Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sprite collision  (Read 2159 times)

0 Members and 1 Guest are viewing this topic.

arkus

  • Newbie
  • *
  • Posts: 12
    • View Profile
sprite collision
« 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:


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.

The Hatchet

  • Full Member
  • ***
  • Posts: 135
    • View Profile
    • Email
Re: sprite collision
« Reply #1 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

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: sprite collision
« Reply #2 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.
SFML / OS X developer

arkus

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: sprite collision
« Reply #3 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!