AristurtleDev / monogame-aseprite

A Cross Platform C# Library That Adds Support For Aseprite Files in MonoGame Projects.
https://monogameaseprite.net
MIT License
166 stars 15 forks source link

Stop method does nothing on a single animation document #20

Closed giusdp closed 1 year ago

giusdp commented 3 years ago

Hello, I'm probably having an uncommon use case in my hands. I have an aseprite document with a single animation of 5 frames that I want it to run just once. I thought about doing this:

animatedSprite.OnAnimationEnd += animatedSprite.Stop;

but the animation loops anyway. I later found out the Pause method, but again it loops anyway with that too.

EDIT: I tried OnAnimationLoop and it worked. I thought that OnAnimationEnd would fire after the last frame, my bad.

manbeardgames commented 3 years ago

So, OnAnimationEnd is supposed to be for when the animation ends, and since a looping animation doesn't end, it's not called.

OnAnimationLoop was the correct call since it's called on the frame the animation loops back to the first frame.

In hindsight I can see how this would be confusing and definitely may need a change or better documentation.

As for one time animations that play and dont loop, check this out. If you end a tag name in Aseprite with [oneshot], then the processor will detect this and only play the animation once. So like if your animation is a door opening and the tag is called open_door, then rename the tag to open_door[oneshot], and it will only play once when called without looping. Note that to play it you still just call .Play("open_door"), the oneshot part is removed from the name.

manbeardgames commented 3 years ago

Just checked and the [oneshot] trick isn't in the documentation page at all, so I def need to update that

giusdp commented 3 years ago

The [oneshot] trick is really neat. I will use that surely! Thanks

AristurtleDev commented 1 year ago

Closing this issue, tracking will now be done in issue #43