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

Author Topic: View colissions  (Read 1303 times)

0 Members and 1 Guest are viewing this topic.

catalinnic

  • Newbie
  • *
  • Posts: 19
    • View Profile
View colissions
« on: August 11, 2019, 12:28:20 pm »
I want to reduce the number of draw calls by verifying if the view is colliding with "Some object" sprite. Eg. I have 50 enemies and i want to draw only who are colliding with the camera.and I don't know how.

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: View colissions
« Reply #1 on: August 11, 2019, 04:18:41 pm »
Using sf::view getCenter and getSize, and if the view doesn't rotate, it's easy to compute an sf::FloatRect representing the view. (center ± size / 2, ...)
Then you can use intersects with the globalBounds of your sprites to check if they are colliding with the camera or not.

catalinnic

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: View colissions
« Reply #2 on: August 11, 2019, 05:44:55 pm »
Thanks, a lot