Sign in to follow this  
P4nch0

Detect end of collision

Recommended Posts

Hi,

Has anyone have good ide how to detect end of collision beetwen player and object?

 

Now i am detecting when  position player x - possition objext x is higher than..

 

Maybe someone have better, please write ;)

Share this post


Link to post
Share on other sites

Arcade physics collisions return true if the collision has occurred, and false if it hasn't.  You can use this to determine the first frame where the collision stops happening.  Something like this:

 

var collisionHappenedLastFrame;

if(game.physics.arcade.collide(entity1, entity2)){
   collisionHappenedLastFrame = true;
}else{
   if(collisionHappenedLastFrame){
      collisionHappenedLastFrame = false;

      //here's your code that relies on the collision ending
   }
}

 

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.