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

Author Topic: sf::Sprite::FlipX/Y  (Read 5535 times)

0 Members and 2 Guests are viewing this topic.

DarkGlitch

  • Newbie
  • *
  • Posts: 11
    • View Profile
sf::Sprite::FlipX/Y
« on: January 11, 2013, 11:06:29 pm »
Bring this back.

This was the main reason I started using SFML, among other reasons, and now that I'm changing my project over to 2.0 I'm learning about all the things I took for granted in 1.6 that aren't in 2.0

That really made things SIMPLE as SFML is supposed to be and I think that made the Sprite class so freaking sexy.

I know I can just use a negative scale value, but FlipX made it so easy to flip a sprite with just a true or false I could hug Laurent on sight if I lived nearby.

On the other hand, changing IntRect's constructor was genius.

Edit: http://en.sfml-dev.org/forums/index.php?topic=9666.0

I should learn to use the search function. Sorry.
« Last Edit: January 11, 2013, 11:11:33 pm by DarkGlitch »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Sprite::FlipX/Y
« Reply #1 on: January 11, 2013, 11:12:07 pm »
So you actually already know, that the feature request won't be accepted, but you still ask for it? ::)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DarkGlitch

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: sf::Sprite::FlipX/Y
« Reply #2 on: January 11, 2013, 11:38:29 pm »
I can hope. XD

No seriously, I just thought well if you're gonna change IntRect, which I agree with, why change Sprite when, imo it was perfect.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Sprite::FlipX/Y
« Reply #3 on: January 12, 2013, 12:14:12 am »
The change of IntRect and FlipX/Y are not really comparable, since IntRect was changed, because of its more logical use x,y,width,height while not affecting the performance in calculating the 'third' information (instead of x2-x1 = width you now get x1+widht = x2).

FlipX/Y on the other hand was removed to clean-up the API and remove redundant functionalities. Since one can simply set a negative scale factor to flip a sprite and the scale function gets implemented anyway, the FlipX/Y just aren't needed anymore.

Arguing about simplicity of FlipX/Y vs. scale with negative factor isn't very strong, since both ways have the same simplicity to use.

The only argument I see as valid, is that FlipX/Y would be more descriptive than the scale function. But I happily take a cleaner API over a small bit of readability. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: sf::Sprite::FlipX/Y
« Reply #4 on: January 12, 2013, 01:37:53 am »
Quote
That really made things SIMPLE as SFML is supposed to be and I think that made the Sprite class so freaking sexy.

void flipX(sf::Sprite & s )
{
    auto rect= s.getTextureRect() ;

    rect.left += rect.width ;
    rect.width = -rect.width ;

    s.setTextureRect(rect) ;
}

void flipY(sf::Sprite& s)
{
    auto rect = s.getTextureRect() ;

    rect.top += rect.height ;
    rect.height = -rect.height ;

    s.setTextureRect(rect) ;
}

There.  It's all sexy again.

waxx

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: sf::Sprite::FlipX/Y
« Reply #5 on: January 24, 2013, 12:49:46 pm »
Doesn't that screw things up with a) subrects b) origins though?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: sf::Sprite::FlipX/Y
« Reply #6 on: January 24, 2013, 01:05:11 pm »
Doesn't that screw things up with a) subrects b) origins though?
Depends what you understand under 'screw up'.
As you see it simply negates the subrect, thus there shouldn't be a problem. Flipping around an axis will of course change the look of the image, thus if you don't apply transformation on the middle of the sprite, things could potentially look not the way you want them, but that's also the case for the old 'native' FlipX/Y.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: sf::Sprite::FlipX/Y
« Reply #7 on: February 17, 2013, 01:02:53 am »
You can flip a sprite if you give them a negative scale...
sf::Sprite RandomSprite;
RandomSprite.setOrgin(RandomSprite.getGlobalBounds().width/2,RandomSprite.getGlobalBounds().height/2)//So the orgin(aka center) is in the center.
RandomSprite.Scale(-1,-1);//Flips and Backward
RandomSprite.Scale(-1,1);//Backwards
RandomSprite.Scale(1,-1)//Flips
 
Your welcome... Maybe should be said somewhere in docs that you can get away with this.
If you notice I put "....", in my sentences way too much... I'm sorry.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
AW: sf::Sprite::FlipX/Y
« Reply #8 on: February 17, 2013, 08:22:31 am »
I think it was already clear that scaling with a negative value will do the trick, but we were more discussing the API changes.
Btw from a design standpoint, chang in the texture rect is imho the cleaner way to do it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Halsys

  • Jr. Member
  • **
  • Posts: 66
  • Halsys like Hal.sys
    • View Profile
    • Email
Re: sf::Sprite::FlipX/Y
« Reply #9 on: February 17, 2013, 08:48:13 am »
You mean its cleaner because you keep your origin and original scale? Well from that point of view, yeah.
But because I use Box2D in my current project and I have to use the center of each physics piece to draw... and a couple times before I had to "Flip it"... It was perfect/fast enough for me. Its a personal preference. :P
If you notice I put "....", in my sentences way too much... I'm sorry.

 

anything