Collision problem

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]

should the event listener say oncollision rather than just collision? [import]uid: 10903 topic_id: 5295 reply_id: 17681[/import]

This should do it:

[lua]wall:addEventListener( “collision”, wall ) --this was most likely your problem

onLocalCollision = function( self, event )
if ( event.phase == “began” ) then
event.other:removeSelf() --in case you have more than 1 ball, this will remove the one that collides with the wall.
end[/lua] [import]uid: 10835 topic_id: 5295 reply_id: 17687[/import]