170 Commits

Author SHA1 Message Date
6dd0a970e6 docs: Move flame_forge2d examples to main examples (#1588) 2022-05-01 13:00:48 +00:00
666a2b199f feat: Adding classes for raw geometric shapes (#1528) 2022-04-27 17:39:50 +00:00
1bfed57132 feat!: Size effects will now work only on components implementing SizeProvider (#1571) 2022-04-27 19:10:01 +02:00
b99e35120d feat: Added componentsAtPoint() iterable (#1518) 2022-04-25 19:52:21 +02:00
295468f03c feat: Add Transform2D.setFrom and Transform2D.clone (#1495) 2022-03-27 21:48:26 +00:00
6891eaaa24 feat: adding ParticleSystemComponent (#1489) 2022-03-26 12:20:31 -03:00
4c3960c341 feat: Possibility to mark gesture events as handled (#1465) 2022-03-19 18:07:06 +01:00
e894d20133 fix: debugMode should be inherited from parent when mounted (#1469) 2022-03-19 16:13:50 +01:00
d51dc5e132 feat: Added .anchor property to CameraComponent.Viewfinder (#1458) 2022-03-18 09:08:51 +01:00
dfeafdd6f3 fix: Fix collision detection comments and typo (#1422)
* Fix collision detection comments and typo

* Update packages/flame/lib/src/collisions/collision_callbacks.dart

Co-authored-by: Pasha Stetsenko <stpasha@google.com>

* Update doc/flame/collision_detection.md

Co-authored-by: Pasha Stetsenko <stpasha@google.com>

Co-authored-by: Pasha Stetsenko <stpasha@google.com>
2022-03-08 14:38:21 +01:00
29dd09ca92 feat(collision detection)!: Use a broadphase to make collision detection more efficient (#1252) 2022-03-07 09:08:32 +01:00
c61a1c18b5 feat: Camera as a component (#1355) 2022-03-07 08:12:17 +01:00
c753fc4636 feat: Components are now always added in the correct order (#1337)
* wip o lifecycle

* Component.add() is no longer async

* fix a test

* game.ready

* fix analyze issues

* FcsRoot

* fix tests

* fix game-in-game example

* Merge _addImpl with add()

* Move some of the functionality from prepare() into add()

* Moved FcsRoot into component.dart and renamed

* more doc-comments

* dartdocs

* Remove addLater in ComponentSet

* format

* temporarily switch to path dependency in flame_test

* restore a test

* format

* get rid of prepare() in Collidable

* eliminate prepare() in Draggable

* eradicate prepare() in Hoverable

* remove prepare() from Tappable

* remove prepare() method and isPrepared flag

* remove prepareComponent() from HasCollidables

* remove prepareComponent

* make flame_bloc depend on latest flame

* try to solve flame_bloc dependency graph

* fix game resize issue

* fix gameresize for zoomed game

* do not allow zero size in onGameResize

* move onMount() call into add()

* use loadingBuilder when size is 0

* ComponentTreeRoot is now in its own file

* addToParent()

* switch to mount queue

* rename isReadyToMount -> isPrepared

* make isMounted and isPrepared readonly

* minor

* print error stacktrace

* Component.add() is now async

* fix tests

* unused import
;

* undo irrelevant changes in Component

* update tests

* tests cleanup

* format

* expand doc for ComponentTreeRoot

* fix analysis error

* added tests

* update docs

* resolve version conflict in pubspec

* Apply suggestions from code review

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* late final

* remount() function

* remove mountQueue

* simplify ready()

* run mount during children queue processing

* simplify mounting

* rename childrenQueue->childreQueues

* merge tryMounting() with remount()

* avoid statics in components lifecycle

* remove ComponentTreeRoot

* remove dead code

* added a todo

* added docs for SingleGameInstance

* Added tests for SingleGameInstance

* added SingleGameInstance to the main doc site

* Added test for multi-widget games

* cleanup

* use state variable in Component

* remove test as dependency

* upgrade mocktail version

* upgrade dartdoc version

* fix analyzer warnings

* mark staticgameinstance as internal

* remove ComponentSet.addChild

* use log() from dart:developer

* undo changes in flame_bloc/pubspec.yaml

* redo changes in flame_bloc/pubspec.yaml

* fix dependency in flame_test

* remove test dependencies

* update pubspec files

* remove dart_code_metrics from pubspec

* fix a test

* Added GameTester.makeReady

* omit type on class variable when it can be inferred

Co-authored-by: Erick <erickzanardoo@gmail.com>

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
2022-02-14 23:22:44 +01:00
c92432895d feat: adding svg example (#1352) 2022-02-11 10:13:30 -03:00
fad9d1d54f feat: Added NoiseEffectController (#1356) 2022-02-06 13:43:12 +01:00
05f7a4c3d6 refactor: Remove Loadable, optional onLoads (#1333) 2022-01-24 23:23:12 +01:00
20776e8659 refactor: Loadable no longer declares onGameResize (#1329) 2022-01-22 10:58:43 +00:00
70b96b071a feat(gestures): Update scale events to contain pan info (#1327)
Since the ScaleDetector is a superset of the PanDetector we need to include pan info in the scale events too
2022-01-22 11:45:42 +01:00
27adda17b7 fix!: Remove pointerId from Draggable callbacks (#1313)
Since pointerId is already handled by the handle* methods we don't have to expose it in the onDrag* methods, this conforms with the standard set in Tappable.
2022-01-18 23:22:10 +01:00
d77e5efee5 refactor: Use canvas.drawImageNine in NineTileBox (#1314)
`canvas.drawImageNine` is built-in now a lot of logic was removed from NineTileBox.
2022-01-17 00:22:51 +01:00
2fbfd3d605 feat: Dual Effect & Its separate removals (#1289) 2022-01-07 17:39:50 +01:00
c888703d6e feat(effects): Added SineEffectController (#1262)
An effect controller that represents a single period of the sine function. Use this to create
natural-looking harmonic oscillations. Two perpendicular move effects governed by
SineEffectControllers with different periods, will create a [Lissajous curve].
2021-12-28 00:12:39 +01:00
7c6ae6def3 feat(effects)!: Added SequenceEffect (#1218)
Added SequenceEffect, which performs a series of other effects.

The biggest challenge in implementing this feature came from the need to run the sequence in reverse, due to the alternate flag. This required that every effect and every controller supported running "back in time", which is not as simple as it sounds.

The following breaking changes were introduced:

    The Effect class no longer supports .reverse() method and .isReversed flag.

    This flag was added only 2 weeks ago (

Effect controllers restructuring #1134), with the idea that it will be necessary for the SequenceEffect. However, as it turned out, this flag is not as helpful as I thought it would be. In fact, given the user's ability to change it any point, it makes the implementation very error-prone.

To be clear, the ability for each effect to run in reverse remains -- only now it can no longer be triggered by the user manually. Instead, SequenceEffect triggers that ability itself at the alternation point. If there is demand in the future to manually force any effect to run backwards, we could restore this flag, but this would require thorough testing to make it work correctly.

Infinite effects now return duration = double.infinity instead of null, which seems more appropriate.
2021-12-27 21:57:48 +01:00
59adc5f34c feat(effects): Added ZigzagEffectController (#1261)
Simple alternating effect controller. Over the course of one period, this controller will proceed
linearly from 0 to 1, then to -1, and then back to 0. Use this for oscillating effects where the
starting position should be the center of the oscillations, rather than the extreme (as provided
by the standard alternating EffectController).
2021-12-27 17:19:18 +00:00
240634e7a3 docs: Fix keyboard example instructions (#1281) 2021-12-27 17:02:09 +00:00
bac6c8a446 refactor: Add a few more rules to flame_lint, including use_key_in_widget_constructors (#1248)
This:

    Add new rule use_if_null_to_convert_nulls_to_bools to flame_lint (no violations)
    Add new rule use_key_in_widget_constructors (several violations)
    Fix violations
    Exclude generated files from flame_lint (we don't have any on this repo but when using on games often there are)

I believe this is not a breaking change because it just adds optional arguments to constructors, but if it is, we can reconsider this PR.
2021-12-19 11:07:42 +01:00
cdb2650b29 feat: Add RandomEffectController (#1203)
* Create RandomEffectController

* added tests

* added example

* documentation

* formatting

* fix a test

* formatting

Co-authored-by: Erick <erickzanardoo@gmail.com>
2021-12-13 00:38:05 +01:00
5c47d7f6d7 chore: analyze issues introduced from new dart version (#1196)
* Added Component.childrenFactory

* fix some of the lint warnings

* more lint warnings

* remove changelog entry

* more analyzer warnings

* one more warning

* one more warning

* remove more unused imports

* fix more warnings

* another warning

* one more warning

* a lot more warnings

* some more warnings

* fix warnings in flame_svg

* fix warnings in flame_bloc

* Remove OrderedSet override feature

* Remove testRandom change

* Remove unnecessary type checks

* Re-remove deprecated argument in random_test

Co-authored-by: Pasha Stetsenko <stpasha@google.com>
2021-12-09 15:40:43 +01:00
dec04f3335 Work around Flutter bug for ColorEffect and fix broken links (#1178)
* Fix `ColorEffect` Flutter bug and example links

* Remove accidental code

* Fix `ColorEffect` test
2021-12-08 13:19:00 +01:00
b71c61be40 Implementing ColorEffect on the new effects system (#1171)
* Implementing ColorEffect on the new effects system

* docs and test

* docs

* Apply suggestions from code review

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* PR suggestions

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-12-08 09:22:12 +00:00
07ab8ce9c9 respectCamera and respectViewport proposal: coordinate system enum (#1167)
* Coordinate system

* Fixess

* .

* .

* Fix tests

* Rename CoordinateSystem to PositioningType

* Update docs for PositioningType

* Use switch instead of if-else

* PositioningType -> PositionType

* Don't do unnecessary transforms

* Added tests for PositionType.widget

* Update doc/components.md

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Added PositionType tests

Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-12-08 09:07:36 +00:00
96991122f4 MoveAlongPathEffect (#1172)
* MoveAlongPathEffect separated from MoveEffect

* rename _lastPosition -> _lastOffset

* Added absolute= flag in MoveAlongPathEffect

* added test for absolute path

* add oriented= flag

* added test

* changelog

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-12-07 20:45:53 +01:00
c35fb46078 Fix hitbox circle on flip (#1165) 2021-12-05 20:38:52 +01:00
bfcda073bb Effect controllers restructuring (#1134)
* Update effectController

* move effect controllers into the controllers/ directory

* Add .forward property to EffectController

* SimpleEffectController supports reverse time

* Fixing some compile errors

* rename SimpleEffectController -> LinearEffectController

* minor cleanup

* DurationEffectController and PauseEffectController

* ReverseLinearEffectController

* CurvedEffectController and its reverse

* InfiniteEffectController

* Added EffectController.recede()

* Add EffectController.update()

* Add InfiniteEffectController'

* RepeatedEffectController

* SequenceEffectController

* DelayedEffectController

* Restore the [EffectController.started] property

* minor

* Rename reset() -> setToStart()

* time direction is now managed from the Effect class

* StandardEffectController replaced with function standardController()

* update some doc-comments

* flutter analyze

* flutter format

* fix some tests

* more test fixes

* fix remaining tests

* format

* rename local variable

* minor simplification

* Expand docs in PauseEffectController

* added tests

* Curved controller test

* fix errors

* formatting

* added more tests

* format

* fix RepeatedEffectController

* more tests

* format

* changelog

* increase tolerance

* Replaced standardController with factory EffectController constructor

* Added parameter EffectController({alternate=false})

* Added default for curve= parameter

* rename

* rename tests

* added more exports

* rename tests

* rename src/effects2

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-12-04 15:58:42 +00:00
4b40479563 Rename isHud to respectCamera (#1159)
* Camera as an internal component

* Correct respectCamera

* Added changelog entry

* Add super call that will later be removed

* Rename callRender -> callOwnRender

* Don't call render when root

* Remove callOwnRender

* Skip CameraWrapper in own renderTree

* Too complex to have camera as component

* Revert test

* Update docs for respectCamera

* Move down field

* Fix changelog
2021-12-04 13:41:51 +00:00
790b8f73dd Remove old effects system (#1157)
* Remove old effects system

* Add changelog entry
2021-12-03 15:02:25 +01:00
fe162c6d90 Introduce updateTree (#1158)
* Introduce updateTree

* Update tests

* Fix update for game-in-game situations

* Add dartdoc to updateTree
2021-12-03 14:01:46 +01:00
ca8f8d3632 Added a ButtonComponent (#1146)
* Added a ButtonComponent

* Don't import VoidCallback

* Change epsilon since test is flaky

* Added SpriteButtonComponent

* Add changelog entry

* Add docs
2021-11-29 21:01:05 +01:00
a2b8c4c44c OpacityEffect in the new effects engine (#1133)
* OpacityEffect example

* Add OpacityEffect example

* Added test for OpacityEffect

* Added changelog entry

* Fix dartdocs

* Reset rounding errors between runs

* Fix test and rounding error

* Update rounding error calculation

* Rounding error should be private

* Bump test epsilon
2021-11-25 11:00:14 +01:00
f249b43e2f Added the SizeEffect and a general ComponentEffect (#1122)
* Added the `SizeEffect` and a general `ComponentEffect`

* Added changelog entry

* Format throw

* Fix analyze issue

* Fix Transform2DEffect test

* Apply suggestions from code review

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Fix missing example parenthesis

* Fix according to comments

Co-authored-by: Luan Nico <luanpotter27@gmail.com>
2021-11-22 21:55:14 +01:00
e6e5a1582c Refactored ScaleEffect to the new effects engine (#1123)
* Scale effect

* Scale effect should affect scale...

* Add ScaleEffect example

* Added `ScaleEffect`

* Fix analyze issue

* Fix ScaleEffect tests
2021-11-20 02:20:06 +01:00
8b132d7c0b Unify examples structure (#1118)
* Animations, CameraAndViewport, CollisionDetection and Components unified

* Added descriptions to effects

* Rename input games

* Unify input stories

* Add info to parallax section

* Added descriptions to the rendering examples

* Add descriptions to the sprites directory

* Fix utils and rendering section

* Add descriptions to the widgets section

* Delete directory that rebase brought back

* Unify game names

* Added some styleguide docs for examples

* Fix analyze issues

* All files should have _example as suffix

* Made the FollowComponentExample a bit easier to understand

* Change priority of ember
2021-11-19 14:28:04 +01:00
03128170bd Add some new lint rules (#1117) 2021-11-18 15:35:10 +00:00
12fd07e5ae Possibility to initialize all PositionComponents from onLoad (#1113)
* Fix ParallaxComponent constructor

* Fix sizing bug parallax_component

* Unify TextComponent and TextBoxComponent

* Fix tests

* Update PositionComponent docs

* Add changelog entry

* Apply suggestions from code review

Co-authored-by: Erick <erickzanardoo@gmail.com>

* Fix analyze issue

* Apply suggestions from code review

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Fix line length in components.md

Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
2021-11-18 11:42:12 +01:00
795264edbf Unify mixin names (#1114) 2021-11-18 08:48:31 +01:00
950a7d6152 Improvements to isometric tilemaps (#1109)
* Improvements to isometric tilemaps

* Changelog

* Add test

* const block

* Fix example

* Update packages/flame/lib/src/components/isometric_tile_map_component.dart

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* Update packages/flame/lib/src/components/isometric_tile_map_component.dart

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* Update packages/flame/lib/src/components/isometric_tile_map_component.dart

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-11-16 15:36:23 +01:00
abc29dbc58 Improving TimerComponent API (#1085)
* Improving TimerComponent API

* pr suggestion

* Update packages/flame/lib/src/components/timer_component.dart

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* pr suggestion

* docs

* pr suggestions

* fixing

* renaming to onTick

* Update packages/flame/lib/src/components/timer_component.dart

Co-authored-by: Luan Nico <luanpotter27@gmail.com>

* Apply suggestions from code review

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

* fixing issues

* fixing flmae bloc isse

* more suggestions

* Update packages/flame/lib/src/timer.dart

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
2021-11-15 14:55:18 +00:00
39c9c55da1 Remove a file that was added to repo by accident (#1097) 2021-11-14 18:20:25 -03:00
3cb23ef530 TextPaint to use TextStyle instead of TextPaintConfig (#1086)
* `TextPaint` to use `TextStyle` instead of `TextPaintConfig`

* Update packages/flame/lib/src/text.dart

Co-authored-by: Pasha Stetsenko <stpasha@google.com>

* Removed BaseTextConfig and TextPaintConfig

* Update text docs

* Apply suggestions from code review

Co-authored-by: Erick <erickzanardoo@gmail.com>

* Remove generics

* Update TextBoxExample

* Update text examples variable names

* Fix TextPaint in collision_detection example

Co-authored-by: Pasha Stetsenko <stpasha@google.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
2021-11-13 16:38:06 +01:00
cd7a0bbb65 ShapeComponent and Hitbox to take transform of parents full ancestor tree into consideration (#1076)
* `ShapeComponent` changes size, position and angle of underlying Shape

* Added description to ShapeComponent

* Fix test

* Update packages/flame/lib/src/components/shape_component.dart

Co-authored-by: Erick <erickzanardoo@gmail.com>

* Add absoluteScale and absoluteAngle to PositionComponent

* Refactor ShapeComponent

* Should be scaled by total scale, not scaled size

* Premature optimization for creation for objects in Polygon

* Use path for default Polygon constructor

* Do not sync component and hitbox shape

* Fix analyze issue

* Add example for flipping with collision detection

* Don't use absoluteScale

* Fix examples

* Fix examples

* Doesn't need super.render

* Fix Circle dartdoc

* Update changelog

* Update names of vertices caches in Polygon

* Update text docs

* Revert "Update text docs"

This reverts commit 73a68a465d76eb0eb50bb3753e57b2f4e3b5a7f4.

* Fix examples

* ShapeComponents docs

* Move example games to the top

* Fix dartdoc comment about polygon vertex relation

* Fix order of polygon vertices in dartdoc

* Fix anchor for PolygonComponent.fromPoints

* Add test with ancestors

* Update doc/components.md

Co-authored-by: Pasha Stetsenko <stpasha@google.com>

* Update doc/components.md

Co-authored-by: Erick <erickzanardoo@gmail.com>

* Rename example classes

* Fix linting issues in examples

* Don't use px

* Use isTrue and isFalse

* Update doc/components.md

Co-authored-by: Erick <erickzanardoo@gmail.com>

* Fixed comments on PR

Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Pasha Stetsenko <stpasha@google.com>
2021-11-13 16:00:24 +01:00