Packagecitrus.core
Classpublic class CitrusEngine
InheritanceCitrusEngine Inheritance flash.display.MovieClip
Subclasses Away3DCitrusEngine, StarlingCitrusEngine

CitrusEngine is the top-most class in the library. When you start your project, you should make your document class extend this class unless you use Starling. In this case extends StarlingCitrusEngine.

CitrusEngine is a singleton so that you can grab a reference to it anywhere, anytime. Don't abuse this power, but use it wisely. With it, you can quickly grab a reference to the manager classes such as current State, Input and SoundManager.



Public Properties
 PropertyDefined By
  console : Console
[read-only] A reference to the console, so that you can add your own console commands.
CitrusEngine
  DEBUG : Boolean = false
DEBUG is not used by CitrusEngine, it is there for your own convenience so you can access it wherever the _ce 'shortcut' is.
CitrusEngine
  fullScreen : Boolean
CitrusEngine
  futureState : IState
Get a direct access to the futureState.
CitrusEngine
  gameData : AGameData
You may use a class to store your game's data, this is already an abstract class made for that.
CitrusEngine
  input : Input
[read-only] You can get access to the Input manager object from this reference so that you can see which keys are pressed and stuff.
CitrusEngine
  levelManager : LevelManager
You may use the Citrus Engine's level manager if you have several levels to handle.
CitrusEngine
  onPlayingChange : Signal
Used to pause animations in SpriteArt and StarlingArt.
CitrusEngine
  onStageResize : Signal
called after a stage resize event signal passes the new screenWidth and screenHeight as arguments.
CitrusEngine
  playing : Boolean
Runs and pauses the game loop.
CitrusEngine
  screenHeight : int
[read-only]
CitrusEngine
  screenWidth : int
[read-only]
CitrusEngine
  sound : SoundManager
[read-only] A reference to the SoundManager instance.
CitrusEngine
  state : IState
A reference to the active game state.
CitrusEngine
Protected Properties
 PropertyDefined By
  _fullScreen : Boolean = false
CitrusEngine
  _futureState : IState
CitrusEngine
  _input : Input
CitrusEngine
  _newState : IState
CitrusEngine
  _playing : Boolean = true
CitrusEngine
  _screenHeight : int = 0
CitrusEngine
  _screenWidth : int = 0
CitrusEngine
  _state : IState
CitrusEngine
  _stateDisplayIndex : uint = 0
CitrusEngine
  _stateTransitionning : IState
CitrusEngine
  _timeDelta : Number
CitrusEngine
Public Methods
 MethodDefined By
  
Flash's innards should be calling this, because you should be extending your document class with it.
CitrusEngine
  
destroy():void
Destroy the Citrus Engine, use it only if the Citrus Engine is just a part of your project and not your Main class.
CitrusEngine
  
[static]
CitrusEngine
  
initialize():void
Called when CitrusEngine is added to the stage and ready to run.
CitrusEngine
Protected Methods
 MethodDefined By
  
handleAddedToStage(e:Event):void
Set up things that need the stage access.
CitrusEngine
  
handleEnterFrame(e:Event):void
This is the game loop.
CitrusEngine
  
handlePlayingChange(value:Boolean):void
called when the value of 'playing' changes.
CitrusEngine
  
handleStageActivated(e:Event):void
Set CitrusEngine's playing to true.
CitrusEngine
  
Set CitrusEngine's playing to false.
CitrusEngine
  
handleStageFullscreen(e:FullScreenEvent):void
CitrusEngine
  
handleStageResize(e:Event):void
CitrusEngine
  
on resize or fullscreen this is called and makes sure _screenWidth/_screenHeight is correct, it can be overriden to update other values that depend on the values of _screenWidth/_screenHeight.
CitrusEngine
Public Constants
 ConstantDefined By
  transformMatrix : Matrix
the matrix that describes the transformation required to go from state container space to flash stage space.
CitrusEngine
  VERSION : String = 3.1.12
[static]
CitrusEngine
Property Detail
_fullScreenproperty
protected var _fullScreen:Boolean = false

_futureStateproperty 
protected var _futureState:IState

_inputproperty 
protected var _input:Input

_newStateproperty 
protected var _newState:IState

_playingproperty 
protected var _playing:Boolean = true

_screenHeightproperty 
protected var _screenHeight:int = 0

_screenWidthproperty 
protected var _screenWidth:int = 0

_stateproperty 
protected var _state:IState

_stateDisplayIndexproperty 
protected var _stateDisplayIndex:uint = 0

_stateTransitionningproperty 
protected var _stateTransitionning:IState

_timeDeltaproperty 
protected var _timeDelta:Number

consoleproperty 
console:Console  [read-only]

A reference to the console, so that you can add your own console commands. See the class documentation for more info. The console can be opened by pressing the tab key. There is one console command built-in by default, but you can add more by using the addCommand() method.

To try it out, try using the "set" command to change a property on a CitrusObject. You can toggle Box2D's debug draw visibility like this "set Box2D visible false". If your Box2D CitrusObject instance is not named "Box2D", use the name you gave it instead.


Implementation
    public function get console():Console
DEBUGproperty 
public var DEBUG:Boolean = false

DEBUG is not used by CitrusEngine, it is there for your own convenience so you can access it wherever the _ce 'shortcut' is. defaults to false.

fullScreenproperty 
fullScreen:Boolean


Implementation
    public function get fullScreen():Boolean
    public function set fullScreen(value:Boolean):void
futureStateproperty 
futureState:IState

Get a direct access to the futureState. Note that the futureState is really set up after an update so it isn't available via state getter before a state update.


Implementation
    public function get futureState():IState
    public function set futureState(value:IState):void
gameDataproperty 
public var gameData:AGameData

You may use a class to store your game's data, this is already an abstract class made for that. It's also a dynamic class, so you won't have problem to access information in its extended class.

inputproperty 
input:Input  [read-only]

You can get access to the Input manager object from this reference so that you can see which keys are pressed and stuff.


Implementation
    public function get input():Input
levelManagerproperty 
public var levelManager:LevelManager

You may use the Citrus Engine's level manager if you have several levels to handle. Take a look on its class for more information.

onPlayingChangeproperty 
public var onPlayingChange:Signal

Used to pause animations in SpriteArt and StarlingArt.

onStageResizeproperty 
public var onStageResize:Signal

called after a stage resize event signal passes the new screenWidth and screenHeight as arguments.

playingproperty 
playing:Boolean

Runs and pauses the game loop. Assign this to false to pause the game and stop the update() methods from being called. Dispatch the Signal onPlayingChange with the value. CitrusEngine calls its own handlePlayingChange listener to 1.reset all input actions when "playing" changes 2.pause or resume all sounds. override handlePlayingChange to override all or any of these behaviors.


Implementation
    public function get playing():Boolean
    public function set playing(value:Boolean):void
screenHeightproperty 
screenHeight:int  [read-only]


Implementation
    public function get screenHeight():int
screenWidthproperty 
screenWidth:int  [read-only]


Implementation
    public function get screenWidth():int
soundproperty 
sound:SoundManager  [read-only]

A reference to the SoundManager instance. Use it if you want.


Implementation
    public function get sound():SoundManager
stateproperty 
state:IState

A reference to the active game state. Actually, that's not entirely true. If you've recently changed states and a tick hasn't occurred yet, then this will reference your new state; this is because actual state-changes only happen pre-tick. That way you don't end up changing states in the middle of a state's tick, effectively fucking stuff up. If you had set up a futureState, accessing the state it wil return you the futureState to enable some objects instantiation (physics, views, etc).


Implementation
    public function get state():IState
    public function set state(value:IState):void
Constructor Detail
CitrusEngine()Constructor
public function CitrusEngine()

Flash's innards should be calling this, because you should be extending your document class with it.

Method Detail
destroy()method
public function destroy():void

Destroy the Citrus Engine, use it only if the Citrus Engine is just a part of your project and not your Main class.

getInstance()method 
public static function getInstance():CitrusEngine

Returns
CitrusEngine
handleAddedToStage()method 
protected function handleAddedToStage(e:Event):void

Set up things that need the stage access.

Parameters

e:Event

handleEnterFrame()method 
protected function handleEnterFrame(e:Event):void

This is the game loop. It switches states if necessary, then calls update on the current state.

Parameters

e:Event

handlePlayingChange()method 
protected function handlePlayingChange(value:Boolean):void

called when the value of 'playing' changes. resets input actions , pauses/resumes all sounds by default.

Parameters

value:Boolean

handleStageActivated()method 
protected function handleStageActivated(e:Event):void

Set CitrusEngine's playing to true. The main loop is performed.

Parameters

e:Event

handleStageDeactivated()method 
protected function handleStageDeactivated(e:Event):void

Set CitrusEngine's playing to false. Every update methods aren't anymore called.

Parameters

e:Event

handleStageFullscreen()method 
protected function handleStageFullscreen(e:FullScreenEvent):void

Parameters

e:FullScreenEvent

handleStageResize()method 
protected function handleStageResize(e:Event):void

Parameters

e:Event

initialize()method 
public function initialize():void

Called when CitrusEngine is added to the stage and ready to run.

resetScreenSize()method 
protected function resetScreenSize():void

on resize or fullscreen this is called and makes sure _screenWidth/_screenHeight is correct, it can be overriden to update other values that depend on the values of _screenWidth/_screenHeight.

Constant Detail
transformMatrixConstant
public const transformMatrix:Matrix

the matrix that describes the transformation required to go from state container space to flash stage space. note : this does not include the camera's transformation. the transformation required to go from flash stage to in state space when a camera is active would be obtained with var m:Matrix = camera.transformMatrix.clone(); m.concat(_ce.transformMatrix); using flash only, the state container is aligned and of the same scale as the flash stage, so this is not required.

VERSIONConstant 
public static const VERSION:String = 3.1.12