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

Author Topic: SFML 1.4: SetScaleX does not appear to be working  (Read 4329 times)

0 Members and 1 Guest are viewing this topic.

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
SFML 1.4: SetScaleX does not appear to be working
« 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!
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 1.4: SetScaleX does not appear to be working
« Reply #1 on: August 07, 2009, 07:50:22 am »
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.
Laurent Gomila - SFML developer

OniLinkPlus

  • Hero Member
  • *****
  • Posts: 500
    • View Profile
SFML 1.4: SetScaleX does not appear to be working
« Reply #2 on: August 07, 2009, 07:32:57 pm »
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!
I use the latest build of SFML2

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 1.4: SetScaleX does not appear to be working
« Reply #3 on: August 07, 2009, 07:56:21 pm »
Quote
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.
Laurent Gomila - SFML developer

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
SFML 1.4: SetScaleX does not appear to be working
« Reply #4 on: August 08, 2009, 06:51:18 am »
Quote from: "Laurent"
negative scales are not allowed.
What is the reason for this?

It seems like mirroring should be abstracted to the sf::Drawable base class.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 1.4: SetScaleX does not appear to be working
« Reply #5 on: August 08, 2009, 11:32:22 am »
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).
Laurent Gomila - SFML developer

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
SFML 1.4: SetScaleX does not appear to be working
« Reply #6 on: August 08, 2009, 07:38:34 pm »
Quote from: "Laurent"
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML 1.4: SetScaleX does not appear to be working
« Reply #7 on: August 08, 2009, 07:44:45 pm »
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.
Laurent Gomila - SFML developer

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
SFML 1.4: SetScaleX does not appear to be working
« Reply #8 on: August 09, 2009, 12:02:46 am »
Quote from: "Laurent"
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.

 

anything