在sfml c ++中向后翻转youtr字符精灵

Bry*_*yce 1 c++ window sprite sfml

我有一些小问题让我的精灵角色翻转.基本上我有一个可以走到右边的角色..我正在寻找它以使它看起来像是向左走.我目前还没有找到一个可行的解决方案,所以任何帮助都会令人惊叹!

我在用:

SFML 2.1 C++

我试过了:

  guy.setTextureRect(sf::IntRect(guy.getGlobalBounds().width, 0, guy.getGlobalBounds.width * -1, guy.getGlobalBounds.height));
Run Code Online (Sandbox Code Playgroud)

Hiu*_*ura 5

一种方法是使用+/- 1个因子进行缩放,如下所示:

sf::Sprite sprite(texture);
sprite.setOrigin({ sprite.getLocalBounds().width, 0 });
sprite.setScale({ -1, 1 });
Run Code Online (Sandbox Code Playgroud)