G’day everyone.
I ran into trouble working on some animations for my game, and can’t seem to figure it out.
I have a group of background images, animated with transition.to() using string tags.
In response to game control events, the appropriate handlers pause or resume background transitions, to stop and start the animation.
The problem appears when transition.resume(“tag”) function was called more than once - in this case, the very next call to transition.pause(“tag”) doesn’t pause the animations. It needs at least the second call to the same function to stop them, and I can’t understand why - it does not seem to be mentioned in any documentation that I can find.
Here’s an excerpt from a test project I’ve created to make sure that this issue is not related to my character’s animations or complex events (full file is available here):
[lua]
function animBackground()
transition.to(background, {x=-700, time=10000, tag=“animBack”})
end
function charRunListener(event)
if event.phase == ‘ended’ then
transition.resume(“animBack”)
end
end
function charStopListener(event)
if event.phase == ‘ended’ then
transition.pause(“animBack”)
end
end
animBackground()
loadControl()
– loadControl displays controls, and binds even listeners like this:
– runButton:addEventListener(“touch”, charRunListener)
– stopButton:addEventListener(“touch”, charStopListener)
[/lua]
So basically if stop and run listeners are called one after another in the right order - everything works. But if run listener is called twice (or more times) - then stop listener doesn’t work from the first call, but needs the second call to stop the animation.
Does anyone have any ideas about this issue?