我有這個問題,是由scene1中的一個里程碑延遲我的遊戲,我點擊菜單按鈕,帶我到菜單,然後當用戶想再次玩,他們點擊播放按鈕,然後當它進入黑屏時,它們應該轉到上一個場景。這裏是一些代碼,這是在場景1中的主菜單按鈕:Corona去前場景導致黑屏
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)
沒有人有一個想法?我找不到其他人有同樣的問題。 – 2013-05-05 01:18:39
如果沒有看到你的場景創建代碼,你將很難弄清楚爲什麼你會得到一個空白的場景。雖然我也很好奇你爲什麼要調用previousScene?你不知道現在你需要從你的菜單中選擇什麼樣的場景嗎?你打印出previousScene的價值,以確保它是你所期望的嗎? – 2013-05-05 20:12:16
我打電話給前一個場景,因爲我想讓用戶走到他們離開的最後一個場景。它是一個字找到遊戲,我試圖做4個圖片1個字的概念,你如何去菜單,然後當你想再玩一次,你只需點擊玩,它會把你帶到你最後一級。 – 2013-05-06 05:49:04