Je ne comprends pas pourquoi mon sprite ne s'affiche pas, peut on m'aider ? Merci.
Voici le code :
#include <SFML/Graphics.hpp>
#include <iostream>
#include <stdlib.h>
#include "Engine.h"
using namespace sf;
using namespace std;
int main()
{
Engine engine;
engine.loadLevel("Golam");
engine.run();
return 0;
}
class Engine
{
public:
Engine();
void loadLevel( string name);
void run();
void draw();
virtual ~Engine();
private:
vector<Plan> plans;
Camera camera;
RenderWindow window;
};
Engine::Engine()
{
window.create(VideoMode(1280, 720), "Test");
window.setFramerateLimit(30);
}
void Engine::loadLevel(string name)
{
Plan plan1("path/plan1.png", 1);
plans.push_back(plan1);
cout << "Level Loaded\n";
}
void Engine::run()
{
while (window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
if (event.type == Event::KeyReleased)
{
if (event.key.code == Keyboard::Escape)
{
window.close();
}
}
}
draw();
}
}
void Engine::draw()
{
window.clear(Color(100,100,50));
window.setView(camera.getView());
window.draw( plans[0].getSprite() );
window.display();
}
#include <SFML/Graphics.hpp>
#include <string>
#include<iostream>
using namespace sf;
using namespace std;
class Plan
{
public:
Plan();
Plan(string path, unsigned int p);
virtual ~Plan();
Sprite getSprite();
int getPriority();
private:
Texture texture;
Sprite sprite;
unsigned int priority;
};
#include "Plan.h"
Plan::Plan(string path, unsigned int p)
{
priority = p;
if (!texture.loadFromFile(path))
{
cout << "error texture." << endl;
}
sprite.setTexture(texture);
}
Sprite Plan::getSprite()
{
return sprite;
}
int Plan::getPriority()
{
return priority;
}