A problem with transition.pause() and transition.resume()

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? 

I believe you are correct and this warrants a bug submission. I created this test code, which clearly shows a tagged transition being resumed, without any previous operations, and failing to pause on the first request - though the second does succeed.

local r = display.newRect( 300, 300, 300, 300 ) transition.to( r, { time=30000, rotation=3000, tag="r" } ) timer.performWithDelay( 2000, function() print("resume") transition.resume( "r" ) end ) timer.performWithDelay( 3000, function() print("resume") transition.resume( "r" ) end ) timer.performWithDelay( 4000, function() print("resume") transition.resume( "r" ) end ) timer.performWithDelay( 7000, function() print("pause") transition.pause( "r" ) end ) timer.performWithDelay( 9000, function() print("pause") transition.pause( "r" ) end )

To file a bug report we need a simple test case (not your entire project). It needs a main.lua, config.lua and build.settings and any assets needed for our engineers to build and run the test case. Put that in a .zip file and use the Report a bug Link at the top of the page.

When filling out the description of the bug, please include the URL to this forum thread in the text. You will get an email on successful submission. That email will contain a CaseID # in the subject. Please post that CaseID # back here.

Thanks

Rob

Bug report is filed. Case 46052

I believe you are correct and this warrants a bug submission. I created this test code, which clearly shows a tagged transition being resumed, without any previous operations, and failing to pause on the first request - though the second does succeed.

local r = display.newRect( 300, 300, 300, 300 ) transition.to( r, { time=30000, rotation=3000, tag="r" } ) timer.performWithDelay( 2000, function() print("resume") transition.resume( "r" ) end ) timer.performWithDelay( 3000, function() print("resume") transition.resume( "r" ) end ) timer.performWithDelay( 4000, function() print("resume") transition.resume( "r" ) end ) timer.performWithDelay( 7000, function() print("pause") transition.pause( "r" ) end ) timer.performWithDelay( 9000, function() print("pause") transition.pause( "r" ) end )

To file a bug report we need a simple test case (not your entire project). It needs a main.lua, config.lua and build.settings and any assets needed for our engineers to build and run the test case. Put that in a .zip file and use the Report a bug Link at the top of the page.

When filling out the description of the bug, please include the URL to this forum thread in the text. You will get an email on successful submission. That email will contain a CaseID # in the subject. Please post that CaseID # back here.

Thanks

Rob

Bug report is filed. Case 46052