SFML community forums
Help => Graphics => Topic started by: jmpeer on May 02, 2010, 11:26:20 pm
-
Yo,
I made a class called Button.
It inherits from String, but also has an Image and Sprite member.
I assumed if I wanted my RenderWindow to draw the Sprite and then the String,
I needed this in the .hpp file:
protected:
virtual void Render(RenderTarget& Target);
And this in the .cpp file:
void Render(RenderTarget& Target)
{
Target.Draw(sprite);
}
It draws the String, the parent class, but does nothing with the sprite, the member. What is the most appropriate way of doing this?
-
This:
private:
void Render(RenderTarget& Target) const;
It is private const :wink:
-
Oh, thanks.
Button is now inheriting from Drawable.
And it has a Sprite, Image, and String member.
And they're being drawn correctly now.
In the .hpp:
protected:
virtual void Render(RenderTarget& Target) const;
In the .cpp:
void Render(RenderTarget& Target) const
{
Target.Draw(sprite);
Target.Draw(text);
}