So I’m making a little game and I have multiple instances of the same object on the screen at one time. I want it so that when you tap on an object it removes itself. But right now if I tap on an instance of that object, instead of removing the one I tap on, it removes the most recent instance of it.
The relevant code:
[lua]
–adds asteroids
function newAsteroid1()
Asteroid1 = display.newImageRect( “Asteroid.png”, 20, 50 )
Asteroid1.y = display.contentHeight
Asteroid1.x = math.random( 0, 320 )
moveAsteroid1()
Asteroid1:addEventListener( “touch”, onTouchA1 )
end
–removes asteroids
function onTouchA1( event )
if event.phase == “began” then
audio.play(explosion, {loops=0} )
display.remove( Asteroid1 )
moveSpeed = moveSpeed - 10
end
end
[/lua]