【发布时间】:2013-10-24 08:08:10
【问题描述】:
当我尝试执行以下代码时,它给了我这个错误:
尝试索引字段“其他”(零值)
但我不知道为什么。
代码:
function onCollision(event)
if event.phase == "began" then
if event.other.star == "star" then
score = score + 1
elseif event.other.mine1 == "mine1" then
if jet.collided == false then
timer.cancel(tmr)
jet.collided = true
jet.bodyType = "static"
explode()
end
end
end
end
提前致谢:)
【问题讨论】:
-
表示
event.other为nil。 -
lhf 所说的。这意味着传递给
onCollision的值是一个表(或类似表),但它没有名为other的字段。也许该字段实际上被命名为Other。也许onCollision没有传递你认为它拥有的对象。
标签: lua physics collision null