我目前的sfml项目有一些看法。 View 改变大小和中心。我可以用数学计算出我想要的位置,但这似乎工作量太大了。是否存在我可以使用的内置函数?
最佳答案
是的,您可以使用 sf::RenderWindow::getDefaultView()
如下(假设你有一个名为 window
的 sf::RenderWindow
):
// First draw all objects that you have set a view for
window.setView(yourView);
window.draw(viewObject);
window.setView(window.getDefaultView()); // Reset the view to the window's default one
// ... Set the position and all (You can do this before as well)
window.draw(yourScoreBoard);
window.display(); // You should see your views with a score board overlay that
// stays in the same place
如果你想绘制有自己 View 的东西,那么首先将窗口的 View 设置为该 View ,然后绘制你的对象。
关于c++ - SFML 参照窗口绘制绝对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48995457/