Hi all
I am practicing tables and iterations and was wondering the following:
How can I access each spawned instance of the ninja object, and specifically delete from game and the table, without the transition.to method?
How do you use an eventListener where each ninja instance is passed through the “self” parameter?
I hope my questions make sense to someone, I don’t know how to explain it better.
Thanks in advance!
K.
function kill(self) display.remove(self) end local ninjas = {} local idx = 0 for i = 1, 4 do idx = idx + 1 local ninja = display.newImageRect( "Idle.png", 45,70 ) ninja.x = 100 ninja.y = math.random(display.actualContentHeight) ninjas[idx] = ninja ninjas[idx].idx = idx -- if ninja.y \> 700 then -- kill() -- end transition.to(ninja, {delay = math.random(5000,9000), time = 3000, x= display.actualContentWidth-200, onComplete= kill})
