SMFL"无法参考,它是一个已删除的功能"

时间:2016-05-05 10:55:14

标签: c++ sfml

我的DrawCircles(窗口)出现问题;方法

当我试图传入"窗口"我的标题中出现了错误。

知道如何解决这个问题吗?此外,谢谢你,我将不胜感激。

这是我的代码:

#include <SFML/Graphics.hpp>
#include <vector>
using namespace std;


vector<sf::CircleShape> Shapes;


int main() {

    sf::RenderWindow window(sf::VideoMode(1280, 720), "Conduit");




    while (window.isOpen()) {

        sf::Event event;
        while (window.pollEvent(event)) {

            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        DrawCircles(window);            // ERROR IS THIS LINE.
        //window.draw(shape);  
        window.display();
    }

}


void RenderCircle()
{
    sf::CircleShape shape;
    shape.setRadius(40.f);
    shape.setPosition(100.f, 100.f);
    shape.setFillColor(sf::Color::Cyan);

    Shapes.push_back(shape);
}

void DrawCircles(sf::RenderWindow window)
{

    for (int i = 0; i < Shapes.size(); i++)
    {
        window.draw(Shapes.at(i));
    }
}

1 个答案:

答案 0 :(得分:0)

请尝试在代码顶部添加DrawCircles方法的原型。并添加所有其他方法的原型。试试这个:

 #include <SFML/Graphics.hpp>
    #include <vector>
    using namespace std;


    void DrawCircles(sf::RenderWindow &window);
    vector<sf::CircleShape> Shapes;
    .. rest of code

void DrawCircles(sf::RenderWindow &window)
{

    for (int i = 0; i < Shapes.size(); i++)
    {
        window.draw(Shapes.at(i));
    }
}