Class R.components.collision.Box
Extends
R.components.Collider.
An extension of the R.components.Collider which will check the
object's axis-aligned bounding boxes for collision.
true
or false
test. A more detailed test
can be made by setting the component to perform a longest axis circle-to-circle collision
test which will result in a collision data structure if a collision occurs. Setting
the testing mode is done by calling the #setTestMode method.
Defined in: box.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.components.collision.Box(name, collisionModel, priority)
Creates a collider component for box-box collision testing.
|
- Fields borrowed from class R.components.Collider:
- COLLIDE_AND_CONTINUE, CONTINUE, DETAILED_TEST, SIMPLE_TEST, STOP
- Fields borrowed from class R.components.Base:
- TYPE_COLLIDER, TYPE_INPUT, TYPE_LOGIC, TYPE_RENDERING, TYPE_TRANSFORM
Method Attributes | Method Name and Description |
---|---|
Get the class name of this object
|
|
release()
Releases the component back into the pool for reuse.
|
|
setGameObject(gameObject)
Establishes the link between this component and its game object.
|
|
setHostObject(gameObject)
Deprecated in favor of #setGameObject
|
|
testCollision(time, dt, collisionObj, objectMask, targetMask)
If a collision occurs, calls the host object's onCollide() method,
passing the time of the collision, the potential collision object, and the host
and target masks.
|
- Methods borrowed from class R.components.Collider:
- destroy, execute, getCollideSame, getCollisionData, getCollisionMask, getCollisionModel, getLinkedBody, getObjectType, getSpatialNode, getTestMode, linkPhysicalBody, setCollideSame, setCollisionData, setCollisionMask, setCollisionModel, setObjectType, setTestMode, updateModel
- Methods borrowed from class R.components.Base:
- getGameObject, getHostObject, getPriority, getType, getTypeString, setPriority
- Methods borrowed from class R.engine.BaseObject:
- addEvent, addEvents, 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.collision.Box(name, collisionModel, priority)
Creates a collider component for box-box collision testing. Each object
must implement the R.objects.Object2D#getWorldBox method and return a
world-oriented bounding box.
- Parameters:
- name
- {String} Name of the component
- collisionModel
- {R.spatial.AbstractSpatialContainer} The collision model
- priority
- {Number} Between 0.0 and 1.0, with 1.0 being highest
Method Detail
{String}
getClassName()
Get the class name of this object
- Returns:
- {String} "R.components.collision.Box"
release()
Releases the component back into the pool for reuse. 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(gameObject)
Deprecated in favor of #setGameObject
- Parameters:
- gameObject
{Number}
testCollision(time, dt, collisionObj, objectMask, targetMask)
If a collision occurs, calls the host object's onCollide() method,
passing the time of the collision, the potential collision object, and the host
and target masks. The return value should either tell the collision tests to continue or stop.
- Parameters:
- time
- {Number} The engine time (in milliseconds) when the potential collision occurred
- dt
- {Number} The delta between the world time and the last time the world was updated in milliseconds.
- collisionObj
- {R.engine.GameObject} The game object with which the collision potentially occurs
- objectMask
- {Number} The collision mask for the game object
- targetMask
- {Number} The collision mask for collisionObj
- Returns:
- {Number} A status indicating whether to continue checking, or to stop