I have a little problem and I’m searching for an easy solution,
in my game, if a bullet touches a specific ennemy, this target should be deleted and respawn otherwhere,
I’m using the self-collision event to make the instructions single to each ennemy,
the problem is that self-collision function only works if he recognise the target, but as I delete it the first time in my collision function, that ennemy doesn’t exist anymore for my function. It works only the first time.
I hope that my problem is understandable,
here is an example of the code:
local ennemy ennemy = display.newRect(0,0, 20, 50) transition.to( ennemy, {time = 2000, x = 240, y = 160} ) local function onCollision(self,event) display.remove( bullet ) display.remove( ennemy ) ennemy = display.newRect(0,0, 20, 50) transition.to( ennemy, {time = 2000, x = 240, y = 160} ) end ennemy.collision = onCollision ennemy:addEventListener( "collision", ennemy )