Commit Graph

3302 Commits

Author SHA1 Message Date
Lukas Klingsbo
80d9d2b354 chore: Remove deprecated methods (#1705)
Removes all methods and classes that were marked to be removed in v1.2.0 in their deprecation tags.
2022-06-06 19:59:31 +00:00
Lukas Klingsbo
49252f8ef2 feat: Add more lint rules (#1703)
Adds some more lint rules and fixes the issues those rules pointed out.
2022-06-06 19:23:25 +00:00
Renan
a15eda0b67 feat: allow external packages to await for game to be loaded (#1699)
When using testWidgets to test pages/widgets that renders a game, one may test a widget in a state after the game has loaded.

This introduces toBeLoaded method to be called by widget tests that evaluate things that happens after the game "onLoad" cycle.

await tester.pumpWidget(GameWidget(game: game));
await game.toBeLoaded(); // ⚠️ calling this before pumping the game into a gameWidget throws assertion error. 
await tester.pump();
2022-06-06 21:05:49 +02:00
Pasha Stetsenko
2711ba60c2 feat: Implement tap events based on componentsAtPoint (#1661)
This PR adds a new event system based on the componentsAtPoint delivery mechanism. These events allow for a proper support of components that implement renderTree() method. The CameraComponent is one such component, with more planned in the future.

Additionally, the following improvements compared to the current tap events added:

    - the same component can be tapped with multiple fingers simultaneously;
    - a component that received onTapDown is guaranteed to receive onTapUp or onTapCancel later;
    - a component that moves away from the point of touch will receive onTapCancel instead of onTapUp (even though the game widget receives onTapUp from Flutter).

Due to the fact that the switch from the current event system to the new event system is potentially a significant breaking change, the new event system is introduced as parallel to the existing one. This way we have more time to test the new system before recommending the switch and deprecating the old one; and the switch itself should feel more gradual.
2022-06-06 15:37:01 +00:00
Lukas Klingsbo
cf67147ea3 feat: Helpers for whether a PositionComponent is flipped. (#1700)
Helpers that just check if the scale is negative so that the user can now whether the component has been flipped.
2022-06-06 09:16:27 +00:00
Alejandro Santiago
1b59d801c6 feat: allow controlling when a fixture is rendered (#1648)
Changes _renderFixtures to renderFixture. This keeps the consistency with the other public render methods in BodyComponent.

Introduces new functionalities:

Allow listening when a given fixture is rendered

Allows modifying the rendering logic for a given (one or more) fixtures.

For example, avoiding a fixture to be rendered:

class MyBodyComponent extends BodyComponent { ... void renderFixture(Canvas canvas, Fixture fixture) { final avoidRendering = condition; // Any condition here. if (avoidRendering) return; super.renderFixture(canvas, fixture); } ... }
2022-06-06 09:01:51 +00:00
Luan Nico
aee77f1974 doc: Add warning about very large numbers on the camera class (#1702) 2022-06-05 13:17:40 -04:00
Luan Nico
f4a9887806 refactor: Update and guarantee consistency on mocktail dev dependency version across repo (#1701) 2022-06-05 12:55:35 -04:00
Pasha Stetsenko
31784ca0b0 feat: Added utility function solveCubic() (#1696)
The function solves a cubic equation, and can be used for a variety of purposes, such as handling the Bezier curves.
2022-06-05 11:41:46 +00:00
nathanaelneveux
4b19a1b203 fix: performance improvements on SpriteBatch APIs (#1637)
Fix for the performance decrease mentioned in #1614
2022-06-04 15:22:11 +00:00
Lukas Klingsbo
f55b2e0dc0 feat: Callbacks in HudButtonComponent constructor and ViewportMargin mixin to avoid code duplication (#1685)
Created a mixin to handle the margin to the viewport, mostly to remove the code duplication in ButtonComponent and HudButtonComponent, but it can also be useful in other cases when you don't want to wrap your component in HudMarginComponent.

Once the new camera system is in place this will of course have to be replaced.
2022-06-04 17:00:12 +02:00
Pasha Stetsenko
c64aedaeb3 feat: Aligned text in the TextBoxComponent (#1620)
- Added option align in the TextBoxComponent which controls the alignment of text.
 - Added option for the TextBoxComponent to have a fixed size (before the only mode was for the textbox to automatically expand/shrink to fit the text).
2022-06-03 23:21:40 +02:00
Pasha Stetsenko
3f28789881 feat: Added ability to render spritesheet-based fonts (#1634)
This PR adds [SpriteFontRenderer], which is a new implementation of [TextRenderer], allowing to render text based on fonts embedded into a spritesheet.

See the T-Rex game example, where the score is now rendered based on a spritesheet font.

(Also added highscore tracking for the TRex game).
2022-06-03 16:30:48 -03:00
Renan
5dcf266423 feat: add options to flutter test (#1690)
Add test options to enclosing test function on flame_test.

This allows users to skip or tag individual tests.
2022-06-03 10:44:15 +00:00
Stijn
c8c51cd824 docs: fix incorrect gameref on ParallaxComponent (#1693)
* Fixed parallax components docs

* Revert "Fixed parallax components docs"

This reverts commit 4c65164a32.

* Docs: Fixed parallaxcomponent docs
2022-06-03 12:16:21 +02:00
Erick
7ef6a51ec6 feat!: Adding GameWidget.controlled (#1650)
* feat: Adding GameWidget.controlled

* follow up

* Update doc/flame/game.md

* follow up

* Update doc/flame/game.md

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>

* Update packages/flame/lib/src/game/game_widget/game_widget.dart

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>

* Update according to comments

* Move out GameWidget docs

* Update game widget docs

* Update docs

* Update GameWidget.controlled example

* Update .controlled dartdocs

* Updated .controlled dartdocs

* Add example to game_widget.md

* Apply suggestions from code review

Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>

Co-authored-by: Renan Araujo <renan.araujo@verygood.ventures>
Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
2022-06-02 13:31:51 +00:00
Ryuzaki
4ca65f8a2c refactor: Add onComplete as optional parameter (#1686)
* Add onFinishCallback as optional parameter

* Rename onFinishCallback to onComplete

* Add void return for onComplete

* Add deprecated getter and setter for onFinishCallback

* Use named onComplete parameter

* Add version in which onFinishCallback will be removed
2022-06-02 06:18:38 +00:00
Lukas Klingsbo
db336c03b6 feat: Children as argument to FlameGame (#1680)
Since we have already added children as an argument to Component, this adds it to the FlameGame.
2022-06-01 22:58:59 +02:00
Pasha Stetsenko
801dbba1d8 refactor: Added MultiDragListener - common API between HasDraggables and MultiTouchDragDetector (#1668)
Created MultiDragListener abstract class, which allows us to simplify code in gestures.dart.
2022-06-01 19:09:54 +00:00
Hwanseok Barth Kang
40a061bcf0 feat!: Add ability to render without loading on image related widgets (#1674)
At first, In #1667, I was planning to change only SpriteWidget to be able to remove showing LoadingBuilder when non-future sprite was passed.
But after some digging, I found that BaseFutureBuilder causes the loading because it only accepts Future as a parameter.
And BaseFutureBuilder are the very base of all image-related widgets such as NineTileBoxWidget, SpriteAnimationWidget, ... etc.

So the key point of this change should allow BaseFutureBuilder to FutureOr as a parameter and split the build function according to the parameter type.

After #1645, the Default constructor of SpriteButton can pass Future but its constructor is not consistent with other image-related widgets.
Plus, type of FutureOr<List<Sprite>> _buttonsFuture only compatible with Future<List<Sprite>> but not List<Sprite>.
So I added secondary constructor SpriteButton.future that accepts only Future and Replaced the FutureOr<Sprite> to Sprite in the default constructor.
2022-05-31 19:23:22 +00:00
Pasha Stetsenko
d8bbfc067e feat: Add solveQuadratic() utility function (#1665)
Adding a helper function for solving quadratic equations.
This allows simplifying logic in CircleComponent, but can also be used in other places later on.

Also, the logic in CircleComponent was simplified to avoid unnecessary line.containsPoint.
2022-05-31 21:16:55 +02:00
Munsterlander
b46cfdb283 docs: Added clarification for onStart, onFrame, onComplete event listeners (#1671)
As the subject says, based on the discussion here: #1654 I have updated the docs for SpriteAnimationComponent.
2022-05-31 15:48:12 +00:00
Pasha Stetsenko
80c648fc94 fix: Deprecate Anchor.translate() (#1672)
This method is not used anywhere, and its name doesn't match the function very well.
2022-05-31 15:41:29 +00:00
Pasha Stetsenko
f8b2410e29 docs: Update Flame min version in "bare flame game" tutorial (#1681)
Updated instructions in the "Bare Flame game" tutorial to account for the current Flutter min version of 2.10.0.
2022-05-30 08:24:52 +02:00
Pasha Stetsenko
84f2f57e5f refactor: Simplify Component.firstChild, .lastChild, and .findParent (#1673)
These methods can be simplified using the extension Iterable.firstOrNull getter.
2022-05-29 21:32:13 +00:00
Pasha Stetsenko
dd05ecb6b8 refactor: Replace some usages of fold<> with .sum (#1670)
In some places in code we used patterns like fold(0, (a, b) => a + b), which can be replaced with a simple .sum from the Iterable extension.
2022-05-29 11:45:58 +00:00
Pasha Stetsenko
dd28183bc4 feat: Keep stacktrace when rethrowing an error from GameWidget (#1675)
We were planning to make this change once we upgrade min Dart version to 2.16; which we finally did in #1617.
2022-05-28 21:50:00 +00:00
Pasha Stetsenko
f37e3a2028 refactor: Deprecate ComponentSet.createDefault() (#1676)
This was a planned move once we'd switch to Dart 2.15; and we're already on 2.16 since #1617.
2022-05-28 22:41:35 +02:00
Lukas Klingsbo
79d823634a docs: Fix the broken example links (#1666)
Fix the last remaining broken example links.
2022-05-28 07:45:19 +00:00
Lukas Klingsbo
53268b5f5f feat: Allow changing parent from null parent (#1662)
changeParent should be allowed even when the current parent is null.
2022-05-27 23:32:11 +00:00
Pasha Stetsenko
04f0d5d172 fix: Subscription for events when game changes in GameWidget (#1659)
Make sure that subscription to GameStateChange events is properly updated when the game: property of a GameWidget changes.
2022-05-28 01:25:54 +02:00
Hwanseok Barth Kang
0ac84c0024 feat: Add ability to add/remove multiple overlays at once (#1657)
As described #1546, It would be more convenient and can reduce the game widget updates if adding or removing overlays at once.
2022-05-28 00:15:52 +02:00
Pasha Stetsenko
6c19fe1aef docs: Fix remaining broken and redirected links (#1664)
Some links still remain broken after #1663, as reported by linkcheck. This PR fixes all of them, except these 5:

https://examples.flame-engine.org/#/Collision%20Detection_Circles

https://examples.flame-engine.org/#/Collision%20Detection_Shapes%20without%20components

https://examples.flame-engine.org/#/Collision%20Detection_Multiple%20shapes

https://examples.flame-engine.org/#/Rendering_Isometric%20Tile%20Map

https://examples.flame-engine.org/#/Controls_Joystick
2022-05-27 19:54:21 +02:00
Lukas Klingsbo
c5af68b944 fix: Dead links and header formatting (#1663)
Fix all the dead links and add two new lines before each new header according to some form of markdown best practices.
2022-05-27 16:57:36 +02:00
Lukas Klingsbo
73b7a4fe10 docs: Release procedure documentation (#1649)
Adds documentation about the release procedure and breaking changes.
2022-05-27 13:14:48 +00:00
Lukas Klingsbo
1b40de094f feat: Add non_constant_identifier_names rule (#1656) 2022-05-26 20:07:37 +02:00
Lukas Klingsbo
5f346fc51a docs: Add Padracing game to the examples (#1651) 2022-05-26 19:32:52 +02:00
Lukas Klingsbo
489204ec68 chore: Move T-Rex to its own package (#1652) 2022-05-24 23:26:56 +02:00
Erick
c887c3616e feat: adding KeyboardListenerComponent (#1594) 2022-05-23 06:32:10 +00:00
oloshe
2e82dc95ec feat: add FutureOr support on SpriteButton (#1645) 2022-05-23 08:19:42 +02:00
Lukas Klingsbo
30d84b7cae refactor: Simplify HudButtonComponent (#1647) 2022-05-21 11:03:20 +02:00
Pasha Stetsenko
821d01c3fa fix!: Game.mouseCursor and Game.overlays can now be safely set during onLoad (#1498) 2022-05-20 21:49:29 +02:00
Pasha Stetsenko
d67065e52d fix: Avoid leaks when using PictureRecorders (#1643) 2022-05-20 13:01:16 +02:00
Pasha Stetsenko
39201c40fa refactor: Component's lifecycle futures moved into LifecycleManager (#1613) 2022-05-18 23:25:36 +02:00
karvulf
69214827a0 fix: Removed warnings using flutter v3 (#1640) 2022-05-18 15:07:50 +02:00
Lukas Klingsbo
9474ce7425 fix: ParallaxComponent.update mustCallSuper (#1635) 2022-05-17 23:09:03 +02:00
Pasha Stetsenko
e239896624 feat: Method componentsAtPoint now reports the "stacktrace" of points (#1615) 2022-05-17 20:52:43 +02:00
Lukas Klingsbo
aeaf9999b0 fix: Export NotifyingVector2 (#1633) 2022-05-16 23:09:21 +02:00
Pasha Stetsenko
5e1f59663b refactor: TextRenderer and TextPaint moved to separate files (#1628) 2022-05-16 17:36:52 +00:00
Pasha Stetsenko
6cc3e82727 fix: Bug in "tty" TextBoxComponent (#1619) 2022-05-16 18:21:14 +02:00