SFML community forums

Help => Graphics => Topic started by: arkus on July 28, 2013, 05:31:54 pm

Title: sprite collision
Post by: arkus on July 28, 2013, 05:31:54 pm
Hi!

I'm looking for an easier way to manage the collosion of two sprites. at the moment, i use sprite.getposition().x/y of each sprite and compare the values with a certain tolerance:
(http://i1244.photobucket.com/albums/gg573/mondscheinprimat/collision.jpg)

Is there a function which compares the alpha channel of two sprites and spots a collision of them?
i need it especially for the collsion of round objects.
Title: Re: sprite collision
Post by: The Hatchet on July 28, 2013, 05:49:28 pm
Nope sorry, the only built in collision functions are with IntRect to check for collision or intersection.  For any other shapes you'll need to do your own
Title: Re: sprite collision
Post by: Hiura on July 28, 2013, 06:42:35 pm
IF you know for sure that the two objects are circles, you know that there is a collision is the distance of the two centers is less than, or equal, to the sum of the two radiuses. It will be much faster than doing complex pixel-perfect collision detection.
Title: Re: sprite collision
Post by: arkus on July 28, 2013, 07:02:43 pm
Quote
IF you know for sure that the two objects are circles, you know that there is a collision is the distance of the two centers is less than, or equal, to the sum of the two radiuses. It will be much faster than doing complex pixel-perfect collision detection.

nice hint, i think this will work in most cases. thank you!