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

Author Topic: setOrigin distorts my sprite?  (Read 3962 times)

0 Members and 1 Guest are viewing this topic.

evanbandit

  • Newbie
  • *
  • Posts: 2
    • View Profile
setOrigin distorts my sprite?
« on: December 08, 2021, 12:30:55 am »
I have a 25px x 25px square sprite and I'm trying to set the origin to the center.

m_PlayerSprite.setOrigin(12.5, 12.5);

but! For some reason having an x value of 12.5 distorts my sprite. Any other value and it looks normal. What gives?

Attached: 1.png: normal, 2.png: distorted, player.png: base image.

EDIT: I wasn't sure how to make my attached images appear in the post. Let me know if that would help. Thanks!



« Last Edit: December 08, 2021, 12:33:07 am by evanbandit »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: setOrigin distorts my sprite?
« Reply #1 on: December 08, 2021, 01:01:03 pm »
It's advisable to always render on integer position, otherwise the rasterizer has to decide whether it draws your 0.5 pixel on the left or the right side or drops them completely. As such it's probably the easiest to pick an integer origin or set a position with 0.5 offset
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

evanbandit

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: setOrigin distorts my sprite?
« Reply #2 on: December 08, 2021, 03:21:18 pm »
Thank you very much!