# How to flip sprite in sfml

I am facing the same problem although the sprite flips but only one time after that it does not flips at all. Here is the code snippet:

void Doodle::moveLeft()
{
if(d_Right)
d_Sprite.setScale(-1.0f, 1.0f);
d_Left = true;
}

void Doodle::moveRight()
{
if(d_Left==false)
d_Sprite.setScale(-1.0f, 1.0f);
d_Right = true;
}

void Doodle::stopLeft()
{
d_Left = false;
}

void Doodle::stopRight()
{
d_Right = false;
}


void Doodle::moveLeft() { if(d_Right) d_Sprite.setScale(-1.0f, 1.0f); d_Left = true; }

void Doodle::moveRight() { if(d_Left==false) d_Sprite.setScale(-1.0f, 1.0f); d_Right = true; }


This code is exactly the same, specifically: d_Sprite.setScale(-1.0f, 1.0f), this only flips it one way, you have to change this to flip it back.

The setScale function overwrites the previous scale. You just need to set the scale to 1 to get the original sprite.

void Doodle::moveLeft()
{
d_Sprite.setScale(-1.0f, 1.0f);
}

void Doodle::moveRight()
{
d_Sprite.setScale(1.0f, 1.0f);
}