-
-
Notifications
You must be signed in to change notification settings - Fork 905
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
feat!: New AlternatePattern
argument for SequenceEffect
#3322
base: main
Are you sure you want to change the base?
feat!: New AlternatePattern
argument for SequenceEffect
#3322
Conversation
…the direction of the delta offset vec. Corrected progress getter overload in SequenceEffect to correctly map to the progess when _index < 0. Added onStart() in the initial conidition of ecede() so that effects like MoveEffect can recalculate their initial data. Removed unnecessary math in DurationEffectController to avoid potential negative zeros. Replaced �lternate boolean for SequenceEffect with a new type AlternatePattern which allows users to include or exlude the last effect in the sequence when the pattern reverses. Default value is now AlternatePattern.none. Updated all SequenceEffect examples and tests to reflect changes. Made the TiledGame example project more aesthetically interesting. The camera now pans to all 4 corners WRT the bounds of the loaded map and uses the new AlternatePattern feature along with all the new fixes.
feature!:
AlternatePattern
for SequenceEffect
. fix:
bad math in MoveToEffect
.feature!:
AlternatePattern
for SequenceEffect
(and fix wrong math in MoveToEffect
).
feature!:
AlternatePattern
for SequenceEffect
(and fix wrong math in MoveToEffect
).feat!:
AlternatePattern
for SequenceEffect
(and fix wrong math in MoveToEffect
).
…ing so that is fixed.
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.
Good idea, it needs tests and docs though.
EDIT: Ah you already wrote that in the PR description.
@@ -28,7 +28,7 @@ class SequenceEffectExample extends FlameGame { | |||
ScaleEffect.by(Vector2.all(1.5), duration(0.7)), | |||
MoveEffect.to(Vector2(400, 500), duration(0.7)), | |||
], | |||
alternate: true, | |||
alternatePattern: AlternatePattern.excludeLast, |
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.
This should be done additionally to alternate
, so that it's not a breaking change, and also follows the same pattern as the other effects.
@@ -40,7 +40,7 @@ class MoveToEffect extends MoveEffect { | |||
@override | |||
void apply(double progress) { | |||
final dProgress = progress - previousProgress; | |||
target.position += _offset * dProgress; | |||
target.position += _offset * dProgress.abs(); |
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.
Hmm, is this really correct?
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.
After thinking about it some more yesterday I think the issue wasn't the reflected vector itself, but rather that the direction vector was incorrect when the camera has a viewport-aware bounds behavior. This causes it to never reach its destination and so the reflective vector is incorrect. That's why taking the absolute value was ok after I added the step to recalculate the vector.
The camera won't be the only component that may never complete its effect with regards to MoveToEffect
so this matter should be resolved in the PR imo.
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.
But this will potentially overshoot the destination right? And also it won't be matching the time anymore?
If you are at 0.99 progress and the delta progress is -0.02 when the effect is going forward it should have moved 0.03 "steps", since it'll start going back again, but with this it will simply move to 1.01.
enum AlternatePattern { | ||
none(0), | ||
includeLast(1), | ||
excludeLast(2); |
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.
If infinite
(or N runs) is used together with alternate
, shouldn't the first also be excluded on runs that are after the first and not the last?
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.
It already behaved this way. Only the last one was ever being repeated.
feat!:
AlternatePattern
for SequenceEffect
(and fix wrong math in MoveToEffect
).AlternatePattern
for SequenceEffect
(and fix wrong math in MoveToEffect
)
AlternatePattern
for SequenceEffect
(and fix wrong math in MoveToEffect
)AlternatePattern
argument for SequenceEffect
MoveToEffect
so that negative progress did not reflect the direction of the delta offset vec.SequenceEffect
to correctly map to the progress when_index < 0
.onStart()
inrecede()
initial condition so that effects likeMoveToEffect
can recalculate their initial data.DurationEffectController
to avoid potential negative zeros.alternate
boolean forSequenceEffect
with a new typeAlternatePattern
which allows users to include or exclude the last effect in the sequence when the pattern reverses.AlternatePattern.none
.SequenceEffect
examples and tests to reflect changes.AlternatePattern
feature along with all the new fixes.docs
and added dartdoc comments with///
.examples
ordocs
.TO DISCUSS
onEnd()
forEffect
s. Or provideonStart()
with an initialprogress
value to calculate from.Breaking Change?
Migration instructions
alternate=true
for allSequenceEffect
s withalternatePattern=AlternatePattern.includeLast
.AlternatePattern.includeLast
will recreate the exact same behavior asalternate=true
in the previous Flame version.AlternatePattern.excludeLast
forSequenceEffect
s to skip playing the lastEffect
twice in a row when alternating.Related Issues
I looked but didn't immediately see anyone reporting these issues. I discovered them myself.