Hello,
I am having a problem with trying to delete a thing that i spawn,
This is the code:
[lua]function newenemy()
local random = math.random(1,800)
if(pausenum==0) then
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);
amount[n] = transition.to( spawn[n], { time=levelamount, y=player.y, x=_W/2,})
n=n+1;
if(spawn[n-1].y>=250) then
print(“DELTEING”)
spawn[n-1]:removeSelf()
spawn[n-1] = nil
end
end
if(pausenum==0) then
pausethings[n] = timer.performWithDelay(1000, newenemy)
else
print(“paused”)
end
end
timer1 = timer.performWithDelay(1000, newenemy)[/lua]
The items all spawn but as you can see removing them does not work.
I tried using OnComplete but if i click one one, it gets removed but the next one that spawns stop moving.
Whats wrong?
Gjosse [import]uid: 120506 topic_id: 23731 reply_id: 323731[/import]
[import]uid: 52491 topic_id: 23731 reply_id: 95660[/import]