1
我想在SFML庫中創建簡單的形狀,但我無法弄清楚如何在多個文件中共享項目。我知道怎麼也得樣子,但我不知道爲什麼這不工作錯誤C2248:'sf :: NonCopyable :: NonCopyable'
主要文件:
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Ball.cpp"
using namespace std;
using namespace sf;
int main()
{
RenderWindow win(VideoMode(800, 800), L"Rozdział 1");
while (win.isOpen())
{
win.clear(Color::White);
Event e;
while (win.pollEvent(e))
{
if (e.type == Event::Closed)
win.close();
}
Ball ball(win);
win.display();
}
}
和ball.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
using namespace std;
using namespace sf;
class Ball
{
public: Ball(RenderWindow win)
{
CircleShape circle(50);
circle.setPosition(0, 0);
circle.setOutlineColor(Color::Red);
circle.setOutlineThickness(2);
Texture texture;
if (!texture.loadFromFile("textura.png"))
cerr << "Nie można załadować grafiki\n";
circle.setTexture(&texture);
win.draw(circle);
}
};
我必須在這個球的創建名單,我在C++中新建,我只用Java創建項目,但首先我想知道如何共享此項目
[SFML在通過類初始化窗口時給出NonCopyable錯誤]的可能重複(http://stackoverflow.com/questions/14150237/sfml-giving-noncopyable-error-when-initializing-a-window-via-class ) – Hiura
Simillar,但不是這樣,它不能解決我的問題 –