I am having a ball that I move around the screen with the accelerometer, that works fine.
Now I am adding a new object and if the ball collide with the wall I want the ball to disappear but it doesnt´t work.If I add a touchevent to the wall the ball disapears.
Here is my code:
local wall = display.newImage( "wall.png" )
wall.x = 506
wall.y = 974
physics.addBody( wall, "static", { density=1, friction=1, bounce=0 } )
local ball= display.newImage ("redball.png")
ball.x = 670
ball.y = 915
physics.addBody(ball, "static" ,{ density = 1.0, friction = 0.7, bounce = 0.8})
function removeball(event)
ball:removeSelf()
end
wall:addEventListener("collision", removeball)
Maholm
[import]uid: 5717 topic_id: 5295 reply_id: 305295[/import]