Neo  0.5.0
Developer Documentation
Neo::Behavior Class Referenceabstract

The Behavior class is an abstraction for creating behaviors. More...

#include <Behavior.h>

Public Member Functions

 Behavior (Object3d *parentObject)
 Creates a new behavior as the child of the given object. More...
 
virtual ~Behavior (void)
 
virtual void destroy (void)=0
 
Object3dgetParentObject (void)
 Returns the parent object. More...
 
virtual const char * getName (void)=0
 Returns the behavior name. More...
 
virtual BehaviorgetCopy (Object3d *parentObject)=0
 Copies one instance of a behavior to a new one and sets the new parent. More...
 
virtual void update (void)=0
 This method is used to update the game logic which is implemented here. More...
 
virtual void draw (void)
 Draws behavior specific images to the screen. More...
 
virtual void runEvent (int param)
 
virtual unsigned int getVariablesNumber (void)=0
 Returns the number of variables this behavior contains. This number is hardcoded in most behaviors. More...
 
virtual NeoVariable getVariable (unsigned int id)=0
 Returns the variable with the given ID. More...
 

Detailed Description

The Behavior class is an abstraction for creating behaviors.

Behaviors can be attached to objects in a Maratis scene. They contain several methods for interacting with the engine and the parent object allowing them to be used as one of the main interfaces for programming game logic.

Constructor & Destructor Documentation

Neo::Behavior::Behavior ( Object3d parentObject)

Creates a new behavior as the child of the given object.

Parameters
parentObjectThe parent of the new object.
virtual Neo::Behavior::~Behavior ( void  )
virtual

Member Function Documentation

virtual void Neo::Behavior::destroy ( void  )
pure virtual
virtual void Neo::Behavior::draw ( void  )
inlinevirtual

Draws behavior specific images to the screen.

Draw is called as often as possible to allow maximum rendering performance.

ATTENTION: No game logics should be located here since this code is very performance relevant!

virtual Behavior* Neo::Behavior::getCopy ( Object3d parentObject)
pure virtual

Copies one instance of a behavior to a new one and sets the new parent.

Parameters
parentObjectThe parent object of the new behavior instance.
Returns
The new behavior instance.
virtual const char* Neo::Behavior::getName ( void  )
pure virtual

Returns the behavior name.

All behaviors need a static string with the name in it to identify it. This method has to be overwritten by any child class!

Returns
The name of the behavior.
Object3d* Neo::Behavior::getParentObject ( void  )
inline

Returns the parent object.

Returns
The parent object.
virtual NeoVariable Neo::Behavior::getVariable ( unsigned int  id)
pure virtual

Returns the variable with the given ID.

Most behaviors give hardcoded variables back.

Example:

MVariable DataBehavior::getVariable(unsigned int id)
{
switch(id)
{
default:
return MVariable("NULL", NULL, M_VARIABLE_NULL);
case 0:
return MVariable("data", &m_data, M_VARIABLE_STRING);
}
}
See also
MVariable
Parameters
idThe ID of the variable. All values are smaller than the one returned by MBehavior::getVariablesNumber
Returns
The variable.
virtual unsigned int Neo::Behavior::getVariablesNumber ( void  )
pure virtual

Returns the number of variables this behavior contains. This number is hardcoded in most behaviors.

See also
MVariable
Returns
Number of variables.
virtual void Neo::Behavior::runEvent ( int  param)
inlinevirtual
virtual void Neo::Behavior::update ( void  )
pure virtual

This method is used to update the game logic which is implemented here.

Update is called every 16,6ms (60FPS) and has to be overwritten by any child class.

ATTENTION: No rendering can be done in here! Use MBehavior::draw instead!


The documentation for this class was generated from the following file: