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

Author Topic: Getting a portion of A sprites bounding box for collision detection  (Read 1415 times)

0 Members and 1 Guest are viewing this topic.

programsfml

  • Newbie
  • *
  • Posts: 3
    • View Profile
Hello. I have two sprites that I want to check for collision on. I was originally calling getGlobalBounds() on both sprites and checking if they intersected. This works fine except for the fact that the player sprites are holding a long weapon, so even if just their weapons are touching when attacking, it counts as collision. I want it so collision only happens when the weapon is hitting the other sprites body. Is there a way to get only a portion of the bounding box for a sprite and then see if it intersects with the other sprite? Thanks!
« Last Edit: May 20, 2018, 02:16:58 am by programsfml »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
You'll have to calculate your own bounding boxes.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything