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

Author Topic: Updating to SFML 2.0 made sprite.setTextureRect EXTREMELY buggy.  (Read 2183 times)

0 Members and 1 Guest are viewing this topic.

Plazmotech

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Hello everybody! I'm in the process of making a game. I was using SFML 1.6, and was recently informed to upgrade to SFML 2.0. I did, and fixed everything I had to, hoping that it would fix the texture. But it did not. My texture now looks like this: http://videobam.com/vdtJR

It's horrible. Normally it would looks like the lights were normally blinking. This is my actual texture: http://i.imgur.com/oKl4VBO.png

and this is the code I'm using to set the sub rect
playerSprite.setTextureRect(sf::IntRect(imageLoop % 4 * 32, floor(imageLoop / 4) * 32, imageLoop % 4 * 32 + 32, floor(imageLoop / 4) * 32 + 32));

It was working perfectly before I upgraded from SFML 1.6 to 2.0. Please help! This is really annoying.


Also, it made the sprite extremely off center. Normally, these bullets are centered: http://i.imgur.com/jYDaOqY.jpg
« Last Edit: January 26, 2013, 12:36:06 am by Plazmotech »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10918
    • View Profile
    • development blog
    • Email
Re: Updating to SFML 2.0 made sprite.setTextureRect EXTREMELY buggy.
« Reply #1 on: January 26, 2013, 12:39:35 am »
Note the API change of sf::Rect:

Rect (T rectLeft, T rectTop, T rectWidth, T rectHeight)

It's no-longer Left, Top, Right, Bottom, but Left, Top, Width, Height. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Plazmotech

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Re: Updating to SFML 2.0 made sprite.setTextureRect EXTREMELY buggy.
« Reply #2 on: January 26, 2013, 12:48:51 am »
Note the API change of sf::Rect:

Rect (T rectLeft, T rectTop, T rectWidth, T rectHeight)

It's no-longer Left, Top, Right, Bottom, but Left, Top, Width, Height. ;)

Thanks! But that still doesn't fix the issue that the bullets are extremely off centre. I did some logging, and their X is indeed in the same place. It was on centre in 1.6.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10918
    • View Profile
    • development blog
    • Email
AW: Updating to SFML 2.0 made sprite.setTextureRect EXTREMELY buggy.
« Reply #3 on: January 26, 2013, 12:50:39 am »
Have you set their origin correctly?

You should provide some code (at best a complete and minimal example). ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything