Class R.components.collision.Convex
Extends
R.components.Collider.
An extension of the ColliderComponent which will check the
object's convex collision hulls using the Separating Axis Theorm (SAT). Each object must
have a collision hull assigned to it with R.objects.Object2D#setCollisionHull.
Defined in: convex.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.components.collision.Convex(name, collisionModel, priority)
Creates a collider component for SAT 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()
Release the component back into the object pool.
|
|
setGameObject(gameObject)
Establishes the link between this component and its game object.
|
|
setHostObject(gameObject)
Deprecated in favor of #setGameObject
|
|
test(shape1, shape2, time, dt)
Performs the SAT collision test for
shape1 against shape2 . |
|
testCollision(time, dt, collisionObj, objectMask, targetMask)
If a collision occurs, calls the game object's onCollide() method,
passing the time of the collision, the potential collision object, and the game object
and target's 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.Convex(name, collisionModel, priority)
Creates a collider component for SAT collision testing. Each object's
collision will be determined using its convex collision hull.
- 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.Convex"
release()
Release the component back into the object pool.
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
{R.math.Vector2D}
test(shape1, shape2, time, dt)
Performs the SAT collision test for
http://rocketmandevelopment.com/2010/05/19/separation-of-axis-theorem-for-collision-detection/
shape1
against shape2
.
Each shape is either a convex hull or a circle (AABB or box is considered a polygon).
If a collision is observed, the method will return a repulsion vector for the first
shape to not collide with the second shape. If no collision is determined, the
repulsion vector will be R.math.Vector2D#ZERO.
The resulting tests used by this component can be found at:http://rocketmandevelopment.com/2010/05/19/separation-of-axis-theorem-for-collision-detection/
- Parameters:
- shape1
- {R.collision.ConvexHull}
- shape2
- {R.collision.ConvexHull}
- time
- {Number} The world time
- dt
- {Number} The delta between the world time and the last time the world was updated in milliseconds.
- Returns:
- {R.math.Vector2D}
{Number}
testCollision(time, dt, collisionObj, objectMask, targetMask)
If a collision occurs, calls the game object's onCollide() method,
passing the time of the collision, the potential collision object, and the game object
and target's 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 host object
- targetMask
- {Number} The collision mask for collisionObj
- Returns:
- {Number} A status indicating whether to continue checking, or to stop