-
-
Notifications
You must be signed in to change notification settings - Fork 899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Effect controllers restructuring #1134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but docs are missing
packages/flame/lib/src/effects2/controllers/standard_controller.dart
Outdated
Show resolved
Hide resolved
packages/flame/lib/src/effects2/controllers/effect_controller.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work @st-pasha!
I'll merge this, and agree with Luan, great job! We still need to update the docs for the effects though, will you do that @st-pasha? |
yep |
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.
Description
Given the new requirement that effect controllers must be able to run backwards in time, and owing to the considerable complexity this entails, this PRs decomposes effect controllers into multiple small building blocks. The main API of
EffectController
remains mostly unchanged (with few new properties added), but the implementation of various effect controllers changes radically. In particular, there is no more classStandardEffectController
. Instead, there are several smaller classes:LinearEffectController
,CurvedEffectController
,ReverseLinearEffectController
,ReverseCurvedEffectController
,DelayedEffectController
,RepeatedEffectController
,InfiniteEffectController
,PauseEffectController
,SequenceEffectController
.In addition, factory constructor
EffectController()
has exactly the same API as oldStandardEffectController
, and can be used in its place.This new structure gives several advantages:
StandardEffectController
were producing an incomprehensible mess.SimpleEffectController
is no longer needed, theEffectController()
constructor will use as little or as many building blocks as necessary to create the effect controller.Checklist
///
) and updated/added examples indoc/examples
.flutter format
and theflutter analyze
does not report any problems.[next]
inCHANGELOG.md
.Draft
status, by clicking on theReady for review
button in this PR.Breaking Change
CHANGELOG.md
).