Packagecitrus.core.starling
Classpublic class StarlingState
InheritanceStarlingState Inheritance starling.display.Sprite
Implements IState

StarlingState class is just a wrapper for the AState class. It's important to notice it extends Starling Sprite.



Public Properties
 PropertyDefined By
  camera : StarlingCamera
[read-only]
StarlingState
  objects : Vector.<CitrusObject>
[read-only] Contains all the objects added to the State and not killed.
StarlingState
  view : ACitrusView
[read-only] Gets a reference to this state's view manager.
StarlingState
Protected Properties
 PropertyDefined By
  _ce : StarlingCitrusEngine
Get a direct references to the Citrus Engine in your State.
StarlingState
  _input : Input
StarlingState
  _realState : MediatorState
StarlingState
Public Methods
 MethodDefined By
  
StarlingState
  
Call this method to add a CitrusObject to this state.
StarlingState
  
Call this method to add an Entity to this state.
StarlingState
  
Call this method to add a PoolObject to this state.
StarlingState
  
destroy():void
Called by the Citrus Engine.
StarlingState
  
Returns the first instance of a CitrusObject that is of the class that you pass in.
StarlingState
  
Gets a reference to a CitrusObject by passing that object's name in.
StarlingState
  
getObjectsByName(name:String):Vector.<CitrusObject>
This returns a vector of all objects of a particular name.
StarlingState
  
getObjectsByType(type:Class):Vector.<CitrusObject>
This returns a vector of all objects of a particular type.
StarlingState
  
initialize():void
You'll most definitely want to override this method when you create your own State class.
StarlingState
  
killAllObjects(... except):void
Destroy all the objects added to the State and not already killed.
StarlingState
  
remove(object:CitrusObject):void
When you are ready to remove an object from getting updated, viewed, and generally being existent, call this method.
StarlingState
  
removeImmediately instaneously destroys and remove the object from the state.
StarlingState
  
update(timeDelta:Number):void
This method calls update on all the CitrusObjects that are attached to this state.
StarlingState
Protected Methods
 MethodDefined By
  
Override this method if you want a state to create an instance of a custom view.
StarlingState
Property Detail
_ceproperty
protected var _ce:StarlingCitrusEngine

Get a direct references to the Citrus Engine in your State.

_inputproperty 
protected var _input:Input

_realStateproperty 
protected var _realState:MediatorState

cameraproperty 
camera:StarlingCamera  [read-only]


Implementation
    public function get camera():StarlingCamera
objectsproperty 
objects:Vector.<CitrusObject>  [read-only]

Contains all the objects added to the State and not killed.


Implementation
    public function get objects():Vector.<CitrusObject>
viewproperty 
view:ACitrusView  [read-only]

Gets a reference to this state's view manager. Take a look at the class definition for more information about this.


Implementation
    public function get view():ACitrusView
Constructor Detail
StarlingState()Constructor
public function StarlingState()



Method Detail
add()method
public function add(object:CitrusObject):CitrusObject

Call this method to add a CitrusObject to this state. All visible game objects and physics objects will need to be created and added via this method so that they can be properly created, managed, updated, and destroyed.

Parameters

object:CitrusObject

Returns
CitrusObject — The CitrusObject that you passed in. Useful for linking commands together.
addEntity()method 
public function addEntity(entity:Entity):Entity

Call this method to add an Entity to this state. All entities will need to be created and added via this method so that they can be properly created, managed, updated, and destroyed.

Parameters

entity:Entity

Returns
Entity — The Entity that you passed in. Useful for linking commands together.
addPoolObject()method 
public function addPoolObject(poolObject:PoolObject):PoolObject

Call this method to add a PoolObject to this state. All pool objects and will need to be created and added via this method so that they can be properly created, managed, updated, and destroyed.

Parameters

poolObject:PoolObject — The PoolObject isCitrusObjectPool's value must be true to be render through the State.

Returns
PoolObject — The PoolObject that you passed in. Useful for linking commands together.
createView()method 
protected function createView():ACitrusView

Override this method if you want a state to create an instance of a custom view.

Returns
ACitrusView
destroy()method 
public function destroy():void

Called by the Citrus Engine.

getFirstObjectByType()method 
public function getFirstObjectByType(type:Class):CitrusObject

Returns the first instance of a CitrusObject that is of the class that you pass in. This is useful if you know that there is only one object of a certain time in your state (such as a "Hero").

Parameters

type:Class — The class of the object you want to get a reference to.

Returns
CitrusObject
getObjectByName()method 
public function getObjectByName(name:String):CitrusObject

Gets a reference to a CitrusObject by passing that object's name in. Often the name property will be set via a level editor such as the Flash IDE.

Parameters

name:String — The name property of the object you want to get a reference to.

Returns
CitrusObject
getObjectsByName()method 
public function getObjectsByName(name:String):Vector.<CitrusObject>

This returns a vector of all objects of a particular name. This is useful for adding an event handler to objects that aren't similar but have the same name. For instance, you can track the collection of coins plus enemies that you've named exactly the same. Then you'd loop through the returned vector to change properties or whatever you want.

Parameters

name:String — The name property of the object you want to get a reference to.

Returns
Vector.<CitrusObject>
getObjectsByType()method 
public function getObjectsByType(type:Class):Vector.<CitrusObject>

This returns a vector of all objects of a particular type. This is useful for adding an event handler to all similar objects. For instance, if you want to track the collection of coins, you can get all objects of type "Coin" via this method. Then you'd loop through the returned array to add your listener to the coins' event.

Parameters

type:Class — The class of the object you want to get a reference to.

Returns
Vector.<CitrusObject>
initialize()method 
public function initialize():void

You'll most definitely want to override this method when you create your own State class. This is where you should add all your CitrusObjects and pretty much make everything. Please note that you can't successfully call add() on a state in the constructur. You should call it in this initialize() method.

killAllObjects()method 
public function killAllObjects(... except):void

Destroy all the objects added to the State and not already killed.

Parameters

... except — CitrusObjects you want to save.

remove()method 
public function remove(object:CitrusObject):void

When you are ready to remove an object from getting updated, viewed, and generally being existent, call this method. Alternatively, you can just set the object's kill property to true. That's all this method does at the moment.

Parameters

object:CitrusObject

removeImmediately()method 
public function removeImmediately(object:CitrusObject):void

removeImmediately instaneously destroys and remove the object from the state. While using remove() is recommended, there are specific case where this is needed. please use with care. Warning: - can break box2D if called directly or indirectly in a collision listener. - effects unknown with nape.

Parameters

object:CitrusObject

update()method 
public function update(timeDelta:Number):void

This method calls update on all the CitrusObjects that are attached to this state. The update method also checks for CitrusObjects that are ready to be destroyed and kills them. Finally, this method updates the View manager.

Parameters

timeDelta:Number