I created a header file (level.h) which has a constructor with a texture parameter called 'ImagePath'. I am then saying what it will do in the level.cpp file which is to apply the 'ImagePath' texture to a sprite. I am then getting an error:
level.cpp: In constructor ‘Tile::Tile(const sf::Texture&)’:
level.cpp:5:22: error: no match for call to ‘(sf::Sprite) (const sf::Texture&)’
5 | TileSprite(ImagePath);
Here is my code:
level.h
#ifndef LEVEL_H
#define LEVEL_H
#include<SFML/Graphics.hpp>
class Tile: public sf::Drawable {
public:
Tile(const sf::Texture& ImagePath);
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
private:
sf::Sprite TileSprite;
};
#endif
level.cpp
#include "level.h"
Tile::Tile(const sf::Texture& ImagePath) {
TileSprite(ImagePath);
}
void Tile::draw(sf::RenderTarget& target, sf::RenderStates states) const {
//Apply transform here
target.draw(TileSprite,states);
}