# Implementing a 2D Collision method that can tell direction of collision (boxes)

Been searching for quite a while now and really struggling to find an easy way, or a good tutorial on how to create a collision detection system which can indicate what side on a box a collision has occurred.

I should specify that I am using SFML2 and their sprites class, this is what I currently use and it just picks up 2 sprites intersecting

//check rectangles for collision without taking into account where the collision is
bool Game::isRectCollision(sf::Sprite &sprite1, sf::Sprite &sprite2){

sf::FloatRect r1=sprite1.getGlobalBounds();
sf::FloatRect r2=sprite2.getGlobalBounds();
return r1.intersects(r2);

}

• I have always passed the object's movement speed as parameters as well. If object1.velocity.x > 0, for example, then object1 is coming from the left and colliding its right. I wonder if there are alternative ways, tho – Mutoh May 10 '15 at 0:19