Hello,
I need some help.
I want to spawn new enemys with a timer. This is what i have now:
[lua]local spawn = {}
local n = 1
function newenemy()
local random = math.random(1,800)
spawn[n] = display.newImage(“media/pos.png”)
spawn[n].x= random/2;spawn[n].y= 40;
localGroup:insert(spawn[n]);
spawn[n]:addEventListener(“touch”, delete);
transition.to( spawn[n], { time=2000, y=enemy.y+230, x=_W/2 } )
end
timer.performWithDelay(1000, newenemy)
timer.performWithDelay(1000, newenemy)[/lua]
If i try it it give a error:
[text]
Runtime error
/Users/gzijlstra/Desktop/App/First Project/game.lua:87: attempt to index global ‘enemy’ (a nil value)
stack traceback:
[C]: ?
/Users/gzijlstra/Desktop/App/First Project/game.lua:87: in function
?: in function <?:215>
[/text]
Whats wrong?
This is not all of the code! [import]uid: 120506 topic_id: 22682 reply_id: 322682[/import]