【发布时间】:2013-12-16 21:00:07
【问题描述】:
我正在开发一款游戏,但我有几个小时以来的问题,我真的不知道如何解决它!
我像往常一样开始我的游戏,使用一个新的故事板,一开始它运行良好,但是,当我尝试实现我的类 Game 来控制所有游戏玩法时,我收到一个错误:
bg_menulvl.lua:
function scene:createScene( event )
local group = self.view
local background = display.newImageRect( "images/backgrounds/bg_menulvl.jpg", display.contentWidth, display.contentHeight )
background.x, background.y = display.contentCenterX, display.contentCenterY
btn_back = widget.newButton
{
defaultFile = "images/boutons/b_back.png",
width = 200, height = 200, left = 150, top = 80,
onRelease = onbtn_back
}
local function onbtn_back()
local Game
Game = game.new("images/backgrounds/bg_rio.jpg")
Game:startGame()
storyboard.removeScene( "bg_menulvl" )
end
game.lua
local function onbtn_map()
storyboard.gotoScene( "bg_menulvl", "fade", 500 )
end
local function onbtn_score()
storyboard.gotoScene( "bg_score", "fade", 500 )
end
function game.new(levelN)
function initGame()
local background = display.newImageRect( levelN, display.contentWidth, display.contentHeight )
background.x, background.y = display.contentCenterX, display.contentCenterY
btn_pause = widget.newButton
{
defaultFile = "images/boutons/b_pause.png",
width = 150, height = 150, left = 1700, top = 40,
onRelease = onbtn_map
}
end
所以,为了理解这一点,我在 bg_menulvl.lua 中开始游戏,当我点击时,我创建了一个新游戏来实现我的逻辑,但是当我开始游戏之后,我尝试点击 onbtn_map,go create一个新的故事板,并提升我的游戏实例...
但我总是得到这个错误:尝试索引字段'contentBound'(一个零值) (在 goToScene 函数中)
如果有人可以帮助我...谢谢!
【问题讨论】:
标签: lua coronasdk corona-storyboard