Class Index | File Index

Classes


Class R.engine.GameObject


Extends R.struct.HashContainer.
A game object is a container for components. Each component within the object provides a portion of the overall functionality. A game object can have any number of components of any type within it. Components provide functionality for things like rendering, collision detection, effects, or transformations. This way, an object can be anything, depending on it's components.

A GameObject is the logical foundation for all in-game objects. It is through this mechanism that game objects can be created without having to manipulate large, monolithic objects. A GameObject contains {@link R.components.Base Components}, which are the building blocks for complex functionality and ease of development.

By building a GameObject from multiple components, the object gains the component's functionality without necessarily having to implement anything. Many components already exist in the engine, but you are only limited by your imagination when it comes to developing new components.
Defined in: gameobject.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Create a game object.
Fields borrowed from class R.struct.Container:
EMPTY
Method Summary
Method Attributes Method Name and Description
 
add(component)
Add a component to the game object.
 
componentSort(component1, component2)
Sort components within this object based upon their component type, and the priority within that type.
 
Destroy all of the components within this object and remove this object from it's render context.
 
Get the class name of this object
 
Get the component with the specified name from this object.
 
Get a component by class name.
 
Returns a property object with accessor methods.
 
Get the rendering context this object will be drawn upon.
 
Check the flag which indicates if the object is dirty.
 
Returns true if the object is to be kept alive (updated) at all times.
 
Marks the object as dirty.
 
Release the object back into the object pool.
 
remove(component)
Remove the component from the game object
 
setKeepAlive(state)
Keep object alive, even when outside viewport.
 
setRenderContext(renderContext)
Set the rendering context this object will be drawn within.
 
update(renderContext, time, dt)
Update this object within the render context, at the specified timeslice.
 
Check the flag which indicates if the object was dirty the last time it was updated.
Methods borrowed from class R.struct.HashContainer:
cleanUp, clear, get, isInHash, removeAtIndex, removeHash
Methods borrowed from class R.struct.Container:
addAll, append, clone, concat, contains, filter, forEach, fromArray, getAll, getObjects, insert, iterator, reduce, replace, replaceAt, size, sort, subset, toXML
Methods borrowed from class R.engine.BaseObject:
addEvent, addEvents, getElement, jQ, removeEvent, setElement, triggerEvent
Methods borrowed from class R.engine.PooledObject:
clearObjectDataModel, getId, getName, getObjectDataModel, isDestroyed, setName, setObjectDataModel, toString
Class Detail
R.engine.GameObject()
Create a game object.
Method Detail
add(component)
Add a component to the game object. The components will be sorted based on their type then their priority within that type. Components with a higher priority will be sorted before components with a lower priority. The sorting order for type is:
Parameters:
component
{R.components.Base} A component to add to the host

componentSort(component1, component2)
Sort components within this object based upon their component type, and the priority within that type. Components with a higher priority will be sorted before components with a lower priority.
Parameters:
component1
component2

destroy()
Destroy all of the components within this object and remove this object from it's render context.

{String} getClassName()
Get the class name of this object
Returns:
{String} "R.engine.GameObject"

{R.components.Base} getComponent(name)
Get the component with the specified name from this object.
Parameters:
name
{String} The unique name of the component to get
Returns:
{R.components.Base}

{R.components.Base} getComponentByClass(className)
Get a component by class name. If there is more than one component with the given class, returns the first occurrence.
Parameters:
className
{String} The class name
Returns:
{R.components.Base} The component, or null if not found

{Object} getProperties()
Returns a property object with accessor methods.
Returns:
{Object}

{R.rendercontexts.AbstractRenderContext} getRenderContext()
Get the rendering context this object will be drawn upon.
Returns:
{R.rendercontexts.AbstractRenderContext} The render context the object belongs to

{Boolean} isDirty()
Check the flag which indicates if the object is dirty.
Returns:
{Boolean}

{Boolean} isKeepAlive()
Returns true if the object is to be kept alive (updated) at all times.
Returns:
{Boolean}

markDirty()
Marks the object as dirty. An object is considered dirty if something about it has changed which would affect how it is rendered.

release()
Release the object back into the object pool.

{R.components.Base} remove(component)
Remove the component from the game object
Parameters:
component
{String|R.components.Base} The component to remove, or the name of the component to remove
Returns:
{R.components.Base} The component which was removed

setKeepAlive(state)
Keep object alive, even when outside viewport. Setting an object to the "keep alive" state will keep the object from being put into the render context's inactive bin, even when it is outside of the expanded viewport. This is good for objects which traverse a large area of the game world.
Parameters:
state
{Boolean} true to keep the object alive at all times

setRenderContext(renderContext)
Set the rendering context this object will be drawn within. This method is called when a host object is added to a rendering context.
Parameters:
renderContext
{R.rendercontexts.AbstractRenderContext} The context

update(renderContext, time, dt)
Update this object within the render context, at the specified timeslice.
Parameters:
renderContext
{R.rendercontexts.AbstractRenderContext} The context the object will be rendered within.
time
{Number} The global time within the engine.
dt
{Number} The delta between the world time and the last time the world was updated in milliseconds.

{Boolean} wasDirty()
Check the flag which indicates if the object was dirty the last time it was updated. Objects which aren't dirty, but were dirty, need to be redrawn one more time so they aren't missed in the next frame.
Returns:
{Boolean}

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