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

Author Topic: Flipping sprites with set scale vs flipping images[SOLVED]  (Read 1062 times)

0 Members and 1 Guest are viewing this topic.

MFB

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
I'm currently writing a very simple platformer(if there is such a thing) and I have to make a decision; some of my sprite sheets are symmetrical thus the sprites need to be mirrored when the player is facing the other direction. Currently I haven't implemented mirroring in my animation so I do something like this for all sprite sheets
if(CurrentState == Idle)
{
if(CurrentDirection == left)
    animation->Row = 0;
if(CurrentDirection == right)
    animation->Row = 1;
}
 
Would it be slower if I did this instead, would the space I save on sprite sheets be worth it?
if(CurrentState == Idle)
{
animation->Row = 0;
if(CurrentDirection == left)
    animation->Sprite.SetScale(1,1);
if(CurrentDirection == right)
    animation->Sprite.SetScale(-1,1);
}
 
Note: My sprite sheets consist of rows and columns of 250x250 images, usually about 25 mb's in size.
« Last Edit: May 22, 2017, 02:57:07 pm by MFB »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Flipping sprites with set scale vs flipping images
« Reply #1 on: May 22, 2017, 02:37:10 pm »
If your question is "is it expensive to apply a (negative) scale?", then no, it's free.
Laurent Gomila - SFML developer

MFB

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: Flipping sprites with set scale vs flipping images
« Reply #2 on: May 22, 2017, 02:54:26 pm »
Thanks a lot! That was exactly what I was asking.

 

anything