Hi all, having some problems getting the scene transitions to work. I’ve never had this problem before and I’ve used the API extensively, which probably means I’m missing something stupid.
I’ve pasted by scene’s code below (sorry there’s more lines than are necessary to illustrate this point).
Would you guys mind taking a look at it and telling me what I’m doing wrong, thanks.
Mark
local storyboard = require( "storyboard" ) local scene = storyboard.newScene() local Music = audio.loadSound( "Ferryboat.mp3" ) local MusicChannel = audio.play( Music, { channel=1, loops=-1, fadein=5000 } ) \_G.Particles = require("lib\_particle\_candy") local bg1 local bg2 local key local page2L local page2R local a1 local a2 local a3 local a4 local a5 local a6 local a7 local a8 local a9 local a10 local a11 local a12 local a13 local a14 local a15 local a16 local a17 local a18 local a17 local a20 ---------------------------------------------------------------------------------- --------------------------------------------------------------------------------- function moveOn (event) storyboard.gotoScene( "scene2", "zoomOutInFadeRotate", 500 ) end function fire (event) if math.random(50) \< 50 then Particles.StartEmitter ("E1", true) end Particles.Update() end function sparkle (event) Particles.StartEmitter("F1") Particles.Update() end function sparkleNew (event) Runtime:addEventListener("enterFrame", sparkle) end function fire1 (event) Runtime:addEventListener("enterFrame", fire) end function stop (event) Particles.DeleteEmitter("F1") end local function remove( event ) bg1 = nil bg2 = nil end local function dropKey( event ) transition.to( key, { y=700, delay = 700, time=400, onComplete=fire1 } ) end local function reveal( event ) Runtime:removeEventListener("enterFrame", fire) transition.to( Particles.GetEmitter("F1"), { x = 800, time=4200, delay=0, onComplete=stop} ) transition.to( a1, { alpha = 1, time=400, delay=300} ) transition.to( a2, { alpha = 1, time=400, delay=500} ) transition.to( a3, { alpha = 1, time=400, delay=700} ) transition.to( a4, { alpha = 1, time=400, delay=900} ) transition.to( a5, { alpha = 1, time=400, delay=1200} ) transition.to( a6, { alpha = 1, time=400, delay=1500} ) transition.to( a7, { alpha = 1, time=400, delay=1800} ) transition.to( a8, { alpha = 1, time=400, delay=2100} ) transition.to( a9, { alpha = 1, time=400, delay=2400} ) transition.to( a10, { alpha = 1, time=400, delay=2700} ) transition.to( a11, { alpha = 1, time=400, delay=3000} ) transition.to( a12, { alpha = 1, time=400, delay=3300} ) transition.to( a13, { alpha = 1, time=400, delay=3600} ) transition.to( a14, { alpha = 1, time=400, delay=3900} ) transition.to( a15, { alpha = 1, time=400, delay=4200} ) transition.to( a16, { alpha = 1, time=400, delay=4500} ) transition.to( a17, { alpha = 1, time=400, delay=4800} ) transition.to( a18, { alpha = 1, time=400, delay=5100} ) transition.to( a19, { alpha = 1, time=400, delay=5400} ) transition.to( a20, { alpha = 1, time=400, delay=5700} ) end local function advance( event ) transition.to( bg1.path, { x1=0, x3=-300, y3=-100, x2=0, x4=-300, y4=100, time=5500, delay=2000 } ) transition.to( bg2.path, { x1=300, y1=100, x2=300, y2=-100, time=5500, delay=2000} ) transition.to( key, { alpha = 0, time=1500, delay=1800} ) transition.to( bg1, { alpha = 0, time=3500, delay=1800, onComplete = sparkleNew} ) transition.to( bg2, { alpha = 0, time=3500, delay=1800} ) transition.to( bg1, { x = -10, time=3500, delay=1800} ) transition.to( bg2, { x = 1034, time=3500, delay=1800, onComplete = remove} ) transition.to( page2L, { alpha = 1, time=900, delay=3400} ) transition.to( page2R, { alpha = 1, time=900, delay=3400} ) transition.to( page2L, { delay=3800, width=512, height=768, time=1900, transition=easing.inCubic } ) transition.to( page2R, { delay=3800, width=512, height=768, time=1900, transition=easing.inCubic } ) transition.to( page2L, { delay=3800, x = 256, time=1900, transition=easing.inCubic} ) transition.to( page2R, { delay=3800, x = 768, time=1900, transition=easing.inCubic, onComplete = reveal} ) end local function advance3( event ) transition.to( page2L.path, { x1=0, x3=-300, y3=-100, x2=0, x4=-300, y4=100, time=5500, delay=0 } ) transition.to( page2R.path, { x1=300, y1=100, x2=300, y2=-100, time=5500, delay=0} ) --transition.to( key, { alpha = 0, time=1500, delay=1800} ) transition.to( page2L, { alpha = 0, time=3500, delay=800} ) transition.to( page2R, { alpha = 0, time=3500, delay=800, onComplete = moveOn} ) transition.to( page2L, { x = -10, time=3500, delay=0} ) transition.to( page2R, { x = 1034, time=3500, delay=0} ) end local function advance2( event ) transition.to( a1, { alpha = 0, time=400, delay=300} ) transition.to( a2, { alpha = 0, time=400, delay=500} ) transition.to( a3, { alpha = 0, time=400, delay=700} ) transition.to( a4, { alpha = 0, time=400, delay=900} ) transition.to( a5, { alpha = 0, time=400, delay=1200} ) transition.to( a6, { alpha = 0, time=400, delay=1500} ) transition.to( a7, { alpha = 0, time=400, delay=1800} ) transition.to( a8, { alpha = 0, time=400, delay=2100} ) transition.to( a9, { alpha = 0, time=400, delay=2400} ) transition.to( a10, { alpha = 0, time=400, delay=2700} ) transition.to( a11, { alpha = 0, time=400, delay=3000} ) transition.to( a12, { alpha = 0, time=400, delay=3300} ) transition.to( a13, { alpha = 0, time=400, delay=3600} ) transition.to( a14, { alpha = 0, time=400, delay=3900} ) transition.to( a15, { alpha = 0, time=400, delay=4200} ) transition.to( a16, { alpha = 0, time=400, delay=4500} ) transition.to( a17, { alpha = 0, time=400, delay=4800} ) transition.to( a18, { alpha = 0, time=400, delay=5100} ) transition.to( a19, { alpha = 0, time=400, delay=5400} ) transition.to( a20, { alpha = 0, time=400, delay=5700, onComplete = advance3} ) end --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view bg1 = display.newImageRect( "p1/p1L.png",512, 768) bg1.x = 256 bg1.y = display.contentCenterY bg1.alpha = 1 bg1:addEventListener( "touch", advance ) bg2 = display.newImageRect( "p1/p1R.png",512, 768 ) bg2.x = 768 bg2.y = display.contentCenterY bg2.alpha = 1 bg2:addEventListener( "touch", advance ) page2L = display.newImageRect( "p2/P2L.png",256, 384 ) page2L.x = 384 page2L.y = display.contentCenterY page2L.alpha = 0 page2L:addEventListener( "touch", advance2 ) page2R = display.newImageRect( "p2/P2R.png",256, 384 ) page2R.x = 640 page2R.y = display.contentCenterY page2R.alpha = 0 page2R:addEventListener( "touch", advance2 ) a1 = display.newImageRect( "assets/01.png",42, 49 ) a1.x = 252 a1.y = 49 a1.alpha = 0 a2 = display.newImageRect( "assets/02.png",38, 49 ) a2.x = 282 a2.y = 50 a2.alpha = 0 a3 = display.newImageRect( "assets/03.png",38, 41 ) a3.x = 309 a3.y = 53 a3.alpha = 0 a4 = display.newImageRect( "assets/04.png",42, 51 ) a4.x = 352 a4.y = 50 a4.alpha = 0 a5 = display.newImageRect( "assets/05.png",29, 48 ) a5.x = 376 a5.y = 50 a5.alpha = 0 a6 = display.newImageRect( "assets/06.png",40, 41 ) a6.x = 400 a6.y = 53 a6.alpha = 0 a7 = display.newImageRect( "assets/07.png",30, 41 ) a7.x = 424 a7.y = 53 a7.alpha = 0 a8 = display.newImageRect( "assets/08.png",40, 50 ) a8.x = 446 a8.y = 58 a8.alpha = 0 a9 = display.newImageRect( "assets/09.png",39, 49 ) a9.x = 474 a9.y = 50 a9.alpha = 0 a10 = display.newImageRect( "assets/10.png",40, 41 ) a10.x = 503 a10.y = 54 a10.alpha = 0 a11 = display.newImageRect( "assets/11.png",39, 40 ) a11.x = 532 a11.y = 54 a11.alpha = 0 a12 = display.newImageRect( "assets/12.png",47, 49 ) a12.x = 573 a12.y = 50 a12.alpha = 0 a13 = display.newImageRect( "assets/13.png",39, 49 ) a13.x = 604 a13.y = 50 a13.alpha = 0 a14 = display.newImageRect( "assets/14.png",39, 40 ) a14.x = 632 a14.y = 54 a14.alpha = 0 a15 = display.newImageRect( "assets/15.png",38, 41 ) a15.x = 660 a15.y = 53 a15.alpha = 0 a16 = display.newImageRect( "assets/16.png",38, 41 ) a16.x = 687 a16.y = 52 a16.alpha = 0 a17 = display.newImageRect( "assets/17.png",29, 48 ) a17.x = 710 a17.y = 50 a17.alpha = 0 a18 = display.newImageRect( "assets/18.png",37, 40 ) a18.x = 732 a18.y = 53 a18.alpha = 0 a19 = display.newImageRect( "assets/19.png",30, 41 ) a19.x = 759 a19.y = 53 a19.alpha = 0 a20 = display.newImageRect( "assets/20.png",38, 41 ) a20.x = 779 a20.y = 54 a20.alpha = 0 key = display.newImageRect( "assets/key.png",95, 163 ) key.x = display.contentCenterX key.y = -100 key.alpha = 1 key:addEventListener( "touch", advance ) --bflash = movieclip.newAnim( { "b1.png","b1.png","b1.png","b1.png","b2.png","b2.png","b2.png","b2.png","b2.png","b2.png","b2.png","b2.png","b3.png","b3.png","b3.png","b3.png"} ) --bflash.x = 319 --bflash.y = 560 --bflash:play() --bflash:play ({loop=1 }) --bflash.stop() --bflash.alpha = 0.4 --bflash.isVisible = false Particles.CreateEmitter ("E1", 512, 700, 0, false, false, true) Particles.CreateParticleType ("ExplosionSmoke", { imagePath = "gfx\_particles/smoke1\_light\_dark.png", imageWidth = 128, imageHeight = 128, directionVariation = 0, velocityVariation = 50, rotationVariation = 360, rotationChange = 30, useEmitterRotation = false, alphaStart = 0.0, fadeInSpeed = 6.25, fadeOutSpeed = -0.5, fadeOutDelay = 350, scaleStart = 0.5, scaleVariation = 0.5, scaleInSpeed = 1.5, emissionShape = 2, emissionRadius = 30, killOutsideScreen = false, lifeTime = 4000, blendMode = "add", } ) Particles.AttachParticleType ("E1", "ExplosionSmoke" , 4, 10,0) Particles.CreateEmitter("F1", 252, 48, 0, false, false, true) --CreateEmitter("name", x,y, rotation, visible, loop, autoDestroy) Particles.CreateParticleType ("FairyDust", { imagePath = "gfx\_particles/colored\_stars.png", imageWidth = 128, imageHeight = 128, velocityStart = 50, velocityVariation = 25, directionVariation = 45, alphaStart = 0, alphaVariation = .25, fadeInSpeed = 3.0, fadeOutSpeed = -.5, fadeOutDelay = 500, scaleStart = 0.01, scaleVariation = 0.25, scaleInSpeed = .5, weight = 0.1, rotationVariation = 360, rotationChange = 40, killOutsideScreen = true, lifeTime = 4000, useEmitterRotation = true, emissionShape = 2, emissionRadius = 15, blendMode = "add", colorStart = {1,1,.58}, } ) Particles.CreateParticleType ("Flash", { imagePath = "gfx\_particles/flare.png", imageWidth = 128, imageHeight = 128, directionVariation = 360, rotationVariation = 360, rotationChange = 30, useEmitterRotation = false, alphaStart = 0.0, fadeInSpeed = 4.0, fadeOutSpeed = -2.0, fadeOutDelay = 250, scaleStart = 4.0, scaleInSpeed = 1.5, scaleOutSpeed = -1.0, scaleOutDelay = 0, killOutsideScreen = false, emissionShape = 2, emissionRadius = 5, blendMode = "add", lifeTime = 3000, colorStart = {.58,1,.58}, } ) Particles.CreateParticleType ("Fireflies", { imagePath = "gfx\_particles/flare.png", imageWidth = 128, imageHeight = 128, velocityStart = 50, velocityVariation = 50, weight = -.1, rotationVariation = 360, rotationChange = 30, useEmitterRotation = true, alphaStart = 0.0, fadeInSpeed = .5, fadeOutSpeed = -.5, fadeOutDelay = 1000, scaleStart = .1, scaleVariation = .3, killOutsideScreen = true, emissionShape = 1, emissionRadius = 400, blendMode = "add", lifeTime = 5000, colorStart = {.58,1,.58}, } ) Particles.CreateParticleType ("Smoke", { imagePath = "gfx\_particles/smoke3.png", imageWidth = 256, imageHeight = 256, velocityStart = 125, velocityVariation = 25, velocityChange = -2, weight = -.1, alphaStart = 0, alphaVariation = 0.0, fadeInSpeed = 1, fadeOutSpeed = -1, fadeOutDelay = 750, scaleStart = .15, scaleVariation = .25, scaleInSpeed = .5, rotationVariation = 360, rotationChange = 20, emissionShape = 2, emissionRadius = 20, killOutsideScreen = false, lifeTime = 3000, blendMode = "screen", colorStart = {.58,1,.58}, } ) -- FEED EMITTERS (EMITTER NAME, PARTICLE TYPE NAME, EMISSION RATE, DURATION, DELAY) Particles.AttachParticleType("F1", "Smoke" , 2, 99999,0) Particles.AttachParticleType("F1", "FairyDust", 65, 99999,0) Particles.AttachParticleType("F1", "Flash" , 12, 99999,0) Particles.AttachParticleType("F1", "Fireflies", 65, 99999,0) -- TRIGGER THE EMITTERS -- SOFT REDIRECTING FIELDS (NAME, MODE, X, Y, STRENGTH, RADIUS, VISIBLE, [fxID]) Particles.CreateFXField("A1", 3, 512,380, 50, 140, false) Particles.GetFXField ("A1").rotation = 70 Particles.CreateFXField("A2", 3, 512,380, 30, 140, false) Particles.GetFXField ("A2").rotation = -70 --AttachParticleType("emitter", "particleName", emissionRate, duration, delay) local group = display.newGroup() group:insert( page2L ) group:insert( page2R ) group:insert( bg1 ) group:insert( bg2 ) group:insert( key ) group:insert( a1 ) group:insert( a2 ) group:insert( a3 ) group:insert( a4 ) group:insert( a5 ) group:insert( a6 ) group:insert( a7 ) group:insert( a8 ) group:insert( a9 ) group:insert( a10 ) group:insert( a11 ) group:insert( a12 ) group:insert( a13 ) group:insert( a14 ) group:insert( a15 ) group:insert( a16 ) group:insert( a17 ) group:insert( a18 ) group:insert( a19 ) group:insert( a20 ) group:insert(Particles.GetEmitter("E1")) group:insert(Particles.GetEmitter("F1")) end -- Called BEFORE scene has moved onscreen: function scene:willEnterScene( event ) local group = self.view ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- -- This event requires build 2012.782 or later. ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- end -- Called AFTER scene has finished moving offscreen: function scene:didExitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- This event requires build 2012.782 or later. ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end -- Called if/when overlay scene is displayed via storyboard.showOverlay() function scene:overlayBegan( event ) local group = self.view local overlay\_name = event.sceneName -- name of the overlay scene ----------------------------------------------------------------------------- -- This event requires build 2012.797 or later. ----------------------------------------------------------------------------- end -- Called if/when overlay scene is hidden/removed via storyboard.hideOverlay() function scene:overlayEnded( event ) local group = self.view local overlay\_name = event.sceneName -- name of the overlay scene ----------------------------------------------------------------------------- -- This event requires build 2012.797 or later. ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "willEnterScene" event is dispatched before scene transition begins scene:addEventListener( "willEnterScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", dropKey ) scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "didExitScene" event is dispatched after scene has finished transitioning out scene:addEventListener( "didExitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) -- "overlayBegan" event is dispatched when an overlay scene is shown scene:addEventListener( "overlayBegan", scene ) -- "overlayEnded" event is dispatched when an overlay scene is hidden/removed scene:addEventListener( "overlayEnded", scene ) --------------------------------------------------------------------------------- return scene