Hi, in my code I have runtime.enterFrame function that moves an object to the left and the return it to the right at x = 560, the problem is when a collision happens to the object, when the object collides with a bullet I want it to go the position of x = 560, but this doesn’t happen, check my code:
[lua]
ene3 = display.newImageRect(group,“enemy3.png”, 47, 44)
ene3.x = 560; ene3.y = math.random(screenTop+10, screenBottom)
ene3.name = “ene”
physics.addBody(ene3,“static”, {radius = 21})
function ene3_collision(e)
if e.other.name == “bullet” then
spawnExplosionToTable(e.target.x,e.target.y)
ene3.x = 560
end
end
ene3:addEventListener(“collision”, ene3_collision)
function ene3:enterFrame()
if ene3.x < screenLeft-10 then
ene3.x = 560
ene3.y = math.random(screenTop+10, screenBottom)
else
ene3.x = ene3.x -5
end
end
Runtime:addEventListener(“enterFrame”, ene3)
[/lua]