Jump to content

Testing for not colliding


Will
 Share

Recommended Posts

function doesOverLay(unitOne, unitTwo)
{
    var left = unitOne.x;
    var right = unitOne.x + unitOne.width;
    var top = unitOne.y;
    var bottom = unitOne.y + unitOne.height;
   
    if(left > unitTwo.x && right < unitTwo.x + unitTwo.width)
    {
        if(top > unitTwo.y && bottom < unitTwo.y + unitTwo.height)
        {
            return true;
        }else{
            return false;
        }
    }else{
        return false;
    }
   
   
}

 

that will do manually, would ! work with the

 

!game.physics.overlap(Player, coins) I'm not sure if a return value is sent?

Link to comment
Share on other sites

Hi,

I'm not sure if this is what you are looking for, but you can simply set a boolean and change if when the group collide so you'll know when they are not according to its value, like this :

if(game.physics.overlap(Player, coins)){ // or in your game.physics.overlap/collide callback    colliding = true;}

Then when colliding is set to false, they are not overlapping/colliding

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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