I,
I try to perform a transition between the loadmainmenu.lua and mainmenu.lua files.
I do not understand why the transition (“fade effect”) is not functioning the first time it is executed but only after mainmenu.lua has called loadmainmenu back.
the transition functions (inside enterScene) are the followings:
loadmainmenu:
function scene:enterScene(event) local screenGroup = self.view print ("\n loadmainmenu: enterScene event") loadingImage = display.newImageRect ( "loading.png", 480, 320) loadingImage.x = 240; loadingImage.y = 160 screenGroup:insert(loadingImage) local goToMenu = function() storyboard.gotoScene ("mainmenu", "fade", 500) end myTimer = timer.performWithDelay (5000, goToMenu, 1) end
Inside mainmenu.lua I have
function scene:enterScene(event) local screenGroup = self.view print ("\n mainmenu: enterScene event") local backgroundImage = display.newImageRect ("mainMenuBG.png", 480, 320) backgroundImage.x = 240; backgroundImage.y = 160 screenGroup:insert (backgroundImage) local playBtn local onPlayTouch = function (event) if event.phase == "release" then --audio.play (btnSound) storyboard.gotoScene ("loadmainmenu", "fade", 300) end end playBtn = ui.newButton { defaultSrc = "playbtn.png", defaultX = 100, defaultY = 100, overSrc = "playbtn-over.png", overX = 100, overY = 100, onEvent = onPlayTouch, id = "PlayButton", text = "", font = "Helvetica", textColor = { 255, 255, 255, 255 }, size = 16, emboss = false } playBtn.x = 240; playBtn.y = 400 screenGroup:insert(playBtn) btnAnim = transition.to (playBtn, { time=500, y=260, transition=easing.inOutExpo }) end