qaf::GameObj Class Reference

#include <qafGameObj.h>

Inheritance diagram for qaf::GameObj:

qaf::AnimParticleObj qaf::LaserCursorObj qaf::PlatformerObj qaf::SpriteParticleObj qaf::TubeCursorObj List of all members.

Detailed Description

GameObjs represent the "active" components of the game.

Instances of this class are returned by a GameObjFactory object.

Typically, you will create a different subclass of GameObj for each kind of character, enemy, item, etc. that takes part in the game, and override the relevant methods to define its behavior.


Public Member Functions

virtual void initialize ()
 Method invoked every time the GameObj is inserted into the Environment, as a result of Environment::loadRoom() being called.
virtual void update (int objLayer, float dt)
 The object's "frame function".
virtual void render (int objLayer, float scrollX, float scrollY)
 This is where the object should draw itself using HGE functions.
virtual bool isVolatile ()
 A "volatile object" will be removed from the Environment and deleted when the room is unloaded.
virtual CollisionStructgetCollisionStruct ()
 Returns the collision structure associated with this object.


Member Function Documentation

virtual void qaf::GameObj::initialize (  )  [virtual]

Method invoked every time the GameObj is inserted into the Environment, as a result of Environment::loadRoom() being called.

By the time initialize() is invoked, the object is already inserted in the Room's default object layer.

All Environment-related tasks should be performed here, rather than in the object's constructor.

If the object needs to be in a layer that is not the room's default, this would be the moment to reposition it with Environment::moveGameObj().

The default implementation does nothing.

Reimplemented in qaf::PlatformerObj.

virtual void qaf::GameObj::update ( int  objLayer,
float  dt 
) [virtual]

The object's "frame function".

It will be called once per frame by the Environment. Update the object's internal state here.

The default implementation does nothing.

Parameters:
objLayer The object layer where this GameObj is residing.
dt The same value that was passed to Environment::update().

Reimplemented in qaf::PlatformerObj.

virtual void qaf::GameObj::render ( int  objLayer,
float  scrollX,
float  scrollY 
) [virtual]

This is where the object should draw itself using HGE functions.

The render target is not transformed; thus, objects should implement their own translation using the Environment's scrolling point.

The default implementation does nothing.

See also:
Environment::getScrollingX(), Environment::getScrollingY(), Environment::getBackBuffer()
Parameters:
objLayer The object layer where this GameObj is residing.
scrollX The scrolling point's current X coordinate.
scrollY The scrolling point's current Y coordinate.

Reimplemented in qaf::PlatformerObj.

virtual bool qaf::GameObj::isVolatile (  )  [virtual]

A "volatile object" will be removed from the Environment and deleted when the room is unloaded.

If this method returns false, the object will be kept and reinserted into the Environment, in the new room's default object layer.

The default implementation returns true.

Returns:
true if this is a volatile object.
See also:
Environment::unloadRoom()

virtual CollisionStruct* qaf::GameObj::getCollisionStruct (  )  [virtual]

Returns the collision structure associated with this object.

This method may be invoked many times during a single frame, so it's important to keep its implementation efficient. Specifically, you shouldn't allocate a new CollisionStruct in every call, but rather keep a pointer to one of these objects in your GameObj and set its positional parameters in the update() method.

It is allowed to return NULL in this method. The object will be assumed to have no collision boundaries, and thus will not collide against any other object.

The default implementation returns NULL.

See also:
CollisionStruct

Reimplemented in qaf::PlatformerObj.


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:14 2007 for Qaf Framework by  doxygen 1.5.1-p1