私は全く新しいCorona(Lua)です。nilとnumberを比較しようとしました。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
エンド
「数とnilを比較しよう」:ゲームを実行した後、ゲームが数秒後に、私は次のエラーを取得するときまで、完璧に動作しているようです上記のように、 'thisAsteroid'は 'asteroidsTable = {}'にあります。これは、モジュールの上に変数として定義されており、関数の外に定義されています。あなたの助けのための
ローカルasteroidsTable = {}
ありがとう!
エラーが発生した行の前に 'print'文を使用してみてください。 – hjpotter92
より具体的で、printステートメントの例を挙げてください。 (申し訳ありませんが、私はコーディングに新しいです) – EbrahimB