My object is not removing...

function drop()
drpimg = display.newImage (“drop.png”)
drpimg.x= math.random(10,1000)
drpimg.y=-10
drpimg.myName = “Drop”
physics.addBody( drpimg, { density=0.9, friction=0.3} )

function drpimg:collision (event)
if event.other.myName == “Ground” then
print “Drop hit the Ground!”
if drpimg.remove then
drpimg:removeSelf()
end
end
end
drpimg:addEventListener(“collision”, drpimg)
end

local drop1= timer.performWithDelay( 1500, drop, -1 )

—>> this is not being executed.can anybody help me? [import]uid: 82446 topic_id: 15496 reply_id: 315496[/import]

what is the -1 that you are passing to the timer.performWithDelay function??

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 15496 reply_id: 57254[/import]

-1 is for infinite loop… [import]uid: 82446 topic_id: 15496 reply_id: 57256[/import]

Well, if you need to check what is the breakpoint, you have to have an infinite loop.

BTW, the numbers + or - do not matter, but Rahul, for not understand how to test, you are off my list for help.

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 15496 reply_id: 57257[/import]

try removing “if drpimg.remove” condition. also you may consider changing the drpimg to local.so that there will be individual handle for each display item added.

I tried the below code and its working fine.
[lua]local physics = require(“physics”)
physics.start()
physics.setGravity(0,9.8)

local jumpPlatform = display.newRect( 10, 350, 360, 5 )
physics.addBody( jumpPlatform, “static” )
jumpPlatform.myName = “Ground”

function drop()
local drpimg = display.newCircle(150,120,10)
drpimg.x= math.random(10,1000)
drpimg.y=-10
drpimg.myName = “Drop”
physics.addBody( drpimg, { density=0.9, friction=0.3} )

function drpimg:collision (event)
if event.other.myName == “Ground” then
print “Drop hit the Ground!”
drpimg:removeSelf()
end
end

drpimg:addEventListener(“collision”, drpimg)
end

local drop1= timer.performWithDelay( 1500, drop, -1 )[/lua] [import]uid: 71210 topic_id: 15496 reply_id: 57271[/import]

Thanks Buddy for the reply but I dont know how it started running without any modifications. [import]uid: 82446 topic_id: 15496 reply_id: 57559[/import]

Glad to hear you got it sorted, just moved this into a more relevant forum :slight_smile: [import]uid: 84637 topic_id: 15496 reply_id: 57855[/import]