17 Commits

Author SHA1 Message Date
843ddc3624 refactor: Move to package imports (#1625)
* refactor: Move to package imports

* Fix local imports

* Removed unused imports
2022-05-15 15:04:35 +00:00
2fbfd3d605 feat: Dual Effect & Its separate removals (#1289) 2022-01-07 17:39:50 +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
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
790b8f73dd Remove old effects system (#1157)
* Remove old effects system

* Add changelog entry
2021-12-03 15:02:25 +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
3abde23450 Move effects (#1077)
* Added MoveEffect

* formatting

* update comments

* Add example for move effects

* Added tests

* changelog

* flutter analyze

* avoid creating newPosition object

* added a trailing comma

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-11-07 20:38:47 +00:00
6e7e098f1b New Rotate effect (#1061)
* Added FlameAnimationController class

* Added MainAnimationController class

* Update doc comments

* formatting

* rename MainAnimationController

* Added tests for StandardAnimationController

* Added more tests

* comment

* Added changelog note

* Export StandardAnimationController

* formatting

* Use a default for 'curve' parameter

* rename onsetDelay -> startDelay

* Added Transofm2DEffect

* Added EffectComponent

* Added .transform getter

* formatting

* Rename EffectComponent -> Effect

* Add documentation for the Effect class

* minor

* Added a test for Effect class

* Adding tests for removeOnFinish

* Adding tests for onStart and onFinish

* Also check the effect after reset

* Fix-up merge

* formatting

* added doc-comments

* changelog note

* Added test for transform2DEffect

* Adjusted comments

* Make PositionComponent._transform public

* change changelog

* Adding RotateEffect

* wip on rotate2 example

* Rename -> RotateEffect2

* export rotation effect

* Finish example for RotateEffect2

* formatting

* rename RotateEffect2 -> RotateEffect

* Changelog note

* Added test file

* flutter format

* Remove a print() call

* _lastProgress moved to Transform2DEffect class

* remove avoid_print for now

* Moved description

* Initialize paints during construction

* Added a random test

* flutter format

Co-authored-by: Lukas Klingsbo <lukas.klingsbo@gmail.com>
2021-11-02 21:08:55 +01:00
d9984c7bda RemoveEffect (#1063)
* Added FlameAnimationController class

* Added MainAnimationController class

* Update doc comments

* formatting

* rename MainAnimationController

* Added tests for StandardAnimationController

* Added more tests

* comment

* Added changelog note

* Export StandardAnimationController

* formatting

* Use a default for 'curve' parameter

* rename onsetDelay -> startDelay

* Added Transofm2DEffect

* Added EffectComponent

* Added .transform getter

* formatting

* Rename EffectComponent -> Effect

* Add documentation for the Effect class

* minor

* Added a test for Effect class

* Adding tests for removeOnFinish

* Adding tests for onStart and onFinish

* Also check the effect after reset

* Fix-up merge

* formatting

* added doc-comments

* changelog note

* Added test for transform2DEffect

* Adjusted comments

* Make PositionComponent._transform public

* change changelog

* Added SimpleEffectController

* Added DestroyEffect

* Changelog note

* Rename DestroyEffect -> RemoveEffect

* Added example for RemoveEffect

* flutter format

* Move description of the RemoveEffectExample game

* move the description again

* minor
2021-11-02 09:59:35 +01:00
a1b6ffa04a Game as a Component (#906)
* Game as a component

* Fix component stories

* Effects are now components

* Update effects docs

* Handle swap of parent

* Fix reAddChildren

* Wait for children to be added

* BaseComponent and PositionComponent to be non-abstract

* Simplify HasGameRef

* Revert so that onLoad can be null

* Fix example description

* Effects as components

* Remove gameRef from addChildren

* Fix hasGameRef

* Start migrating effects

* Updated comments of effect fields

* Fix comments

* Continue to fix sequence and combined effects

* Upgrade ordered_set

* Fix position_component_test

* BaseComponent -> Component

* Fix combined and sequence effects

* Await components to be added in tests

* Remove unnecessary game.update in tests

* Fix some tests related to composition

* BaseGame should be used in examples

* Fix CombinedEffect test

* Keyboard code to be based on Component

* Fix keyboard tests

* Fix analyze problems

* Fix sequence_effect

* Fix combined_effect_test

* Store peak state instead of end state

* Fix sequence_effect tests

* Update tutorial

* Fix tutorial 1

* Remove SimplePositionComponentEffect

* Remove unused test variable

* Update docs

* Removed onMount

* Remove onMount

* Add missing dartdoc

* Fix dart docs

* Add super.update where needed

* Move reAddChildren to component

* Reorganize method order in game widget

* preOffset -> initialDelay, postOffset -> peakDelay

* Introduce component.onParentChange

* Remove tests in wrong file

* Fix composed component test

* Add game lifecycle test

* Use BaseGame for mouse cursor test

* Oxygen should (?) not call super.update

* Use BaseGame in keyboard_test

* Fix onLoad to be properly cached

* Re-add unintentionally removed override

* Fix info for collision detection tests

* Add test for correct lifecycle on parent change

* Fix particles example

* Add component lifecycle diagram to the docs

* Add docs for the game lifecycle

* onRemove should be called when a game is removed from the widget

* Fix analyze errors

* prepare should be called from the component itself, not its parent

* Fix dartdoc

* onParentChange -> onMount

* onMount should have void as return type

* Simplify the loaderFuture in GameWidget

* Fix mock_canvas

* Fix rebase problem

* Remove asComponent

* Less complex _loaderFuture

* Add super.update to no_fcs parallax example

* Fix async tests

* Revert _loaderFuture

* Fix analyze issues

* await gameWithCollidables

* Keep epsilon small where it can be

* tappable methods should return bool

* Game lifecycle is now the same as for Component

* Remove mustCallSuper from component.update

* Make onLoadCache protected

* @internal on onLoadCache

* Cache/Memoize debugPaint and debugTextPaint

* Fix imports

* Fix comments

* Always call super.onLoad so that mixins can override it

* Add forgotten super.onLoad

* Bump coverage percentage

* HasCollidables should override update

* Fix Game comments

* Fix some dartdoc

* Apply suggestions from code review

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

* Game + Loadable as mixins

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

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

* Update loadable docs

* Fix comments

* Move fps_counter

* Fix keyboard example

* Fix dartdoc

* Remove tutorials temporarily

* Fix game lowlevel graph

* Fix resize issue

Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Luan Nico <luanpotter27@gmail.com>
2021-09-15 00:17:49 +02:00
54fbd260bc Scale for PositionComponent (#892)
* Draft of PositionComponent.scale

* Use matrix transformations

* Update tests to take matrix transform into consideration

* Add tests for collision detection with scale

* Rename ScaleEffect to SizeEffect

* Use transform matrix to prepare canvas

* Fix scaledSizeCache

* Add changelog entries and docs

* Dartdoc on public access methods

* Update packages/flame/CHANGELOG.md

Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>

* Move cache classes to own directory

Co-authored-by: Jochum van der Ploeg <jochum@vdploeg.net>
2021-08-06 21:59:52 +02:00
b2ea597734 Initial implementation of paint effects (#880)
* Initial implementation of paint effects

* Improving HasPaint

* Adding color effect

* Adding exaustive tests for the HasPaint mixin

* Adding tests for the effects

* some adjustments

* Fixing some imports

* Adding docs

* Adding types to the has paint mixin

* Fixing constructor name for the opacity effect

* Apply suggestions from code review

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

* Luan's suggestion

* Luan's comments

* formatting issues

* dartcodemetrics don't help me :(

* Adding assert

Co-authored-by: Luan Nico <luanpotter27@gmail.com>
2021-07-31 15:58:52 -03:00
769bb711c3 Migrate examples back, change to monorepo (#701) 2021-03-12 09:24:50 -05:00