The CitrusObject

The CitrusObject class is the foundational object that should be used for all game objects logic you create, such as spaceships, enemies, coins, bosses. CitrusObject is basically an abstract class that gets added to a State instance. The current State calls update on all CitrusObjects. Also, CitrusObjects are useful because they can be initialized with a params object, which can be created via an object parser/factory.

Define a CitrusObject

Each CitrusObject is defined by a name (there may be duplicate names) and an optional object to set quickly some params. It has also a kill property which determines if the object should be removed and destroyed in the State or not.

var hero:Hero = new Hero("hero", {width:600, view:"patch.swf"});
add(hero);
hero.x = 120;

Its parameters are automatically set up when the object is instantiated. To register new parameters, your object must have them as public properties or setter.

  citrus/citrusobject.txt · Last modified: 2013/06/25 08:51 by 86.71.131.65
 
Powered by DokuWiki