The ClipComponent factory Constructor "circle", "rectangle" and
"polygon" are now redirect Constructor while they persist their previous
behaviour and syntax.
This allows subclasses of ClipComponent to directly address them.
```dart
/// Examples:
SubClass.fancyShape() : super.polygon();
Smiley() : super.circle();
```
---------
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
This PR adds a new method to the `SpriteBatch` class which allow users
to replace the information, based on an index of the batch.
This is useful when you want to change some of the rendering calls
without having to rebuild the whole batch.
---------
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
Assignment of the game property on Components using
RiverpodComponentMixin was being performed inside the onLoad method,
meaning if components were unmounted and mounted once again, attempts to
invoke callbacks to the GameWidget's build method would throw an
exception.
This functionality has been moved to the onMount method, where it always
should have been.
Changes to how support for manual listeners is implemented in
flutter_riverpod 2.5.1 (released 4 days ago) have affected
flame_riverpod - specifically, the implementation of
ProviderSubscription.
This PR updates the implementation of manual listeners in flame_riverpod
in the same manner that flutter_riverpod has.
The unused fields of "SpriteWidget", "srcPosition" and "srcSize" and
their matching parameter in the default constructor has been removed.
If SpriteWidget is used, remove the parameter srcPosition and srcSize as
they have not been used in the default constructor.
(This does not belong to SpriteWidget.asset())
Clamp opacity set by the ColorEffect to 1.0; this was causing an issue
when the tween returned values greater than 1.
The test shows that when dt is greater than 0.5 and less than 0.75 for a
period of 1 the tween returns approx 1.2 which causes Color to throw an
exception.
This has now been fixed.
Since https://github.com/flutter/flutter/issues/89433 has also now been
fixed, I have changed the min opacity to 0.
I received an assertion error after I set `autoResize` to true when I am
using `SpriteComponent.fromImage` component. It's kinda weird for me
that the message tells me **"If size is set, autoResize should be false
or size should be null when autoResize is true.''**, but the thing is I
never set the size for that image yet. Then, I check the code and I
found out that the size will never be null anyway, so the `autoresize`
should always be false.
In this PR, I just remove all the fallback value for `size`, so it would
not give an assertion error when `size` is not being set yet while the
`autoresize` is true.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Adding a child component to a parent which is in `removing` state,
caused the lifecycle processing to go into a cyclic dependency when the
parent is re-added. It happens because, while processing the lifecycle
events, child's add event causes itself and the parent to get added to
the blocked list. As a result of this, when the parent's add event is
processed next, it gets skipped due to being in the blocked list.
This PR makes sure that the child does not get enqueued when parent is
about to be removed.
This PR adds an extension on `TiledObject` to allow getting the object's
`position` and `size` as `Vector2` objects.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
```
The following 18 packages will be updated:
Package Name Current Version Updated Version Update Reason
flame 1.14.0 1.15.0 updated with minor changes
flame_isolate 0.5.0+7 0.5.1 updated with minor changes
flame_noise 0.1.1+12 0.2.0 updated with major changes
flame_riverpod 5.1.5 5.2.0 updated with minor changes
flame_test 1.15.3 1.15.4 updated with patch changes
flame_texturepacker 2.1.0 3.0.0 updated with major changes
flame_oxygen 0.1.9+7 0.1.9+8 dependency was updated
flame_tiled 1.18.3 1.18.4 dependency was updated
flame_fire_atlas 1.4.7 1.4.8 dependency was updated
flame_audio 2.1.7 2.1.8 dependency was updated
flame_spine 0.1.1+9 0.1.1+10 dependency was updated
flame_bloc 1.10.9 1.10.10 dependency was updated
flame_rive 1.9.10 1.9.11 dependency was updated
flame_lottie 0.3.0+7 0.3.0+8 dependency was updated
flame_markdown 0.1.1+7 0.1.1+8 dependency was updated
flame_forge2d 0.16.0+4 0.16.0+5 dependency was updated
flame_svg 1.8.9 1.8.10 dependency was updated
flame_network_assets 0.2.0+12 0.2.0+13 dependency was updated
```
Update flame_noise to use the latest version of fast_noise, basically
replacing the Perlin-specific effect controller with a generic
`NoiseEffectController` that can take in any noise class (leveraging the
new Noise2 interface).
Just update from `PerlinNoiseEffectController` to
`NoiseEffectController` and provide the noise/parameters you want
directly into the `noise` field.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Fix warnings and lint issues across the codebase.
This includes:
* equals should now be Object instead of dynamic (and thus we don't need
_help.dart anymore)
* the `always_require_non_null_named_parameters` lint rule is removed
* the `avoid-banned-imports` rule from DCM actually doesn't do anything
unless configured
Previously if you replaced a sprite in a `SpriteButtonComponent` with
`component.button = ...` it didn't update the button visually since the
`sprites` map wasn't updated, this PR solves that.
Previously the `mounted`, `loaded` and `removed` completers for
`FlameGame` weren't called since `FlameGame` doesn't go through the
normal component lifecycle flow, this PR adds so that the completers are
completed properly.
Closes#3003
This PR transfers the
[flame_texturepacker](https://github.com/Brixto/flame_texturepacker) to
the monorepo and updates it to be compatible with the rest of the
structure (linting etc).
When camera is following a component and trying to follow another target
I got an exception:
```
dart:core Iterable.forEach
package:flame/src/camera/camera_component.dart 326:25 CameraComponent.stop
package:flame/src/camera/camera_component.dart 309:5 CameraComponent.follow
test/camera/camera_component_test.dart 69:14 main.<fn>.<fn>
package:flame_test/src/test_flame_game.dart 80:21 testWithGame.<fn>
Concurrent modification during iteration: _Set len:0.
```
Copying viewfinder children before iterating through it and removing
child from parent does the trick, as we are not iterating through the
same list as we are removing items from, but rather a copy of it.
I tried to use camera from `game` provided in the test but it is AFAIK
not mounted and will hence not queue modifications (adds and removes).
Hence I create a new camera and mount it.
Updated package dependencies for flame_isolate.
Added support for TailoredIsolate and computeStream (called
isolateComputeStream in flame_isolate).
Updated the example package with new sprites created by yours truly, and
updated the license for the package, now that there is no assets with
copy-left CC license remaining.
### Migration instructions
Computation function is renamed from `isolate` to `isolateCompute`.
There are future breaking changes that are, as of now, mitigated with a
`@Deprecated` annotation with information regarding what function to use
instead.
Since the user might want to use the `ComponentKey` after it has been
assigned it should be made public.
It also updates `Consumer.key` to `Consumer.widgetKey` in flame_riverpod
to avoid a name clash. (Slightly breaking)
### Migration instructions
If you are using `consumer.key` from flame_riverpod you have to now use
`consumer.widgetKey` instead.
## Related Issues
Closes#2985
Previously, the `PolygonComponent.containsPoint()` and
`.containsLocalPoint()` functions consisted of duplicate code that
checked whether a given point lies within a convex polygon. They didn't
function properly with concave polygons.
I created a new `_containsPoint()` function that is called from both
functions to reduce redundancies. This new function uses a different
approach to figure out whether a point lies within a polygon, which
should also work for concave polygons, or even polygons with holes. The
algorithm is vaguely explained within code comments, and is visualized
in this post: https://stackoverflow.com/a/218081/5008997
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>