Jump to content

Remove object in group after delay?


Qzlmnrk
 Share

Recommended Posts

I already know how to destroy a group object when it collides with something else.  However, I can't seem to find a way to delay the destruction of the object after the collision.  The following code works for instantly destroying the otherThing in the otherThings group that the thing object overlaps:

game.physics.arcade.overlap(thing, otherThings, removeOtherThing, null, this);function removeOtherThing (thing, otherThing) {	otherThing.destroy();}

What I want to do is delay the destruction of the otherThing object by an arbitrary amount.  I can't seem to find a way that works, though, with the methods I've tried so far returning errors.  Help would be appreciated!

Link to comment
Share on other sites

Just off the top of my head (I'm kinda' new to the phaser world), but want to be active in the forums (this forum needs a little more activity)...  what if you set up something like (pseudo code of course)

 

if you create a var to hold the time delay

 

var timer = new timer

 

a var to hold the otherThing that needs destoryed

 

var destoryMe = null;

 

Then in the "removeOtherThing" function you

 

destoryMe = otherThing

timer = gametimer + ARBITRARY AMOUNT

 

Then in the update function you

 

If(timer >= gametimer && destoryMe != null)

{

   destroyMe.destroy();

  destroyMe = null;

 

}

 

Now, like I said, I'm kinda' new to this, so Phaser may have a function that does all of this, but mayber this can give you a place to start.

 

Ross

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...