This PR addresses the concerns in
https://github.com/flame-engine/flame/issues/3488
For convenience, here is the relevant text.
> It is a fairly common feature for a game to "type out" dialogue within
a TextBoxComponent (as the behavior would be if timePerChar > 0, but
also allow the user to skip that type-out effect, and display the
dialogue in its entirety (as the behavior would be if timePerChar == 0).
This PR implements a setter for TextBoxComponent.boxConfig, allowing for
the TextBoxConfig to be changed after TextBoxComponent is instantiated.
The `_boxConfig` has been made non-final to allow this field to be
modifiable.
Additionally, a `skip` method is implemented which more explicitly
provides the intended skipping behavior.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Updates to use the new color method `withValues`.
---------
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
Final tweaks to prepare merging flame_3d.
As can be seen [on the merge
PR](https://github.com/flame-engine/flame/pull/3377), we are almost
ready to have a nice diff to merge. This fixes a couple final issues:
* the `.4 -> 0.4` thing that I had copied from main before merging my
fix into main (this will "untouch" that file from the main diff)
* the min flutter version as set by `melos bs` on the flame_3d package
itself
Update cicd.yml file on flame_3d to match main.
Since we finally updated main, we should require no difference
whatsoever on this file anymore.
This will require downgrading all the color changes, which is fine. This
should never have been a part of flame_3d to begin with.
Files were "untouched" by checking out the exact version as they are in
main right now (will need to rebase flame_3d to main later). I had to
add a couple more files because the files on main had dependencies on
changes that are not yet rebased on flame_3d. These extra diffs should
disappear when I do the final rebase.
This PR adds the `WorldRoute` which acts as a normal route, but instead
of adding a new component (page), it swaps out the world that the camera
(either the default camera or an explicitly passed in one) is watching.
To sort overlays we can introduce a priority.
Let's say my app contains several menus that can be displayed
simultaneously, but I want my main menu displayed at first in the stack
(at the bottom).
Adds a `Paint` attribute to the `SpriteWidget` and
`SpriteAnimationWidget` for an improved API.
---------
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Enable DCM rule double-literal-format.
More details
[here](https://dcm.dev/docs/rules/common/double-literal-format/). This
both forbids trailing zeroes and mandates leading zeroes.
If we would prefer a different style (e.g. prefer no leading zero
instead), just lmk :)
Update IsometricTileMapComponent to have better defined position and
size.
Before, the isometric component "zero" would be the center of the 0,0
block.
However, that does not play nicely with our component system if you want
to know the size (i.e. bounding box) of a component.
This changes so that the 0,0 of the component is the 0,0 of the AABB
around the isometric tiles. Then, it also computes the size of the
component accordingly.
This also changes the example to allow toggling between half and full
size more easily.
In our example, this is what it looks like:

The example still shows how to compute the previous origin (the purple
dot) if you want to.
With full size blocks:

This is a minor breaking change as you might need to "reposition" your
tile components, essentially remove the "compensation" for its location
that you probably did yourself. If you were centering the tile component
based on the available methods such as `map.getBlockCenterPosition`,
then just make sure you are adding the `map.position` to that and it
should work as before.
Previously some rays that originated outside of the `CircleHitbox` were
counted as inside, this solves that and adds an example of how to use
the `isInsideHitbox` functionality (thanks to @wurzelsand).
Closes#3063
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>
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.
The `visibleGameSize` should be based on the virtual size of the
viewport, otherwise it won't work for `FixedResolutionViewport` for
example.
We noticed this when using the `ScreenHitbox` in a world that was looked
upon by a camera with a `FixedResolutionViewport`.
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>
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>
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.
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.
Bumps forge2d to 0.12.2
Migration instructions:
The gravity and bullet are now field setters and getters, so if you
before had `setGravity(Vector2(0, -10))` then you now do `gravity =
Vector2(0, -10);` and if you previously had `body.setBullet(true);` you
now do `body.isBullet = true;`.
This enables you to zoom when using the CameraComponent.withFixedResolution constructor, without disabling the fixed resolution after doing so, by introducing a new viewport the FixedResolutionViewport.
This PR adds a backdrop component to the `CameraComponent` which renders
behind the world.
With this change the rendering order looks like this:
```
backdrop
world
viewport
viewfinder
```
In the following example you can see a `ParallaxComponent` attached to
the backdrop, a player and some other components attached to the world,
and some texts attached to the viewfinder and viewport:
