GameComponent of BuddhaCpp

BuddhaCpp got to provide GameComponent class group, but that is not compoleted, yet. Main classes are only GameComponent class and DrawableComponent class. Interfaces of them still don’t have been defined.

How to define your sub-class?

class MyClass : public GameComponent
{
public:
MyClass(Game* game);
void Update(GameTime gameTime);
};

For changing update-order, you may call SetUpdateOrder(). Now you have to call this in the constructor.

MyClass::MyClass(Game* game)
: GameComponent(game)
{
SetUpdateOrder(20);
}

After you create an instance, you adds it to ComponentCollection of your Game instance.

MyClass* myComp = new MyClass(this);
GetComponents()->Add(myComp);

The case of DrawableComponent is the following;

class MyClass : public DrawableComponent
{
public:
MyClass(Game* game);
void Update(GameTime gameTime);
void Draw(GameTime gameTime);
};

For chaning draw-order, uses SetDrawOrder().

Advertisements
This entry was posted in Game Engine and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s