Custom Transitions and Performance Issues

So I was looking into creating a custom scene transition between two scenes. Something similar to the cloud transition in both angry birds 2 and boom beach. However as composer is transitioning between the two scenes it causes my animation to hiccup. I was wondering if there was any way to prevent this hiccup or performance dip for my animation. This is the code that controls my animation, its basically two sets of clouds that move together at the center of the screen then move back offscreen, and while they are together the new scene loads. 

local function changeScene(destination) local function preventTouch( ) return true end local touchBlock = display.newRect(centerX, centerY, \_rW, \_rH) touchBlock.alpha = .01 touchBlock:addEventListener( "tap", preventTouch ) touchBlock:addEventListener( "touch", preventTouch ) local function listener( ) composer.gotoScene( destination ) end local topBg = display.newImageRect( "images/menu\_scenechange.png", \_rW, \_rH ) topBg.x, topBg.y = centerX, \_y0 - \_rH\*.5 topBg.xScale, topBg.yScale = -1,-1 local botBg = display.newImageRect( "images/menu\_scenechange.png", \_rW, \_rH ) botBg.x, botBg.y = centerX, \_rH + \_rH\*.5 local function deleteAll() display.remove(touchBlock) touchBlock = nil display.remove(topBg) topBg = nil display.remove(botBg) botBg = nil end changeTransitions[#changeTransitions + 1] = transition.to( topBg, { time=transitionTime\*.5, y=centerY } ) changeTransitions[#changeTransitions + 1] = transition.to( botBg, { time=transitionTime\*.5, y=centerY, onComplete=listener } ) changeTransitions[#changeTransitions + 1] = transition.to( topBg, { delay=transitionTime\*.55, time=transitionTime\*.5, y=\_y0 - \_rH\*.5} ) changeTransitions[#changeTransitions + 1] = transition.to( botBg, { delay=transitionTime\*.55, time=transitionTime\*.5, y=\_rH + \_rH\*.5, onComplete=deleteAll} ) end

Corona is single-threaded so you will need to cover with clouds, then load new scene.  Only when new scene is completely ready then remove clouds to make it completely smooth.

The composer display groups are all contained within a parent display group, so you can put the transition clouds on top of everything, load the new scene, then move the clouds apart.

Hmm this is what has been bothering me. I changed it so that the transition back only happens once the scene has been loaded, but the time it takes for the clouds to move apart changes. It isn’t even consistent between scenes. I separated the transition into two parts. One to have the clouds move on screen, then another separate one that takes part in the “show/did” part of the composer. 

local changeTransitions = {} local topBg local botBg local touchBlock local function changeScene(destination) local function preventTouch( ) return true end touchBlock = display.newRect(centerX, centerY, \_rW, \_rH) touchBlock.alpha = .01 touchBlock:addEventListener( "tap", preventTouch ) touchBlock:addEventListener( "touch", preventTouch ) local function listener( ) composer.gotoScene( destination ) end topBg = display.newImageRect( "images/menu\_scenechange.png", \_rW, \_rH ) topBg.x, topBg.y = centerX, \_y0 - \_rH\*.5 topBg.xScale, topBg.yScale = -1,-1 botBg = display.newImageRect( "images/menu\_scenechange.png", \_rW, \_rH ) botBg.x, botBg.y = centerX, \_rH + \_rH\*.5 changeTransitions[#changeTransitions + 1] = transition.to( topBg, { time=transitionTime\*.5, y=centerY } ) changeTransitions[#changeTransitions + 1] = transition.to( botBg, { time=transitionTime\*.5, y=centerY, onComplete=listener } ) end local function changeComplete(event) local function deleteAll() display.remove(touchBlock) touchBlock = nil display.remove(topBg) topBg = nil display.remove(botBg) botBg = nil end changeTransitions[#changeTransitions + 1] = transition.to( topBg, { time=transitionTime\*.5, y=\_y0 - \_rH\*.5} ) changeTransitions[#changeTransitions + 1] = transition.to( botBg, { time=transitionTime\*.5, y=\_rH + \_rH\*.5, onComplete=deleteAll} ) end

http://gph.is/2sNbae1

perhaps transitionTime is being changed somehow?

also adding a sine easing will make it look more appealing 

So I added an easing to the transition and this appears to solve the problem corona being “jittery” don’t know why but it does.

Corona is single-threaded so you will need to cover with clouds, then load new scene.  Only when new scene is completely ready then remove clouds to make it completely smooth.

The composer display groups are all contained within a parent display group, so you can put the transition clouds on top of everything, load the new scene, then move the clouds apart.

Hmm this is what has been bothering me. I changed it so that the transition back only happens once the scene has been loaded, but the time it takes for the clouds to move apart changes. It isn’t even consistent between scenes. I separated the transition into two parts. One to have the clouds move on screen, then another separate one that takes part in the “show/did” part of the composer. 

local changeTransitions = {} local topBg local botBg local touchBlock local function changeScene(destination) local function preventTouch( ) return true end touchBlock = display.newRect(centerX, centerY, \_rW, \_rH) touchBlock.alpha = .01 touchBlock:addEventListener( "tap", preventTouch ) touchBlock:addEventListener( "touch", preventTouch ) local function listener( ) composer.gotoScene( destination ) end topBg = display.newImageRect( "images/menu\_scenechange.png", \_rW, \_rH ) topBg.x, topBg.y = centerX, \_y0 - \_rH\*.5 topBg.xScale, topBg.yScale = -1,-1 botBg = display.newImageRect( "images/menu\_scenechange.png", \_rW, \_rH ) botBg.x, botBg.y = centerX, \_rH + \_rH\*.5 changeTransitions[#changeTransitions + 1] = transition.to( topBg, { time=transitionTime\*.5, y=centerY } ) changeTransitions[#changeTransitions + 1] = transition.to( botBg, { time=transitionTime\*.5, y=centerY, onComplete=listener } ) end local function changeComplete(event) local function deleteAll() display.remove(touchBlock) touchBlock = nil display.remove(topBg) topBg = nil display.remove(botBg) botBg = nil end changeTransitions[#changeTransitions + 1] = transition.to( topBg, { time=transitionTime\*.5, y=\_y0 - \_rH\*.5} ) changeTransitions[#changeTransitions + 1] = transition.to( botBg, { time=transitionTime\*.5, y=\_rH + \_rH\*.5, onComplete=deleteAll} ) end

http://gph.is/2sNbae1

perhaps transitionTime is being changed somehow?

also adding a sine easing will make it look more appealing 

So I added an easing to the transition and this appears to solve the problem corona being “jittery” don’t know why but it does.