0
當我試圖執行下面的代碼它給我這個錯誤:Lua的碰撞零值
Attempt to index field 'other' (a nil value)
,但我不知道爲什麼。
代碼:
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'爲零的消息。 – lhf
什麼lhf說。這意味着傳遞給'onCollision'的值是一個表(或者像一個),但它沒有名爲'other'的字段。也許該字段實際上被命名爲「其他」。或許'onCollision'還沒有通過你認爲它的對象。 – RBerteig