1
我在電暈模擬器中得到以下錯誤。我知道的文件中沒有任何變化。 (我已經包含了main.lua代碼和menuMain.lua代碼。)如果您對可能造成這種情況的任何想法都會有所瞭解! =)謝謝。電暈故事板調度事件錯誤
電暈模擬器運行時錯誤 文件: 嘗試調用方法'dispatchEvent'(一個零值) 堆棧回溯: [c]函數'dispatchEvent' ?在功能可按gotoScene ... dwegrecki/main.lua:在主chunck
16 - main.lua
-- Hide Status Bar
display.setStatusBar(display.HiddenStatusBar)
-- require controller module
local storyboard = require "storyboard"
-- load first screen
storyboard.gotoScene("menuMain")
- menuMain.lua
local storyboard = require("storyboard")
local scene = storyboard.newScene()
---------------------------------------------------------------------------------
-- BEGINNING OF IMPLEMENTATION
---------------------------------------------------------------------------------
local mainBg
local titleIcon
local startBtn
local aboutBtn
local onStartBtnTouch = {}
local scene = {}
-- Touch event listener for startBtn
local function onStartBtnTouch(self, event)
if event.phase == "began" then
storyboard.gotoScene("menuLevel", "fade", 400 )
return true
end
end
-- Touch event listener for cerditsBtn
local function onCreditsBtnTouch(self, event)
if event.phase == "began" then
storyboard.gotoScene("zerocredits", "fade", 400 )
return true
end
end
-- Called when the scene's view does not exist:
function scene:createScene(event)
local screenGroup = self.view
mainBg = display.newImage('bg.png')
titleBg = display.newImage('title.png', 0, 100)
playBtn = display.newImage('playBtn.png', 200, 240)
creditsBtn = display.newImage('creditsBtn.png', 200, 290)
titleView = display.newGroup(titleBg, playBtn, creditsBtn)
screenGroup:insert(titleBg, playBtn, creditsBtn)
playBtn.touch = onStartBtnTouch
creditsBtn.touch = onCreditsBtnTouch
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene(event)
print("1: enterScene event")
-- remove previous scene's view
storyboard.purgeScene("LevelMenu")
storyboard.purgeScene("credits")
storyboard.purgeScene("main")
end
-- Called when scene is about to move offscreen:
function scene:exitScene(event)
print("1: exitScene event")
-- remove touch listener for image
mainBg:removeEventListener("touch", mainBg)
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene(event)
print("((destroying scene 1's view))")
end
---------------------------------------------------------------------------------
-- END OF IMPLEMENTATION
---------------------------------------------------------------------------------
scene:addEventListener("createScene", scene)
scene:addEventListener("enterScene", scene)
scene:addEventListener("exitScene", scene)
scene:addEventListener("destroyScene", scene)
---------------------------------------------------------------------------------
return scene
謝謝DevfaR只是讓你知道,隨着我使用credits.lua文件的事實導致問題。我更改了credits.lua文件名,並且我還修復了本地場景= {},並且一切都很順利! – AziDesigns
@AziDesigns ...你爲我節省了很多精力!我還有一個導致問題的credits.lua文件。 lua/corona是新手,所以很可能不會在很長時間內想到這一點。乾杯。 –