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

Author Topic: [SOLVED]Check for sprite collision  (Read 1305 times)

0 Members and 1 Guest are viewing this topic.

Antonio9227

  • Newbie
  • *
  • Posts: 25
    • View Profile
[SOLVED]Check for sprite collision
« on: October 02, 2013, 03:51:29 pm »
Is there any way to check if 2 sprites are collided?
« Last Edit: October 03, 2013, 05:21:31 pm by Antonio9227 »

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Check for sprite collision
« Reply #1 on: October 02, 2013, 04:06:04 pm »
There are tons of ways to do this, but without any more information have a look at this.

if (sprite1.getGlobalBounds().intersects(sprite2.getGlobalBounds()))
{
      //Collision
}
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

Antonio9227

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Check for sprite collision
« Reply #2 on: October 02, 2013, 04:07:30 pm »
Thanks for the fast reply :D

 

anything