SFML community forums

Help => Graphics => Topic started by: Eulavvalue on November 07, 2013, 10:45:17 am

Title: [Solved] Getting 8 points from sprite
Post by: Eulavvalue on November 07, 2013, 10:45:17 am
I'm using Tiled Tile Map Loader (http://trederia.blogspot.co.uk/2013/05/tiled-map-loader-for-sfml.html) and am attempting to use the MapLoader's Collision(point) function to check for any collisions against tiles with my player sprite. I've got it to work using a test sf::RectangleShape where I can simply getPoint(0), getPoint(1), etc. So I'm thinking I should be able to get the bounding box of my sprite and make a RectangleShape with it, and use that to check for collision. I'm drawing a blank on how to get the bounding box from my sprite and creating a sf::Vector2f with it, though, if anyone can help or point me in the right direction. I've read  the creator's collision article on his website and for whatever reason it's not clicking (possibly because I'm tired), so figured I would throw up a post before I sleep.
Title: Re: Getting 8 points from sprite
Post by: eXpl0it3r on November 07, 2013, 10:49:44 am
Reading the documentation of SFML would most likely enlight you with: sprite.getGlobalBounds() :)
Title: Re: Getting 8 points from sprite
Post by: Eulavvalue on November 08, 2013, 01:57:40 am
Thanks, pointed me in the right direction. Ended up creating a sf::RectangleShape boundingBox in my player class and updating it every tick to check for collision. If collision happens then I revert any movements. Will probably have to update it once I apply gravity to the game and such. 

Edit: Turns out there is also a GetAABB() method included so I can just check for intersections rather than check for points :P.