monogame-aseprite icon indicating copy to clipboard operation
monogame-aseprite copied to clipboard

Stop method does nothing on a single animation document

Open giusdp opened this issue 4 years ago • 3 comments

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.

giusdp avatar Jan 13 '21 18:01 giusdp

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 avatar Jan 13 '21 21:01 manbeardgames

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

manbeardgames avatar Jan 13 '21 21:01 manbeardgames

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

giusdp avatar Jan 14 '21 11:01 giusdp

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

AristurtleDev avatar Feb 21 '23 21:02 AristurtleDev