How to destroy/ remove object after n time?

Hi,

 I want to remove objects after n seconds so how to remove it in 3 seconds. I have tried this but it says starter a nil value.( Starter is the name of scene). I only changed name of scene in this code from Game.

local function destroyObj(obj)

display.remove(obj)

obj=nil

end

test = display.newRect(1120, -50,20,20)

physics.addBody(test, “dynamic”, {density = 1.0, friction = 10, bounce = .5})

starter:insert(test)

test.collision = function(self, event)

                        if ( event.phase == “began” ) then

                            timer.performWithDelay(5000, function()

                                destroyObj(self)

                            end, 1)

                        end

                    end

            

                test:addEventListener( “collision”, test )

end

I also tried

local function remove()

“here I display object”

display.remove( object )

timer.performWithDelay( 3000, remove, 0)

but it also not working!

what is starter ?

starter:insert indicates that starter is a group in which you are inserting ‘test’ object

You probably meant to do:

scene.view:insert(test)

instead of:

starter:insert(test)

Rob

what is starter ?

starter:insert indicates that starter is a group in which you are inserting ‘test’ object

You probably meant to do:

scene.view:insert(test)

instead of:

starter:insert(test)

Rob