c++ - SFML 2.0 - 窗口出现后立即关闭
问题描述
窗口出现后立即关闭,即使它应该等待关闭事件。
主.h:
#include <SFML/Graphics.hpp>
#include <iostream>
#include "window.h"
int main()
{
window::window mainwindow;
mainwindow.createwindow(800, 600);
while(mainwindow.window.pollEvent(mainwindow.events)){
if (mainwindow.events.type == sf::Event::Closed){
mainwindow.window.close();
}
}
return 0;
}
窗口.h:
#include <SFML/Graphics.hpp>
#include <iostream>
namespace window{
class window{
public:
sf::Window window;
sf::Event events;
void createwindow(int resx, int resy){
window.create(sf::VideoMode(resx, resy), "MainWindow", sf::Style::Default);
}
};
}
该代码基于此 SFML 教程:https://www.sfml-dev.org/tutorials/2.5/window-window.php
我正在使用 SMFL 2-2.5.1-23.83,IDE 为 code::blocks 20.03。感谢所有帮助
解决方案
推荐阅读
- python - 我不能将单个元素附加到嵌套列表
- asp.net - Visual Studio 2017 版本 15.7.3 未成功启动应用程序
- java - 如何复制不包括目标为空的值的行?
- javascript - 用带有颜色变量的 Span 包裹一小段文本
- android - 如何防止Android Studio中logcats中的时间戳被剥离?
- java - 没有名为“springSecurityFilterChain”的 bean 可用
- python - 识别图像目标线
- php - 跨 2 个表的 SQL 查询计数
- r - 我可以在 dplyr 的汇总中嵌套分组依据吗?
- c++ - “[class] 未声明”但 CLion 看到了