I use it to stop and resume a scrolling background effect. I’ve found that if I don’t do that, the animation jumps when the application resumes. However I’ve noticed that the transition only resumes every second time the code is called. So if I open the application after suspending it nothing happens. If I do it again it works. Any ideas on how to work around this?
Out of curiosity, can you move the function you’ve wrapped inside this listener up and outside and then call it via a short timer of like 100 milliseconds? This kind of thing may need to triggered after a short timer, but I haven’t tested as such before.
Perhaps you should consider either saving a reference to the transition:
local myTransition = transition.to(…)
Then trying to resume based on passing that reference to transition.resume()… Or consider tagging your transitions and using tags to resume. However, I wonder if this will work on Android at all since Android dumps the textures on suspend and we have to reconstruct them on resume. This may be enough to potentially break the transitions. You might also want to give a little more time to your timer to allow Android to get the display rebuilt.
Thanks Rob, in playing around with tagging I came across the solution that works for the simulator: my original test case was buggy as timer.performWithDelay passes an event object into the transition.resume function which must have confused the matter. A working test case looks like:
[lua]
local c=display.newCircle(display.contentCenterX,display.contentCenterY,20)
function move()
transition.to(c,{x=c.x<display.contentCenterX and display.contentWidth or 0,onComplete=move})
Out of curiosity, can you move the function you’ve wrapped inside this listener up and outside and then call it via a short timer of like 100 milliseconds? This kind of thing may need to triggered after a short timer, but I haven’t tested as such before.
Perhaps you should consider either saving a reference to the transition:
local myTransition = transition.to(…)
Then trying to resume based on passing that reference to transition.resume()… Or consider tagging your transitions and using tags to resume. However, I wonder if this will work on Android at all since Android dumps the textures on suspend and we have to reconstruct them on resume. This may be enough to potentially break the transitions. You might also want to give a little more time to your timer to allow Android to get the display rebuilt.
Thanks Rob, in playing around with tagging I came across the solution that works for the simulator: my original test case was buggy as timer.performWithDelay passes an event object into the transition.resume function which must have confused the matter. A working test case looks like:
[lua]
local c=display.newCircle(display.contentCenterX,display.contentCenterY,20)
function move()
transition.to(c,{x=c.x<display.contentCenterX and display.contentWidth or 0,onComplete=move})