274 Commits

Author SHA1 Message Date
d1777b7a9e feat: Add a setter for TextBoxComponent.boxConfig and add a convenience method to skip per-char buildup (#3490)
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>
2025-02-13 11:13:07 +00:00
8d8be05b32 fix: SpawnComponent.periodRange should change range each iteration (#3464)
The `SpawnComponent` accidentally didn't update the range each iteration
due to that the `minPeriod` variable wasn't set.
2025-01-28 20:46:32 +00:00
13bb7cf44b docs: Use built-in camera in example (#3458)
This uses the built-in camera in the example, so that people don't
create new default cameras accidentally.
2025-01-26 14:07:09 -03:00
f85263f271 fix: Darkness increases with higher values (#3448)
Previously, .darken(.98) would darken the image by 98%, now it darkens
by the inverse by 2%. This restores the original functionality.
2025-01-18 21:38:57 -05:00
de8e3bcea2 fix: Fix brighten and darken alpha issue (#3414)
Fix brighten and darken alpha issue.
This is all thanks to @jtmcdole's insight & fixes
[here](https://github.com/flame-engine/flame/pull/3407).

---------

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Co-authored-by: John McDole <john@mcdole.org>
2024-12-17 19:06:14 +01:00
ba3b225a4b docs: Update the ClipComponent example (#3389)
This PR updates the ClipComponent example to make it clear how the
clipping works.

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-12-13 22:52:28 +01:00
978ad31b42 refactor: Fix lint issues from latest flutter release (#3390)
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>
2024-12-13 22:40:54 +01:00
d4094b2a1b chore: Final tweaks to prepare merging flame_3d (#3381)
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
2024-12-11 14:26:29 -05:00
06f5a4b4a8 chore: Update cicd.yml file on flame_3d to match main, rollback color changes (#3378)
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.
2024-12-11 14:26:29 -05:00
27e4dcb65a chore: Update usages of Dart UI Color to not use deprecated fields and methods [flame_3d] (#3297)
Update usages of Dart UI Color to not use deprecated fields and methods.
On latest main of Flutter these will cause lint errors, [as can be seen
here](https://github.com/flame-engine/flame/actions/runs/10814047130/job/29999530293?pr=3282).

Note: I will update the `flame_3d`-specific violations on a followup.
2024-12-11 14:26:29 -05:00
13b4f70fe3 chore: Fix minor lint issue (#3379)
Fix minor lint issue
2024-12-10 16:35:45 +00:00
497f128f8c feat: Add WorldRoute to enable swapping worlds from the RouterComponent (#3372)
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.
2024-11-24 15:05:08 +01:00
e591ebf8a3 feat(overlays): Added the 'priority' parameter for overlays (#3349)
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).
2024-10-21 17:54:28 +02:00
ff170dc5c2 fix: Widgets flickering (#3343)
Fix the flickering in the widgets: `SpriteAnimationWidget`,
`SpriteWidget` and `NineTileBoxWidget`.
2024-10-16 12:11:17 -03:00
a17fe4cdfa fix: Fix SpriteBatch to comply with new drawAtlas requirement (#3338)
Fix SpriteBatch to comply with new drawAtlas requirement

Fixes: #3331
2024-10-13 12:09:29 -04:00
a5338d0c20 feat: Adding paint attribute to SpriteWidget and SpriteAnimationWidget (#3298)
Adds a `Paint` attribute to the `SpriteWidget` and
`SpriteAnimationWidget` for an improved API.

---------

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-09-12 12:19:54 +00:00
4af00c1a85 feat: Adding on game resize example (#3260)
Simple example to test the `onGameResize` lifecycle method.


https://github.com/user-attachments/assets/e0a874e9-f1f8-4fc3-b9bd-11a726a22794
2024-08-09 13:35:31 -03:00
fabbf928d0 chore: Enable DCM rule double-literal-format (#3248)
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 :)
2024-07-30 11:17:27 -04:00
df9be25ba4 docs: Fix code links for jenny examples (#3229)
Jenny code links were broken in examples. This PR fixes them.
2024-07-21 10:33:18 +00:00
1b0bee726b fix: Update version of lints to comply with new pub requirements (#3223)
Update version of lints to comply with new pub requirements.
2024-07-16 15:49:47 +02:00
6e517fa229 docs(example): DraggableBox does not follow the cursor smoothly (#3204)
This PR makes the `DraggableBox` movement more smooth and predictable
by:
1) adjusting `FixtureDef` and `MouseJointDef` parameters
2) setting the `MouseJoint` target to
`game.screenToWorld(event.deviceEndPosition)` rather than
`event.localEndPosition`

Fixes https://github.com/flame-engine/flame/issues/3203

The comparison recordings are presented below:

<details closed><summary>GearJointExample</summary>

  | BEFORE | AFTER |
  |----------|----------|
| <video
src="https://github.com/flame-engine/flame/assets/30288967/8188ed18-e0aa-4c0f-a6c4-092015ba471c">
| <video
src="https://github.com/flame-engine/flame/assets/30288967/2388bf23-ab32-43a8-af88-a974687b6901">
|

</details>

<details closed><summary>PrismaticJointExample</summary>

  | BEFORE | AFTER |
  |----------|----------|
| <video
src="https://github.com/flame-engine/flame/assets/30288967/80ca56cd-7b7c-4a12-a551-37f268011bb0">
| <video
src="https://github.com/flame-engine/flame/assets/30288967/aaae0f7d-230b-47db-a1c2-cc39cace74e7">
|

</details>

<details closed><summary>PulleyJointExample</summary>

  | BEFORE | AFTER |
  |----------|----------|
| <video
src="https://github.com/flame-engine/flame/assets/30288967/1d40b0a0-57d2-444e-a324-63112548f9e3">
| <video
src="https://github.com/flame-engine/flame/assets/30288967/6deb1226-0f96-440f-ba72-14806612bd32">
|

</details>

<details closed><summary>RopeJointExample</summary>

  | BEFORE | AFTER |
  |----------|----------|
| <video
src="https://github.com/flame-engine/flame/assets/30288967/60b2ceee-4a41-4443-a2db-de5515270f18">
| <video
src="https://github.com/flame-engine/flame/assets/30288967/c06e35ff-2c59-4a02-b6bb-7611817a76c0">
|

</details>
2024-06-24 19:19:26 +00:00
67e069c00d feat: Support inline code blocks on markdown rich text (#3186)
Support inline code blocks on markdown rich text.
2024-06-06 08:57:55 -04:00
194d553656 feat: Support text align on new text rendering pipeline (#3147)
Support text align on new text rendering pipeline.

![image](https://github.com/flame-engine/flame/assets/882703/62f91c8e-f38f-48b0-8c59-06efb10acdf3)

![image](https://github.com/flame-engine/flame/assets/882703/b00afb90-6051-4a2c-aac6-ac36ea1bcba2)
2024-05-06 08:13:10 -04:00
9a7bdc7439 fix!: Update IsometricTileMapComponent to have better defined position and size (#3142)
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:


![image](https://github.com/flame-engine/flame/assets/882703/6e3d6bb5-ff66-4923-9c66-2f0794fd3eab)

The example still shows how to compute the previous origin (the purple
dot) if you want to.

With full size blocks:


![image](https://github.com/flame-engine/flame/assets/882703/485dbffc-51a8-46f5-a125-6f12cce5b35e)


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.
2024-04-29 11:24:05 -04:00
b283b82f6c refactor: Modernize switch; use switch-expressions and no break; (#3133)
Replaces the switch cases that can be replaces with switch expressions
and removes `break;` where it isn't needed.

https://dart.dev/language/branches#switch-statements
2024-04-18 23:41:08 +02:00
67e24a2ae7 chore: Remove repetitive words (#3118)
Replace this text.

Signed-off-by: guqicun <guqicun@outlook.com>
2024-04-06 16:35:29 +02:00
b946ba70cb feat: Add copyWith method on the TextBoxConfig (#3099)
Simplifies the creation of the `TextBoxConfig` in the
`ScrollTextBoxComponent` by adding a `copyWith` method to it and making
it `const`.
2024-03-26 22:21:26 +00:00
8cd9e12319 fix: CircleHitbox should properly detect when ray is outside (#3100)
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
2024-03-26 22:59:29 +01:00
6daf7a3d35 docs: Fix broken link to flame_jenny example code (#3093)
The links for the flame_jenny examples were pointing on the wrong URL.
2024-03-25 10:43:49 +01:00
0028b5cb15 docs: Jenny example (#3086)
Replace this text.

---------

Co-authored-by: xjyribro <limcheekee.63@gmail.com>
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2024-03-23 13:21:09 +01:00
12841d6471 docs: Update RawKeyEvent references to KeyEvent (#3052) (#3053)
This PR fixes #3052 and updates deprecated type references in docs from
`RawKeyEvent` to `KeyEvent`.

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2024-03-06 14:40:54 +01:00
330862c98e fix!: Migrate from RawKeyEvent to KeyEvent (#3002)
First pass at migrating from `RawKeyEvent` and `RawKeyboard`
to `KeyEvent` and `HardwareKeyboard`.

Context:
https://docs.flutter.dev/release/breaking-changes/key-event-migration
2024-02-15 23:10:51 +01:00
e27818d872 fix: Set margins of JoystickComponent properly (#3019)
The margins of the `JoystickComponent` weren't set properly, this PR
fixes that.
2024-02-05 11:02:02 +00:00
2fd84c846f feat!: Update flame_noise to use latest version of fast_noise (#3015)
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>
2024-02-04 16:37:54 +01:00
3c38ee6058 feat: Bumped integral_isolates package for flame_isolate (#2994)
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.
2024-01-22 21:08:33 +00:00
bd130b711b fix: The visibleGameSize should be based on viewport.virtualSize (#2945)
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`.
2023-12-21 16:42:07 +00:00
d12e45444e docs: Remove references to Tappable and Draggable (#2912)
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>
2023-12-09 16:09:45 +01:00
8c3cb72541 feat: Scrollable TextBoxComponent (#2901)
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>
2023-12-08 19:53:45 +00:00
63994ebcd8 fix!: Add DisplacementEvent to fix delta coordinate transformations for drag events (#2871)
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>
2023-11-30 16:40:26 +01:00
0fd2662d4b refactor!: Replace Offset with opacityFrom and opacityTo in ColorEffect (#2876)
`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.
2023-11-27 14:21:18 +01:00
f42d0e73be docs: Fix naming of drag- and tap-callbacks examples (#2873)
Fix naming of drag- and tap-callbacks examples
2023-11-26 17:55:35 +00:00
37f7b12f57 fix: Use world on tap_callbacks_example (#2875)
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.
2023-11-26 17:32:59 +00:00
39edc70206 docs: Fix Hover Callbacks so the tap used in the example respects the zoom (#2874)
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.
2023-11-26 18:26:00 +01:00
d51cd584c7 fix: Minor issues due Flutter 3.16 (#2856)
With the last Flutter version, a few issues were introduced in Flame sourcebase. This PR solves that.
2023-11-16 17:50:39 -03:00
03f4e56ffe chore: Bump Forge2D to 0.12.2 (#2836)
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;`.
2023-11-03 22:58:49 +01:00
5b67b8f14a fix: Remove deprecations for 1.10.0 (#2809)
Removed deprecations for 1.10.0 and fixes some small unreleased regressions found when going through the examples.
2023-10-11 15:57:25 +02:00
97fff0ed2b feat: Add advanced button component (#2742)
New button with support for multiple states:
<img width="278" alt="image"
src="https://github.com/flame-engine/flame/assets/18004353/041c1105-8991-4976-b1a2-0553c149ec4e">
2023-10-10 21:43:28 +02:00
4c762f94d4 feat: Introduce the FixedResolutionViewport (#2796)
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.
2023-10-10 00:20:05 +02:00
ab329f718a feat: Backdrop (static backgrounds) component for CameraComponent (#2787)
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:

![image](https://github.com/flame-engine/flame/assets/744771/a0b2fe0e-bff3-4d1d-a2d1-ddd3199bbdab)
2023-10-03 17:26:36 +00:00
35290757f3 docs: Fix broken links to code in examples (#2789)
Fixing broken links to issue #2618
2023-10-03 11:55:27 +00:00