Jump to content

Detect collision on a sprite side


Arlefreak
 Share

Recommended Posts

is there a way to handle collisions of an object depending on the side colliding? for example top, bottom, left, , right so for example I have a character and I want it to do something when it collides on the left side of a sprite, but when it is on top, just continue.

 

PD: i think the chat is down, I don't know if it is known.

 

Link to comment
Share on other sites

Assuming your player is just moving towards the top. I would probably put some logic in a collisionHandler function.

To check if the playerObject(obj1) is below (y-axis) the collisionObject(obj2) at the moment the collision occurs.
If is not below , then that means the collision occurred from the side.

Another way i was thinking of doing this, is by having a sprite vs group collision check.  What you want to do is add all the sprites that are below the playerObject to this group.  This way you don't worry about the sprites that are not in the group.

Link to comment
Share on other sites

Thanks for the response!  I wanted to know if it was some way implemented but it doesn't seem so hard to do it myself, also i was thinking about a sprite 1px width and add it to my object so the collision would only be with it.

I will try it and see how does it goes. 

 

Assuming your player is just moving towards the top. I would probably put some logic in a collisionHandler function.

 

 

PD: the link for the collision handler seems to be broken 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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