Satheesh, i tried the code that you give me, and it isnt work, something is wrong, if i use my function:
function ball1:collision (event)
event.other:removeSelf()
end
ball1:addEventListener("collision",ball1)
the game run on the simulator, and make what i want, but without any filter, because i only want to remove thing with “star” name
and if i use your function, the game dont run
try it to see plz, it will not run, but if you replace the function by the function above, will run
[code]
module(…, package.seeall)
function new()
local physics = require “physics”
physics.start()
physics.setDrawMode( “hybrid” )
physics.setGravity( 0,0 )
local ball1 = display.newCircle( 80, 120, 20 )
ball1:setFillColor( 0, 255, 0 )
physics.addBody(ball1,“static”)–{ density=2, bounce=0.3, radius=25});
ball1.x = 250; ball1.y = 100
local function touch(event)
if event.phase == “ended” then
physics.setGravity( 0,9.8 )
ball1.bodyType = “dynamic”
end
end
ball1:addEventListener( “touch”, touch )
block1 = display.newRect( 50, 50, 50, 50 )
block1.name = “star”
block1:setFillColor( 255, 255, 255, 100 )
physics.addBody(block1, “kinematic”)-- { density=2, friction=0, bounce=0 })
block1.x = 250 block1.y= 250
function ball1:collision (event)
if event.other.name==“star”
return
end
event.other:removeSelf()
end
end
ball1:addEventListener(“collision”,ball1)
end
[/code] [import]uid: 26056 topic_id: 15886 reply_id: 58783[/import]