SFML community forums

Help => Graphics => Topic started by: TheDianamu on September 29, 2013, 04:10:54 am

Title: setImage not a member of sf::Sprite
Post by: TheDianamu on September 29, 2013, 04:10:54 am
I'm having troubles with my tile class for my engine. I'm using the SFML 2.1 and coding visual c++ 2010

I get the following on compile:
'setImage' : is not a member of 'sf::Sprite'

Tile.cpp:
#include "Tile.h"
#include <SFML\Graphics.hpp>

Tile::Tile(sf::Image& image)
{
        baseSprite.setImage(image, true);
}

Tile::~Tile()
{

}

void Tile::Draw(int x, int y, sf::RenderWindow* rw)
{
        baseSprite.setPosition(x, y);
        rw->draw(baseSprite);
}

Tile.h:

#ifndef _TILE_H
#define _TILE_H

#include <SFML\Graphics.hpp>

class Tile
{
private:
        sf::Sprite baseSprite;

public:
        Tile(sf::Image& image);
        ~Tile();

        void Draw(int x, int y, sf::RenderWindow* rw);
};

#endif
Title: Re: setImage not a member of sf::Sprite
Post by: AlejandroCoria on September 29, 2013, 04:31:45 am
Use sf::Texture instead of sf:Image

http://www.sfml-dev.org/documentation/2.1/classsf_1_1Sprite.php (http://www.sfml-dev.org/documentation/2.1/classsf_1_1Sprite.php)

http://www.sfml-dev.org/documentation/2.1/classsf_1_1Texture.php (http://www.sfml-dev.org/documentation/2.1/classsf_1_1Texture.php)
Title: Re: setImage not a member of sf::Sprite
Post by: Laurent on September 29, 2013, 09:09:28 am
Read an up-to-date documentation ;)