C++ SFML - 在特定坐标处渲染

标签 c++

我想拥有自己的游戏渲染风格,但我想知道如何在 SFML 中在特定坐标处渲染 Sprite 。我知道你可以做 sprite.setPositon(20, 56) 这样的事情,但我想更像 window.drawAt(mySprite, 20, 56),因为那会容易得多。

最佳答案

制作一个通过引用获取窗口和 Sprite 的函数。

void drawAt(sf::RenderWindow & window, sf::Sprite & mySprite, int x, int y)
{
    // set sprite position, then draw it
}

然后你可以这样调用它:

drawAt(window, mySprite, 20, 56);

就这么简单:

window.drawAt(mySprite, 20, 56);

关于C++ SFML - 在特定坐标处渲染,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17242000/

相关文章:

c++ - 这是什么意思 : configuring Qt with “-opengl desktop” ?

c++ - 为什么 unordered_map 和 map 提供相同的性能?

c++ - 自定义控件发布的属性不存在

c++ - 是否可以覆盖 boost::bimaps::bimap.left 的 "find"和 "erase"方法?怎么做?

c++ - 错误正方体qt

c++ - 将 "ddd"附加到远程计算机上运行的进程

c++ - 错误 : passing ‘const Integer’ as ‘this’ argument of ‘Integer Integer::pow(int)’ discards qualifiers

c++ - 为什么包含 "boost/multiprecision/cpp_int.hpp"会破坏套接字?

c++ - c++ '<type error> is not a namespace' 中的命名空间问题

c++ - 多个 Pimpl 类互相使用