problem inheriting Character class to render it

maroxe

01-09-2008 17:36:28

Hi,
i'm trying to make my character visible, i have to ways to do that:
  1. *inherting from Character and RenderableSource Classes like NxOgre::Body
    *class Player{
    /***/
    protected:
    Character* character;
    RenderableSource* renderableSource;
    /**/
    };
    [/list:u]
    with the first method, i can't call the Scene::CreateCharacterMethod, because it returns a Character* , and i don't know how to initialise only the base class part of a derived class (is it possible in C++ ?) :(
    with the second method, i can't have acces to protected memeber :(

mcaden

01-09-2008 17:49:35

that's not inheritance. That's a 'has-a' relationship rather than an 'is-a' relationship.



class Player : public Character
{
...


and in the constructor definition of your player class call the Character's class constructor before entering like so:

Player::Player( String name,...) : Character( name, ... )
{
...


Placing the actual arguments in the parentheses (don't try to redeclare Character's parameters, just use the variables passed into your Player constructor).

maroxe

01-09-2008 20:01:22

ok thanks ;)