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

Author Topic: Collision detection of a transformed entity  (Read 1234 times)

0 Members and 1 Guest are viewing this topic.

stavsen

  • Newbie
  • *
  • Posts: 5
    • View Profile
Collision detection of a transformed entity
« on: March 01, 2018, 04:39:02 pm »
Hi,
I've been reading the code from the SFML Game Development book
and i have a small question regarding collision detection with the Node system.

If i have an Entity that inherits from SpriteNode, and the Entity has been transformed in some way
does sfml have any built in functions to check whether something is colliding with the sprite of the Entity?

(Usually i would just get the sprits bounds and then use the Rect class functions to check for collisions, but i obviously cant do that with the system showed in the book, as the sprites own transform isn't related to where its being drawn on the screen anymore :\ )

Or would i need something like a physics library for this?

Thanks :)

« Last Edit: March 01, 2018, 05:11:35 pm by stavsen »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Collision detection of a transformed entity
« Reply #1 on: March 03, 2018, 11:02:39 am »
If you want to do simple AABB you just need to apply the whole tree transformation to get the sprites bounding box.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Collision detection of a transformed entity
« Reply #2 on: March 06, 2018, 10:25:18 pm »
If the sprites are rotated, you might want to consider using this: Rectangular Boundary Collision
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything