【发布时间】:2014-07-21 05:50:42
【问题描述】:
我在使用 Corona SDK 开发与碰撞检测和故事板库有关的奇怪错误。
这是我的onCollision 听众:
local function onBottomBorderCollision( event )
if (event.other.isBall) then
local index = table.indexOf( ballArray, other )
table.remove( ballArray, index )
event.other:removeSelf( )
event.other = nil
updateLife(false)
updateScore(false)
end
end
这在第一次启动时运行良好,但在返回菜单屏幕后(使用storyboard.goToScene("menu")) 并重新玩游戏,现在这个监听器将在我的一个球击中底部边框时触发以下错误:
尝试索引字段“其他”(零值)
我确实在scene:onEnterScene(scene) 中创建了适当的侦听器,所以这与它们无关,而且这个其他侦听器永远不会产生错误:
local function onPlayerCollision( event )
if(event.other.isBall) then
xVel, yVel = event.other:getLinearVelocity( )
event.other:setLinearVelocity( event.other.XLinearVelocity, yVel )
end
end
我现在卡住了...请帮助!
【问题讨论】:
标签: lua coronasdk collision-detection null corona-storyboard