I have been working really hard over the past couple of months on my current project and had hit a wall a couple of weeks back and I was really stuck but thanks to the corona community I worked out and solved the problem and have continued coding. But I have just hit another wall as i have started testing the game. I now have the following error occurring when i try to go to my gameover.lua file.
Runtime error
file directory// game.lua:435: ‘for’ limit
must be a number
stack traceback:
file directory// game.lua:435: in function
‘updateBlocks’
file directory//
here is the code that has the error within.
function updateBlocks()
\*\* for 1 = 1, blocks.numChildren, 1 do
if(a \> 1) then
newX = (blocks[a - 1]).x + 79
else
newX = (blocks[8]).x + 79 - speed
end
if((blocks[a]).x \< -40) then
score = score + 2
scoreText.text = " " .. score
scoreText:setReferencePoint(display.CenterLeftReferencePoint)
scoreText.x = 120
scoreText.y = 20
if(inEvent == 11) then
(blocks[a]).x, (blocks[a]).y = newX, 600
else
(blocks[a]).x, (blocks[a]).y = newX, groundLevel
end
--by setting up the spikes this way we are guaranteed to
--only have 3 spikes out at most at a time.
if(inEvent == 12) then
for a=1, spikes.numChildren, 1 do
if(spikes[a].isAlive == true) then
--do nothing
else
spikes[a].isAlive = true
spikes[a].y = groundLevel - 200
spikes[a].x = newX
break
end
end
end
checkEvent()
else
(blocks[a]):translate(speed \* -1, 0)
end
end
end
the line that is stated as having and error within is highlighted with ** at the start (this highlight is not in my project code. I have added this for you)
I cannot change any of the numbers as this will cause the graphics in the game not to work.
I would really love some help with this please.
Thanks
Ryan [import]uid: 111430 topic_id: 27795 reply_id: 327795[/import]