SMFL "Cannot be Referenced, it is a deleted function"

SMFL "Cannot be Referenced, it is a deleted function"

本文关键字:is function it deleted Cannot be Referenced SMFL      更新时间:2023-10-16

我的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));
    }
}

请尝试在代码顶部添加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));
    }
}