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

Author Topic: Window resize messing with hitboxes  (Read 2380 times)

0 Members and 1 Guest are viewing this topic.

slohobo

  • Newbie
  • *
  • Posts: 5
    • View Profile
Window resize messing with hitboxes
« on: August 14, 2017, 09:47:06 pm »
I am sure it is a line of code that will fix my issue, but whenever I maximize my window, sfml will inherently change how my hitboxes work with the user (in this case the mouse). If I start my program at 1280x720p and my hitboxes revolve around that resolution than it will work fine, but if I increase the size of my program to 1400x1080p then my hitboxes "get smaller". The hitboxes in theory do not get smaller, but as the amount of pixels on the screen increase, the hitbox itself doesn't account for the change. Is there something in sfml that will account for resizes or do I have to do the math around it and figure it out?

I am asking this because whenever I resize the window, sfml accounts for the graphical changes the resize did.

I really hope this makes sense...

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Window resize messing with hitboxes
« Reply #1 on: August 14, 2017, 09:51:49 pm »
Read the official tutorial on views and make sure to understand them. Also make sure you properly translate from screen space to world space with the mapPixelToCoords function.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything