Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;SFML-在特定坐标下渲染_C++ - Fatal编程技术网

C++ C++;SFML-在特定坐标下渲染

C++ C++;SFML-在特定坐标下渲染,c++,C++,我想拥有自己的游戏渲染风格,但我想知道如何在SFML中以特定坐标渲染精灵。我知道你可以做像sprite.setposition(20,56)这样的事情,但我想做得更像window.drawAt(mySprite,20,56),因为那样会容易得多。制作一个函数,通过引用获取一个窗口和一个sprite void drawAt(sf::RenderWindow & window, sf::Sprite & mySprite, int x, int y) { // set spr

我想拥有自己的游戏渲染风格,但我想知道如何在SFML中以特定坐标渲染精灵。我知道你可以做像
sprite.setposition(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);

没有奇迹,你需要创造你自己的功能。我创建了两类纹理和精灵,然后从there@demonofnight我应该使用指针或引用来实现函数吗?在C++中,应该使用引用作为OO/C++方法