SFML community forums

Help => General => Topic started by: fancode992 on December 15, 2019, 08:11:33 pm

Title: Getting intersection direction/side.
Post by: fancode992 on December 15, 2019, 08:11:33 pm
Greetings,
As the title says, how can I get the side a sprite collides with another one? For example, I have an enumeration called "Direction" which includes north, south, west and east, a function shall return only one.

I am currently checking collision between two sprites via this code:
spritevar.getLocalBounds().intersects(spritevar2)

I am sorry for being so undescriptive. Thank you. :)
Title: Re: Getting intersection direction/side.
Post by: Mortal on December 15, 2019, 10:54:05 pm
you should use sf::Sprite::getGlobalbounds() instead of the local to test for intersects.
you may try manifold for detecting the collision from every directions up/down or left/right, here an excellent tutorial in this topic with examples:

http://trederia.blogspot.com/2016/02/2d-physics-101-pong.html
Title: Re: Getting intersection direction/side.
Post by: fancode992 on December 17, 2019, 05:57:42 pm
you should use sf::Sprite::getGlobalbounds() instead of the local to test for intersects.
you may try manifold for detecting the collision from every directions up/down or left/right, here an excellent tutorial in this topic with examples:

http://trederia.blogspot.com/2016/02/2d-physics-101-pong.html
Hello Mortal, thank you for helping me :).
Title: Re: Getting intersection direction/side.
Post by: Mortal on December 17, 2019, 06:09:36 pm
you most welcome  :)