【发布时间】:2013-11-04 15:37:06
【问题描述】:
我从 sfml 2.1 开始,但我找不到如何让程序流畅运行
我的意思是,程序可以运行,但除非我做某事,例如按下按钮或移动鼠标,否则主循环不会运行,
这是我的主循环代码示例
window.setFramerateLimit(30); // set max fps to 30
while (window.isOpen())
{
// this code ignores the framerate limit and doesnt runs when an event is found
while (window.pollEvent(event))
{
// this code works fine but it wont run unless the user presses a key or moves the mouse
}
}
有什么想法吗?
【问题讨论】:
-
That's the way it's supposed to work,应该“始终”运行的代码应该添加到
while (window.pollEvent(event))循环之外。 -
你真的应该阅读tutorials,它们对于使用 SFML 是必不可少的。
-
例如,如果我想让一个精灵自己向左移动,我应该怎么做?
-
@user2953006 你应该阅读教程。这似乎不是技术问题,而是缺乏知识。
标签: c++ sfml frame-rate