SFML community forums
Help => Graphics => Topic started by: OniLinkPlus on August 07, 2009, 06:02:00 am
-
I am attempting to flip a Sprite in my game based on which way the player is facing, but when I use Sprite.SetScaleX(-1), the Image remains facing right instead of left. It was enclosed in a condition, so I removed the condition to see if that was a problem, and it still does not flip. Does anyone have any idea what is causing this problem? I would appreciate help. Thanks!
-
If you check the standard error output, you'll find a message which says that negative scales are not allowed. That's why sf::Sprite defines these two functions: FlipX and FlipY.
-
But I don't GET a Standard Error Output. Maybe if I compile my Program as a Console App, the STDERR will show up in the console?
Anyways, I didn't use FlipX because I assumed it would flip it every frame(I had a problem like that in SDL, as in, FlipX(true) will make it face left one frame then right the next), but I guess that was a stupid assumption. It works! Thank you for your help!
-
But I don't GET a Standard Error Output. Maybe if I compile my Program as a Console App, the STDERR will show up in the console?
Yes. But you can also leave your application as it is, and redirect std::cerr to a file for example.
-
negative scales are not allowed.
What is the reason for this?
It seems like mirroring should be abstracted to the sf::Drawable base class.
-
The FlipX and FlipY functions just flip the image without altering the sprite's geometry. Using a negative scale would invert the quad's coordinates, so instead of being drawn in (0, 0, width, height) it would be drawn in (-width, -height, 0, 0).
-
The FlipX and FlipY functions just flip the image without altering the sprite's geometry. Using a negative scale would invert the quad's coordinates, so instead of being drawn in (0, 0, width, height) it would be drawn in (-width, -height, 0, 0).
That's exactly what one would expect when using a negative scale. Also, what if the user uses SetCenter? Then they could choose where to mirror at, which may be useful.
The thing that gets me, though, is that Drawable abstracts position, scale, rotation, etc very well. Mirroring belongs in there as well. In my game I'm actually using glSetScalef in a few places, so this would be quite useful for me, personally.
-
Well, I think that it can be confusing for many users, especially beginners. But you're right, that could be useful too. I'll think about it for SFML 2.0.
-
Well, I think that it can be confusing for many users, especially beginners. But you're right, that could be useful too. I'll think about it for SFML 2.0.
Thanks, I do hope you'll change it.
Scaling by any number goes from 0,0 and rotation also goes from 0,0. I think users would expect that scaling by a negative number does also. Also, scaling by a negative works like that in any other system.