【发布时间】:2013-05-04 08:51:05
【问题描述】:
我遇到了这个问题,它使我的游戏延迟了一个里程碑,在场景 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 )
【问题讨论】:
-
有人有想法吗?我找不到其他有同样问题的人。
-
在没有看到场景创建代码的情况下,很难弄清楚为什么会得到一个空白场景。虽然我也很好奇你为什么要调用 previousScene?你现在不知道你需要从你的菜单中去哪个场景吗?您是否打印出 previousScene 的值以确保它是您所期望的?
-
我正在调用上一个场景,因为我希望它将用户带到他们离开的最后一个场景。它是一个单词查找游戏,我正在尝试通过如何进入菜单来实现 4 pics 1 word 的概念,然后当你想再次玩时,你只需点击播放,它就会带你到你所在的最后一个级别.
-
检查我在第一篇文章底部所做的编辑。
-
好吧,完整的代码在电晕实验室的一个线程中,暂时没有人最终回复:forums.coronalabs.com/topic/…
标签: lua storyboard coronasdk