Suppose I have a class like this:
Class GraphicalEntity : public sf::Drawable, sf::Transformable
{
public:
GraphicalEntity();
private:
sf::Sprite aSprite
void draw(sf::RenderTarget &target, sf::RenderStates states) const;
};
And then there's the implementation thereof with draw():
draw(sf::RenderTarget &target, sf::RenderStates states) const
{
aSprite.setPosition(100, 100); // Error
target.draw(aSprite);
}
I get an error when I want to set the position of the sprite, visual studio complains:
Error: no instance of overloaded function "Sprite::setPosition" matches the argument list and object (the object has type qualifies that prevent a match)
argument types are: (int,int)
object type is: const Sprite
However, if I declare a sprite within draw's implementation then I can easily apply various transforms. What I want to know is, how can I use aSprite within the draw function? If I declare a local sprite within the draw() function, then I can't use it outside the function.