martinjlowm/AnimationGroup

Bounce once?

Opened this issue · 7 comments

Hey!
I'd like to to create an animation like you had shown on the gif.
Problem is I can't see any way to create this animation.

The current problem is that it is resetting after every animation to default.
What Id like to do is to execute animation 1 at order 1, animation 2 at order 2 and animation 3 meanwhile.

Also I think an Bunce once option could be very useful

cheers!

You should be able to listen to the OnLoop handler when all animations are complete and then call Finish() on the animation group.

Alright, thanks!

Is it inteded that GetLoopState() always returns nil?

You forgot to add "OnLoop" to your default event handlers.
The handler is working fine though.

self.handlers = {
['OnLoad'] = true,
['OnPlay'] = true,
['OnPaused'] = true,
['OnStop'] = true,
['OnFinished'] = true,
['OnLoop'] = true
}

The loop thing is only partly implemented. It is not intended that GetLoopState returns nil, no :) The handler is left out from the table since it does not exist in the game by default. The others are meant for overriding.

Btw what happens if I call finish after the Loop event handler, it will just continue scaling instead of going back to normal state, is that intended?
Also should it fire OnLoop if it reached the peak or if it is back to default?
cheers!

Not sure how it was inteded, but incase you are thinking about it, I switched line 356-366, the two blocks to ensure only on repetation after the finish call.

-- We `bounce' if the boundary orders have no animations
if (not self.playing and shift and
(not self.finishing) and bouncing) then
self.reverse = not self.reverse
self:__Notify(nil, 'Bounce')
end

-- Call AnimationGroup's callback
if type(group_func) == 'function' then
    group_func(self, unpack(args))
end

cheers!