ok day 4 of corona. at the moment i have an enemy that spawns every 3 seconds and comes in from the left side of the screen moving right. if i try to kill the first one by tapping that dies just fine. if i allow more than 1 to spawn on the screen then tapping the first one no longer kills it and it kills whatever else is on the screen.
im not suprised this is happening based on my code. but i dont know how to make a “life” type variable only apply to individual actors. so i can have multiple targets on the screen and only kill the ones im actually tapping on.
heres my code
[lua]local function enemySender ()
enemy1 = display.newImageRect (“images/final-0001.png”, 32, 32)
enemy1.x = -50
enemy1.y = 250
transition.to (enemy1,{ time=6000, x=300})
local function killenemy()
enemy1:removeSelf ()
end
enemy1.isHitTestable = true
enemy1:addEventListener (“tap”, killenemy)
end
timer.performWithDelay(3000,enemySender,0) [/lua]
also how can i randomise that timer a bit? so lets say in addition to enemy1 theres also enemy2 and enemy3 and every 3 seconds the game randomly selects one of those 3 actors to send out. [import]uid: 80874 topic_id: 14558 reply_id: 314558[/import]
[import]uid: 3826 topic_id: 14558 reply_id: 53920[/import]