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

Author Topic: Checking if a sprite flipped?  (Read 3101 times)

0 Members and 1 Guest are viewing this topic.

Noctune9

  • Newbie
  • *
  • Posts: 1
    • View Profile
Checking if a sprite flipped?
« on: October 01, 2009, 09:29:04 pm »
I'm inheriting from a sprite in order to create my lighting system. Unfortunately, there doesn't seem to be any function which tells me if a sprite is flipped, making it impossible for me to implement the Render function properly. :(

I could implement it myself easily, but I think it would be better if it became fixed in SFML.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Checking if a sprite flipped?
« Reply #1 on: October 01, 2009, 09:54:22 pm »
Quote
I could implement it myself easily

You should do so, because I don't think that this feature will be implemented soon.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Checking if a sprite flipped?
« Reply #2 on: October 02, 2009, 02:59:24 pm »
Quote from: "Noctune9"
I could implement it myself easily, but I think it would be better if it became fixed in SFML.
How? By overriding the FlipX() and FlipY() methods? That can be dangerous since those are not virtual functions.

Laurent, what is the reason not to provide IsFlippedX() and IsFlippedY() member functions? The sf::Sprite class already owns two corresponding bool variables. I don't think duplicating the information makes much sense.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Checking if a sprite flipped?
« Reply #3 on: October 02, 2009, 03:10:22 pm »
Quote
How?

Store your own booleans, that you update when you call FlipX/FlipY.
Or modify SFML to add the accessors inside sf::Sprite.
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Checking if a sprite flipped?
« Reply #4 on: October 02, 2009, 08:00:55 pm »
Quote from: "Laurent"
Store your own booleans, that you update when you call FlipX/FlipY.
That's what I actually meant by overriding the methods. But your object can become inconsistent if you ever access it via sf::Sprite* or sf::Sprite& because FlipX() and FlipY() are not virtual.

Why are there no getters like IsFlippedX() and IsFlippedY()? Is there a special reason, or is this feature just required too rarely? And as I said, I think it's not very useful to have the two bools again, if they already exist in the base class. At least, I find it a bit questionable to provide setters only... ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Checking if a sprite flipped?
« Reply #5 on: October 02, 2009, 08:57:30 pm »
Don't worry, it will probably be implemented one day ;)
Laurent Gomila - SFML developer

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Checking if a sprite flipped?
« Reply #6 on: October 02, 2009, 10:10:13 pm »
Okay, thanks for the notice. :)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Haze

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Github Profile
Checking if a sprite flipped?
« Reply #7 on: October 15, 2011, 09:15:18 pm »
I just discovered there is currently no way to tell is a sprite is flipped, and found this old topic.

Laurent, do you still plan to add those two little getters IsFlippedX / IsFlippedY ?
I concur with Nexus, overriding FlipX/FlipY methods is just an hacky workaround.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Checking if a sprite flipped?
« Reply #8 on: October 15, 2011, 10:13:52 pm »
I think I'll just remove these functions from sf::Sprite, and instead allow negative scale factors.
Laurent Gomila - SFML developer

Haikarainen

  • Guest
Checking if a sprite flipped?
« Reply #9 on: October 16, 2011, 12:01:29 am »
Quote from: "Laurent"
I think I'll just remove these functions from sf::Sprite, and instead allow negative scale factors.


That sounds like a REALLY great idea!

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
Checking if a sprite flipped?
« Reply #10 on: October 16, 2011, 12:44:50 am »
Quote from: "Haikarainen"
Quote from: "Laurent"
I think I'll just remove these functions from sf::Sprite, and instead allow negative scale factors.
That sounds like a REALLY great idea!

One that I requested a long while ago :lol:
One problem with the old flip functions is that it flips the texture, not the sprite. In most situations we want to flip around the sprite origin, which is, in practice, a negative scaling.
Pluma - Plug-in Management Framework