[英]SFML Error - isOpen non-standard syntax;
So I am getting this error: game.cpp(15): error C3867: 'sf::Window::isOpen': non-standard syntax; use '&' to create a pointer to member
所以我得到这个错误:
game.cpp(15): error C3867: 'sf::Window::isOpen': non-standard syntax; use '&' to create a pointer to member
game.cpp(15): error C3867: 'sf::Window::isOpen': non-standard syntax; use '&' to create a pointer to member
Game.cpp Game.cpp
#include "Game.h"
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
Game::Game() :
window(sf::VideoMode(200, 200), "SFML works!"),
player()
{
player.setRadius(40.f);
player.setPosition(100.f, 100.f);
player.setFillColor(sf::Color::Cyan);
}
void Game::run() {
while (window.isOpen) {
processEvents();
update();
render();
}
}
void Game::processEvents()
{
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
}
void Game::update() {
}
void Game::render() {
window.clear();
window.draw(player);
window.display();
}
And this is my game.h 这是我的游戏。
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
class Game {
public:
Game();
void run();
sf::RenderWindow window;
sf::CircleShape player;
private:
void processEvents();
void update();
void render();
};
I have no idea what I am doing wrong, I looked trough other stackoverflow answers to the same error but they are all general and they do not help me fix this error because its from the SFML library. 我不知道我在做什么错,我查看了其他关于同一错误的stackoverflow答案,但它们都很笼统,它们无助于我修复此错误,因为它来自SFML库。 If someone know how to fix it please help me :)
如果有人知道如何解决,请帮助我:)
Here while (window.isOpen)
you are testing that the member function pointer 'window.isOpen' is not nullptr
. 在此
while (window.isOpen)
您正在测试成员函数指针'window.isOpen'不是nullptr
。 What you intended was to call the function while (window.isOpen())
. 您打算
while (window.isOpen())
调用该函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.