Eddit : j'ai trouver mais le problème sa me sort un carrée blanc et le sprite . Voici le code
main.cpp
#include <iostream>
#include <SFML/Graphics.hpp>
#include "Ship.h"
using namespace std;
using namespace sf;
int main()
{
sf::RenderWindow window(sf::VideoMode(1220, 800), "SFML works!");
window.setFramerateLimit(60);
std::vector<Ship> first;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::V))
{
int x = first.size();
first.push_back(Ship());
first[x].setTexture();
first[x].setPosition(100, 100);
}
}
window.clear();
for ( int i = 0; i< first.size();i++)
{
window.draw(first[i]);
}
window.display();
}
return 0;
}
ship.h
#ifndef SHIP_H
#define SHIP_H
#include <SFML/Graphics.hpp>
#include <iostream>
class Ship : public sf::Drawable , public sf::Transformable
{
public:
Ship();
void deplacement();
void setTexture();
private:
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(Spr_ship, states);
}
sf::Sprite Spr_ship;
sf::Texture Text_ship;
};
#endif // SHIP_H
et ship.cpp
#include "Ship.h"
Ship::Ship()
{
Text_ship.loadFromFile("ressource/texture/rafale.png");
Spr_ship.setTexture(Text_ship);
Spr_ship.setPosition(150,150);
Spr_ship.setOrigin(78, 78);
}
void Ship::deplacement()
{
}
void Ship::setTexture()
{
Text_ship.loadFromFile("ressource/texture/rafale.png";
Spr_ship.setTexture(Text_ship);
}
Je ne voie pas dout sa pourais venir. marci de votre aide
bonne journée.
^^ simple pour vous, mais pour un novice comme moi je ne voie pas quoi faire mise a part mettre :
sf::RenderWindow window(sf::VideoMode(1220, 800), "SFML works!");
window.setFramerateLimit(60);
Ship First /*par exemple*/;
std::vector<Ship> first;