Bonjour en ce moment je fait de la poo mais je coince sur l'affichage d'un sprite.
Voici l'erreur que me sort mon gentil compil : "Error : no matching function call to 'sf::Renderwindow::draw(Piece&)"
Je ne sait d'ou sa viens, merci de m'aider.
Main.cpp :
#include <iostream>
#include <SFML/Graphics.hpp>
#include<Piece.h>
using namespace std;
int main()
{
sf::RenderWindow window(sf::VideoMode(400, 400), "test poo ");
Piece coins;
Piece spritex;
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}
if (sf::Keyboard::isKeyPressed(sf::Keyboard::A))
{
coins.placement();
}
window.clear();
window.draw(spritex);
window.display();
}
}
Piece.h :
#include <SFML/Graphics.hpp>
#ifndef PIECE_H
#define PIECE_H
class Piece
{
public:
Piece();
void placement();
private:
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
{
target.draw(spr_piece, states);
}
sf::Texture t_piece;
sf::Sprite spr_piece;
int rend2X;
int rend2Y;
};
#endif // PIECE_H
Piece.cpp :
#include "Piece.h"
#include <iostream>
#include <sstream>
#include <stdlib.h>
#include <math.h>
#include <SFML/Graphics.hpp>
Piece::Piece()
{
t_piece.loadFromFile("ressource/piece.png");
spr_piece.setTexture(t_piece);
}
void Piece::placement()
{
int randY = rand() % 300;
int randX = rand() % 60;
int rend2X = 1150 - (randX *8 );
int rend2Y = 800 - ( randY *2);
spr_piece.setPosition(rend2X,rend2Y);
}