Class Index | File Index

Classes


Class R.components.logic.StateMachine


Extends R.components.Logic.
A component that uses a behavior tree to process state changes. This is based on Mary Rose Cook's excellent Machine.js (which is linked in) so for now look to:

http://machinejs.maryrosecook.com/
The states, themselves, should exist on your R.engine.GameObject for which this component is used.
Defined in: statemachine.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
R.components.logic.StateMachine(name, states, priority)
Creates a state machine which is used to drive the behaviors of your game object.
Field Summary
Field Attributes Field Name and Description
 
The default time between state changes (1000 milliseconds)
 
The machine state data model location.
Fields borrowed from class R.components.Base:
TYPE_COLLIDER, TYPE_INPUT, TYPE_LOGIC, TYPE_RENDERING, TYPE_TRANSFORM
Method Summary
Method Attributes Method Name and Description
 
execute(renderContext, time, dt)
Update the state machine for each step of the engine.
 
setBehaviorTree(stateTree, updateInterval)
Set the behavior tree for the state machine.
 
setUpdateInterval(updateInterval)
Set the interval at which the machine's state is updated.
Methods borrowed from class R.components.Logic:
getClassName
Methods borrowed from class R.components.Base:
getGameObject, getHostObject, getPriority, getType, getTypeString, release, setGameObject, setHostObject, setPriority
Methods borrowed from class R.engine.BaseObject:
addEvent, addEvents, destroy, getElement, jQ, removeEvent, setElement, triggerEvent, update
Methods borrowed from class R.engine.PooledObject:
clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toString, toXML
Class Detail
R.components.logic.StateMachine(name, states, priority)
Creates a state machine which is used to drive the behaviors of your game object.
Parameters:
name
{String} The name of the component
states Optional, Default: null
{Object} A states control object, if null assumes the state methods exist on the host.
priority Optional, Default: 1.0
{Number} The priority of this component
Field Detail
DEFAULT_INTERVAL
The default time between state changes (1000 milliseconds)

MACHINE_STATE
The machine state data model location.
Method Detail
execute(renderContext, time, dt)
Update the state machine for each step of the engine.
Parameters:
renderContext
{R.rendercontexts.AbstractRenderContext} The rendering context
time
{Number} The engine time in milliseconds
dt
{Number} The delta between the world time and the last time the world was updated in milliseconds.

setBehaviorTree(stateTree, updateInterval)
Set the behavior tree for the state machine. This is also used to configure how often the machine is updated. By tweaking the speed at which decisions are made, it is possible to simulate faster or slower "behavior" or "thought" processing.
Parameters:
stateTree
{Object} The behavior tree object
updateInterval Optional, Default: 1000
{Number} The number of milliseconds between state changes

setUpdateInterval(updateInterval)
Set the interval at which the machine's state is updated.
Parameters:
updateInterval
{Number} The number of milliseconds between state changes

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Mar 18 2013 16:09:16 GMT-0400 (EDT)