Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: virtual void Render(RenderTarget& Target)  (Read 2166 times)

0 Members and 1 Guest are viewing this topic.

jmpeer

  • Newbie
  • *
  • Posts: 4
    • View Profile
virtual void Render(RenderTarget& Target)
« 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:
Code: [Select]
protected:
virtual void Render(RenderTarget& Target);

And this in the .cpp file:
Code: [Select]
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?

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
virtual void Render(RenderTarget& Target)
« Reply #1 on: May 02, 2010, 11:36:51 pm »
This:
Quote
private:
void Render(RenderTarget& Target) const;

It is private const  :wink:
Pluma - Plug-in Management Framework

jmpeer

  • Newbie
  • *
  • Posts: 4
    • View Profile
virtual void Render(RenderTarget& Target)
« Reply #2 on: May 03, 2010, 12:05:58 am »
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:
Code: [Select]
protected:
virtual void Render(RenderTarget& Target) const;

In the .cpp:
Code: [Select]
void Render(RenderTarget& Target) const
{
     Target.Draw(sprite);
     Target.Draw(text);
}

 

anything