Skip to content
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

Added custom loop point to FlxAnimation #2621

Merged
merged 1 commit into from
Aug 16, 2022

Conversation

EliteMasterEric
Copy link
Contributor

This simple change adds the ability to set a custom loop point on an FlxAnimation.

This allows you to conveniently perform behaviors such as having a "lead-in" to a looping animation.

For example, if you have a 5-frame animation, and you set loopPoint to 3, the frames you see will be:

1-2-3-4-5~3-4-5~3-4-5~3-4-5~3-4-5

Copy link
Contributor

@EyeDaleHim EyeDaleHim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very convenient. Would love to see this used.

@Geokureli
Copy link
Member

Geokureli commented Aug 15, 2022

I'm confused by the reverse behavior. It seems like a reverse animation similar to the one you describe would be:5,4,3/5,4,3/5,4,3... when I would expect 5,4,3,2,1/3,2,1/3,2,1...

Am I correct? do others agree with my preference?

@Cheemsandfriends
Copy link
Contributor

I'm confused by the reverse behavior. It seems like a reverse animation similar to the one you describe would be:5,4,3/5,4,3/5,4,3... when I would expect 5,4,3,2,1/3,2,1/3,2,1...

Am I correct? do others agree with my preference?

I think loopPoint should be where does the animation start, like if the animation is reversed, the loopPoint should be at the end of the animation or something that would be equivalent
for example, if you had an animation that would have the loopPoint of 0, and you reverse it would equal to the length of the animation and if the loopPoint is 1, then it's the length - 1.

@Geokureli
Copy link
Member

I'm confused by the reverse behavior. It seems like a reverse animation similar to the one you describe would be:5,4,3/5,4,3/5,4,3... when I would expect 5,4,3,2,1/3,2,1/3,2,1...
Am I correct? do others agree with my preference?

for example, if you had an animation that would have the loopPoint of 0, and you reverse it would equal to the length of the animation and if the loopPoint is 1, then it's the length - 1.

That doesn't seem intuitive to me, since the animation's frames aren't decided that way. also if you add frames to an animation it would change the effective loopPoint. I think frame numbers should always refer to the absolute frame number

@Geokureli
Copy link
Member

I'm confused by the reverse behavior. It seems like a reverse animation similar to the one you describe would be:5,4,3/5,4,3/5,4,3... when I would expect 5,4,3,2,1/3,2,1/3,2,1...

Am I correct? do others agree with my preference?

I was mistaken, here. For some reason I forgot reverse was an arg in play() and not add() in terms of playing my example of a looped anim in reverse, 5,4,3/5,4,3... makes the most sense. TBH, no solution is perfect here, since the reverse of 1,2,3,4,5/3,4,5/3,4,5/... is an infinite number of 5,4,3 followed by a final 5,4,3,2,1 which isn't feasible.

@Geokureli Geokureli merged commit b5a91ad into HaxeFlixel:dev Aug 16, 2022
@Geokureli
Copy link
Member

thanks!
Updated the changelog

@EliteMasterEric
Copy link
Contributor Author

Thank you for the merge!

To clarify, this is not an argument of .add you have to set the value on the FlxAnimation after adding it.

I did it that way because I noticed the .add function was starting to get bloated with arguments and didn't want to make it worse.

@Geokureli
Copy link
Member

Geokureli commented Aug 16, 2022

yeah this is too niche of a feature to add to such an already large function

Maybe in 5.0.0 we can change loop, and flipX/Y to be enums. or add a addAdvanced() to prevent breaking games

@EliteMasterEric
Copy link
Contributor Author

Maybe in 5.0.0 we can change loop, and flipX/Y to be enums. or add a addAdvanced() to prevent breaking games

Yeah, in the future an addAdvanced function could take a parameter object to allow for much finer tuning of configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants