简体   繁体   English

SFML错误-isOpen非标准语法;

[英]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.

相关问题 线程构造函数中的非标准语法错误 - Non-Standard Syntax Error in Thread Constructor 错误信息:非标准语法; 使用“&amp;”创建指向成员的指针 - Error Message: non-standard syntax; use '&' to create a pointer to member function arguments 中的向量出现“非标准语法”错误 - “Non-standard syntax” error with vectors in function arguments 非标准语法; 将成员函数分配给vector时,使用&#39;&&#39;创建指向成员错误的指针 - non-standard syntax; use '&' to create a pointer to member error when assigning member function to vector Visual Studio 2015 中的“非标准语法;使用‘&amp;’创建指向成员的指针”错误 - "non-standard syntax; use '&' to create a pointer to member" error in Visual Studio 2015 Windows C++ Wrap dll into class Error: incompatible with parameter and non-standard syntax - Windows C++ Wrap dll into class Error: incompatible with parameter and non-standard syntax 了解重载运算符。 获得“非标准语法”; 使用“&”创建指向成员的指针”错误 - Learning about Overloading Operators. Getting “non-standard syntax; use '&' to create a pointer to a member” error C3867:&#39;_com_error :: Description&#39;:非标准语法 使用“&”创建指向成员的指针 - C3867 : '_com_error::Description': non-standard syntax; use '&' to create a pointer to member 非标准语法; 使用“&”创建指向成员的指针 - non-standard syntax; use '&' to create a pointer to member WINAPI EnumWindowsProc:非标准语法; 使用&创建一个指向成员的点 - WINAPI EnumWindowsProc: Non-Standard Syntax; use & to create a point to a member
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM