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

Author Topic: [Solved] Getting 8 points from sprite  (Read 1266 times)

0 Members and 1 Guest are viewing this topic.

Eulavvalue

  • Newbie
  • *
  • Posts: 9
    • View Profile
[Solved] Getting 8 points from sprite
« 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.
« Last Edit: November 08, 2013, 01:58:05 am by Eulavvalue »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10924
    • View Profile
    • development blog
    • Email
Re: Getting 8 points from sprite
« Reply #1 on: November 07, 2013, 10:49:44 am »
Reading the documentation of SFML would most likely enlight you with: sprite.getGlobalBounds() :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Eulavvalue

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Getting 8 points from sprite
« Reply #2 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.
« Last Edit: November 08, 2013, 07:47:23 am by Eulavvalue »