The `bounds` setter of `BoundedPositionBehavior` tries to update the
target's position when bounds are updated. But it wasn't checking if the
target is null. This was causing null exceptions while updating bounds
of an unmounted `BoundedPositionBehavior` with null target (as seen in
[this failing test
case](https://github.com/flame-engine/flame/actions/runs/7231182930/job/19704091006#step:5:1291)).
This PR fixes that by checking if the target is null before updating the
position.
Closes#2655
After a long time, the PR with the step 3 for the space shooter
tutorial!
Replace or remove this text.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
We still had some references to `Tappable` and `Draggable`, this PR
removes them and removes a superfluous test for `TapCallbacks`.
---------
Co-authored-by: jonathan <sharyari@gmail.com>
```
The following 17 packages will be updated:
Package Name Current Version Updated Version Update Reason
flame 1.11.0 1.12.0 updated with minor changes
flame_riverpod 5.0.0 5.1.0 updated with minor changes
flame_test 1.15.0 1.15.1 dependency was updated
flame_tiled 1.18.0 1.18.1 dependency was updated
flame_oxygen 0.1.9+4 0.1.9+5 dependency was updated
flame_isolate 0.5.0+4 0.5.0+5 dependency was updated
flame_fire_atlas 1.4.4 1.4.5 dependency was updated
flame_audio 2.1.4 2.1.5 dependency was updated
flame_spine 0.1.1+6 0.1.1+7 dependency was updated
flame_bloc 1.10.6 1.10.7 dependency was updated
flame_lottie 0.3.0+4 0.3.0+5 dependency was updated
flame_markdown 0.1.1+4 0.1.1+5 dependency was updated
flame_rive 1.9.7 1.9.8 dependency was updated
flame_forge2d 0.16.0+1 0.16.0+2 dependency was updated
flame_noise 0.1.1+9 0.1.1+10 dependency was updated
flame_svg 1.8.6 1.8.7 dependency was updated
flame_network_assets 0.2.0+9 0.2.0+10 dependency was updated
```
This PR introduces a new ScrollTextBoxComponent, enhancing the existing
text box functionalities with scrollable text capabilities. This
component, built on top of the existing TextBoxComponent, is designed to
handle scrollable text, thereby providing a better user interface for
games that require displaying longer text content.
Added docs and and an example.
---------
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Add a new variable to the `CollisionDetection` class. Call
`notifyListeners` at the end of the collision detection step, so that
users can add a listener to their code to know when this step has
finished. The variable is a basic implementation of a `Listenable`
class, since it needs no more complexity.
Closes#2849
The objective of this fix is to make a tap on a card more
positive-feeling for the player and not to disappear silently if it is
interpreted as a drag.
It adds a Base Card to make an empty Stock Pile behave as a Card and use
the tap and drag logic of the `Card` class. Any attempted drag on a
Stock Pile card, including the Base Card, is now changed to a tap in
onTapCancel() and the drag is not followed. The Base Card is rendered in
outline only and does *not* take part in gameplay.
In other Piles a short drag is either treated as a tap or ignored. Only
the Waste and Tableau Piles allow such taps. As before in Klondike
Step5, they result in the tapped card moving automatically to its
Foundation Pile if it is eligible to "go out".
As before in Klondike Step4 and Step5, all piles except the Stock Pile
allow drags to start on them and they can finish on a Foundation Pile or
a Tableau Pile.
Closes#2890.
When testing, try sliding the finger or mouse slightly while making a
tap.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
The Snapshot mixin was missing a function to clear the snapshot. This is
useful for when you want to invalidate the picture, but don't want to
immediately pre-render the image yet.
When the cards are dealt at the start of a Klondike Step 5 game there
are multiple occurrences of unrealistic behaviors:
- Several cards being dealt may come from the middle of the Stock Pile,
- Cards that are dealt early can be seen moving in front of cards that
are dealt later.
Each card dealt should be rendered on the top of the Stock Pile and
should be seen to come from there. During the deal, later cards dealt
are placed on top of earlier ones, so later cards should be seen to move
in front of earlier ones when they are travelling from the Stock Pile to
their positions in the layout.
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
`SpriteAnimationWidget` was incorrectly reseting its `animationTicker`
everytime it had a change, even if the playing attribute did not change.
This PR fixes that.
Update t-rex game to use `TapCallbacks` instead of `TapDetector`, in
anticipation of [deprecating the
latter](https://github.com/flame-engine/flame/pull/2886).
Also update the term high score to avoid a dictionary entry.
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Add an ad-hoc index page with routing links to all examples within
doc/flame/examples.
Before, it would just show a cryptic error message that would require
checking the code to understand how to access a specific one.
These examples are used with route pre-set within the docs so they are
not normally accessed by users directly, however this is helpful when
you refactor something and wish to double-check the examples still work.

Obviously it could be improved further, but this already helps finding
what you seek quickly.
This adds `DisplacementEvent` to fix delta coordinate transformations
for drag events, to be used instead of `PositionEvent`.
Drag Events now expose the start and end position, as well as the delta,
correctly transformed by the camera and zoom.
This also ensures that drag events, once starts, do not get lost if the
drag update leaves the component bounds.
* if you are using `DragUpdateEvent` events, the `devicePosition`,
`canvasPosition`, `localPosition`, and `delta` are deprecated as they
are unclear.
* use `xStartPosition` to get the position at the start of the drag
event ("from")
* use `xEndPosition` to get the position at the end of the drag event
("to")
* if you want the delta, use `localDelta`. it now already considers the
camera zoom. no need to manually account for that
* now you keep receiving drag events for the same component even if the
mouse leaves the component (breaking)
---------
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
`ColorEffect`'s API was a bit confusing because it used `Offset` for
getting values of opacity start and end from user. This PR changes that
to use optional `opacityFrom` and `opacityTo` double parameters. It also
adds validate checks on these value to make sure that are between 0 and
1.
`spine_flutter` got a new release recently, which fix the issue that the
dependency overriding was handling, so this PR removes the dependency
override and updates the package.
Make `Viewfinder` and `Viewport` comply with `CoordinateTransform`
interface; they already perform the coordinate transform operation but
didn't technically implement then interface.
Use world on tap_callbacks_example. We should just standardize all
examples to use the world unless there is a reason not to, in order to
avoid confusing users.
Fix Hover Callbacks so the tap used in the example respects the zoom.
The example happens to use a tap event to create new squares. However,
since the tap event is bound to the Game instead of the World, had it
had any zoom applied (which it didn't), or any other camera transform,
the squares would have been created on the wrong place. This sends a bad
example to new users and can cause confusion.
Adds new configurations to Flame Tiled's atlas packing. Spacing which
can be used to tilesets are not too close to each other in the atlas,
something that can cause texture leaking causing weird rendering issues.
Primarily this PR is completing Step 5 of Flame's Klondike Tutorial and removing the tbc.md file ("To be continued...").
As at the end of Step 4, the Klondike Game had no animation, other than the drag-and-drop moves to play the game. It also had no ways to detect a win, react to a win or play again without re-loading and re-running the whole app. Step 4 played the Klondike Draw 3 variation of Klondike. Step 5 introduces the easier Klondike Draw 1 variation and provides buttons to:
Choose between Draw 1 and Draw 3,
Start the game again with a new deal, or
Start again with the same deal as before.
The new code and step5.md tutorial text cover Effects and EffectControllers in some detail, with complex examples of their use. The animations include:
Returning dropped but misplaced cards to the places they came from,
Settling dropped and validly placed cards into position,
Flipping cards from Stock Pile to Waste Pile,
Turning cards over on the Tableau piles when the cards above them are moved away,
Collecting multiple cards when the game is over,
Dealing and re-dealing multiple cards,
Allowing a card to be auto-moved onTapUp() to its Foundation Pile if it is ready to go out,
Providing a display of moving cards when/if the player wins.
Adds a `componentAtlases` in the `TiledComponent` which can be useful
for debugging purposes, where the developer will be able to inspect the
atlases being used in their game.
With previous implementation of the `SequenceEffect` didn't allowed
developers to extend it and create custom sequence effects. This PR
slightly refactors the class so it can now be extended.
Currently the Flame section opens up when you press jenny due to a
script that we have looking for `index.html`, this PR renames those
pages to be in line with the rest of the docs.
Thanks for reporting it @incendial
Creates a configuration in Flame Tiled that allows developers to use custom paint objects which can be useful when we need to render tilesets that require a different Paint configuration other than the default one. Like low rez pixel art tilesets which benefits from using filterQuality.none
Flame Tiled uses SpriteBatch under the hood to render its tiles. That API has a flag called useAtlas that when false allows rendering to be done through drawImageRects instead of drawAtlas.
There were not way to set that through Flame Tiled though. This PR exposes that as an option for the developer.