我遇到了这个问题,它使我的游戏延迟了一个里程碑,在场景 1 中,我单击将我带到菜单的菜单按钮,然后当用户想要再次播放时,他们单击播放按钮,但是他们应该转到上一个场景当它进入黑屏时。这是一些代码,这是场景 1 中的主菜单按钮:
function scene:enterScene(event)
local group = self.view
function menubutton:touch( event )
if event.phase == "began" then
storyboard.gotoScene( "menu", "slideRight", 750 )
audio.play(click)
display.getCurrentStage():setFocus( event.target )
event.target.isFocus = true
elseif event.target.isFocus then
if event.phase == "moved" then
print( "user has moved their finger off the button." )
elseif event.phase == "ended" then
print( "user has switched to the main menu" )
display.getCurrentStage():setFocus( nil )
event.target.isFocus = false
end
end
return true
结尾
这是主菜单上的播放按钮:
function scene:enterScene(event)
local group = self.view
local function onSceneTouch( event )
if event.phase == "ended" then
audio.play(click)
local previousScene = storyboard.getPrevious()
if previousScene == nil then
storyboard.gotoScene( "scene1", "slideLeft", 750 ) else
storyboard.gotoScene(previousScene)
return true
end
end
end
有任何想法吗?我在模拟器输出中没有收到任何错误。
编辑:当我将这行代码放在菜单上时,这行代码停止了空白屏幕,但只显示图像,背景图像按钮图像等,但没有别的。
local prior_scene = storyboard.getPrevious()
storyboard.purgeScene( prior_scene )