我對Corona(Lua)完全陌生。運行遊戲後,遊戲似乎幾秒鐘後,當我碰到下面的錯誤,以很好地工作,直到:「試圖用數字來比較零」嘗試將零與數字進行比較Lua(Corona Lab)中的錯誤
本地函數gameLoop()
-- create new asteroids
createAsteroid()
-- remove asteroids which have been drifted off the screen
for i = #asteroidsTable, 1, -1 do
local thisAsteroid = asteroidsTable [i]
if (thisAsteroid.x < -100 or
thisAsteroid.x > display.contentWidth + 100 or
thisAsteroid.y < -100 or
thisAsteroid.y > display.contentHeight + 100)
then
display.remove(thisAsteroid)
table.remove(asteroidsTable)
end
end
末
正如您在上面所看到的,'thisAsteroid'在'asteroidsTable = {}'中,它被定義爲模塊頂部的變量和任何函數的OUTSIDE。
local asteroidsTable = {}
感謝您的幫助!
嘗試在遇到錯誤的行之前使用'print'語句。 – hjpotter92
可以請你更具體一些,並給出打印聲明的例子? (對不起,我是編碼新手) – EbrahimB