【问题标题】:Flipping youtr character sprite backwards in sfml c++在 sfml c++ 中向后翻转你的角色精灵
【发布时间】:2014-10-15 21:35:35
【问题描述】:

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

我正在使用:

SFML 2.1 C++

我试过了:

  guy.setTextureRect(sf::IntRect(guy.getGlobalBounds().width, 0, guy.getGlobalBounds.width * -1, guy.getGlobalBounds.height));

【问题讨论】:

    标签: c++ window sfml sprite


    【解决方案1】:

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

    sf::Sprite sprite(texture);
    sprite.setOrigin({ sprite.getLocalBounds().width, 0 });
    sprite.setScale({ -1, 1 });
    

    【讨论】:

    • 工作完美!谢谢!
    猜你喜欢
    • 2021-11-18
    • 2014-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多