lua - Corona going to previous scene results in black screen -
i've got problem delaying game milestone, in scene1 click menu button takes me menu when user wants play again click play button , should go previous scene when goes black screen. here code, main menu button in scene 1:
function scene:enterscene(event) local group = self.view function menubutton:touch( event ) if event.phase == "began" storyboard.gotoscene( "menu", "slideright", 750 ) audio.play(click) display.getcurrentstage():setfocus( event.target ) event.target.isfocus = true elseif event.target.isfocus if event.phase == "moved" print( "user has moved finger off button." ) elseif event.phase == "ended" print( "user has switched main menu" ) display.getcurrentstage():setfocus( nil ) event.target.isfocus = false end end return true
end
here play button on main menu:
function scene:enterscene(event) local group = self.view local function onscenetouch( event ) if event.phase == "ended" audio.play(click) local previousscene = storyboard.getprevious() if previousscene == nil storyboard.gotoscene( "scene1", "slideleft", 750 ) else storyboard.gotoscene(previousscene) return true end end end
any ideas? getting no errors in simulator output.
edit: line of code stopped blank screen when placed on menu, images show up, background image button images etc nothing else.
local prior_scene = storyboard.getprevious() storyboard.purgescene( prior_scene )
try use tap listener instead of touch listener. don't see entire code think there problem.
main menu button in scene 1:
function scene:enterscene(event) local group = self.view local function onmenubuttontap( event ) audio.play(click) storyboard.gotoscene( "menu", "slideright", 750 ) return true end end
play button on main menu scene:
function scene:enterscene(event) local group = self.view local function onplaytap( event ) audio.play(click) local previousscene = storyboard.getprevious() if previousscene == nil storyboard.gotoscene( "scene1", "slideleft", 750 ) else storyboard.gotoscene(previousscene) end return true end end
------------------------------------------------------------
new code:
------------------------------------------------------------
change in scene1.lua
function scene:exitscene(event) local group = self.view storyboard.destroyscene( "scene1" ) end
with this
function scene:exitscene(event) local group = self.view end
in menu.lua add this:
function scene:createscene( event ) local group = self.view storyboard.purgescene( "scene1" ) end scene:addeventlistener( "createscene", scene )
Comments
Post a Comment