hey so im trying to remove both images/objects when they collide, i put this code in, doesn’t work for me though, can anyone help me? Thanks!
[code]
local crate1 = display.newImage( “scroll.png”, 180, 170 )
physics.addBody( crate1, { density = 3.0, friction = 0.3, bounce = 0.1 } )
crate1.myName = “first crate”
localGroup:insert(crate1)
local crate2 = display.newImage( “ground.png”, 160, 400 )
physics.addBody( crate2, “static”, { friction=1.5, bounce=0.1 } )
crate2.myName = “second crate”
localGroup:insert(crate2)
local function onCollision( event )
if ( event.phase == “began” ) then
print( "began: " … event.object1.myName … " & " … event.object2.myName )
elseif ( event.phase == “ended” ) then
lives = lives - 1
livesDisplay.text = lives
if lives == 0 then
director:changeScene(“level1success”)
event.object2:removeSelf()
end
end
Runtime:addEventListener( “collision”, onCollision )
[/code] [import]uid: 10827 topic_id: 10013 reply_id: 310013[/import]
[import]uid: 52491 topic_id: 10013 reply_id: 36567[/import]