SFML community forums
Help => Graphics => Topic started by: nitram_cero on May 04, 2009, 11:31:29 pm
-
FlipX/Y does not flip using the center as pivot.
Is this the intention?
If I have an already centered image, and apply a flipX(true), the flip
gets done in respect to the left border.
And now the center is outside the image (left where it was).
I think I've already asked this, but I don't seem to find it in the forums.
Thanks.
-Martín
-
FlipX/Y does not flip using the center as pivot.
Is this the intention?
Yes. Flipping X just means the sprite is mirrored so that the left edge becomes the right one and vice versa (analogous to Top/Bottom).
-
Thanks, but I don't seem to find a way to center it.
I try this fixup
spr_.SetImage(*anim_->frames[keyframe_].image);
spr_.SetCenter((float)spr_.GetImage()->GetWidth()/2, (float)spr_.GetImage()->GetHeight());
//...
spr_.flipX(facing_==Animation::FaceLeft);
if(facing_==Animation::FaceLeft && spr_.GetCenter().x>0 || facing_==Animation::FaceRight && spr_.GetCenter().x<0)
spr_.SetCenter(-spr_.GetCenter().x, spr_.GetCenter().y);
But doesn't work when going left.
(http://i44.tinypic.com/2z4hlzk.png)
(Don't mind the crappy graphics)
Any help?
Thanks!
EDIT:
I forgot that SetImage only changes the sprite size the first time.
spr_.SetSubRect(IntRect(0, 0, spr_.GetImage()->GetWidth(), spr_.GetImage()->GetHeight()));
In case anyone was wondering, this fixed my problem.
BTW: No fixup was needed, flipX was working as expected. Sorry! :oops:
Regards
-Martín