Class Index | File Index

Classes


Class R.components.Base


Extends R.engine.BaseObject.
All components extend from this object class. A component is one part of an operating whole object (a R.engine.GameObject) which is responsible for only a portion of the overall operation of the game object. Components are broken down into five major categories:

Components are executed in the order listed. First, all inputs are checked, then logic is performed. Logic may be internal to a game object itself, but some components perform an object-centric type of logic that can be reused. Next, collisions are checked. And finally, rendering can occur.

Within each component type set, components can be prioritized so that one component will execute before others. Such an ordering allows for multiple components of each type to perform their tasks in an order that the game object defines.
Defined in: base.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
R.components.Base(name, type, priority)
Create a new instance of a component, setting the name, type, and update priority of this component compared to all other components within the host.
Field Summary
Field Attributes Field Name and Description
 
The constant value for COLLIDER components.
 
The constant value for INPUT components.
 
The constant value for LOGIC components.
 
The constant value for RENDERING components.
 
The constant value for TRANSFORM (movement) components.
Method Summary
Method Attributes Method Name and Description
 
execute(renderContext, time, dt)
[ABSTRACT] This method is called by the game object to run the component, updating its state.
 
Get the class name of this object
 
Gets the game object this component is a part of.
 
Deprecated in favor of #getGameObject
 
Returns the priority of this component.
 
Get the type of this component.
 
Get the type of the component as a string.
 
Releases the object back into the object pool.
 
setGameObject(gameObject)
Establishes the link between this component and its game object.
 
setHostObject(hostObject)
Deprecated in favor of #setGameObject
 
setPriority(priority)
Set the execution priority of this component with 1.0 being the highest priority and 0.0 being the lowest.
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.Base(name, type, priority)
Create a new instance of a component, setting the name, type, and update priority of this component compared to all other components within the host.
Parameters:
name
{String} The name of the component
type
{Number} The type of the component
priority
{Number} A value between 0.0 and 1.0. Default: 0.5
Field Detail
TYPE_COLLIDER
The constant value for COLLIDER components.

TYPE_INPUT
The constant value for INPUT components.

TYPE_LOGIC
The constant value for LOGIC components.

TYPE_RENDERING
The constant value for RENDERING components.

TYPE_TRANSFORM
The constant value for TRANSFORM (movement) components.
Method Detail
execute(renderContext, time, dt)
[ABSTRACT] This method is called by the game object to run the component, updating its state. Not all components will need an execute method. However, it is important to include one if you need to update the state of the component for each engine cycle.
Parameters:
renderContext
{R.rendercontexts.AbstractRenderContext} The context the component will render within.
time
{Number} The global engine time
dt
{Number} The delta between the world time and the last time the world was updated in milliseconds.

{String} getClassName()
Get the class name of this object
Returns:
{String} The string "R.components.Base"

{R.engine.GameObject} getGameObject()
Gets the game object this component is a part of. When the component was assigned to a game object, the game object will have set itself as the container via #setGameObject.
Returns:
{R.engine.GameObject}

getHostObject()
Deprecated in favor of #getGameObject

{Number} getPriority()
Returns the priority of this component.
Returns:
{Number} A value between 0.0 and 1.0

{Number} getType()
Get the type of this component. The value will be one of: #TYPE_INPUT, #TYPE_TRANSFORM, #TYPE_LOGIC, #TYPE_COLLIDER, or #TYPE_RENDERING
Returns:
{Number} The component type Id

{String} getTypeString()
Get the type of the component as a string.
Returns:
{String}

release()
Releases the object back into the object pool. See PooledObject#release for more information.

setGameObject(gameObject)
Establishes the link between this component and its game object. When you assign components to a game object, it will call this method so that each component can refer to its game object, the same way a game object can refer to a component with R.engine.GameObject#getComponent.
Parameters:
gameObject
{R.engine.GameObject} The object which hosts this component

setHostObject(hostObject)
Deprecated in favor of #setGameObject
Parameters:
hostObject

setPriority(priority)
Set the execution priority of this component with 1.0 being the highest priority and 0.0 being the lowest. Components within a game object are sorted by type, and then priority. As such, two components with the same type will be sorted by priority with the higher value executing before the lower value. This allows you to layer components like the R.components.Render component so that one effect is drawn before another.
Parameters:
priority
{Number} A value between 0.0 and 1.0

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