Class R.components.collision.Circle
Extends
R.components.Collider.
An extension of the ColliderComponent which will check if the
object's are colliding based on their world bounding circles. If either of the
objects does not have the R.objects.Object2D#getWorldCircle method
the test will result in no collision.
true
or false
test. A more detailed test
can be made by setting the component to perform a 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: circle.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.components.collision.Circle(name, collisionModel, priority)
Creates a collider component for circle-circle 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 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.Circle(name, collisionModel, priority)
Creates a collider component for circle-circle collision testing. Each object
must implement either the R.objects.Object2D#getWorldBox or
R.objects.Object2D#getCircle method and return a world-oriented bounding box or
circle, respectively.
- Parameters:
- name
- {String} Name of the component
- collisionModel
- {SpatialCollection} 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} The string "R.components.collision.Circle"
release()
Releases the component back into the pool for reuse. See R.engine.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 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 game object
- targetMask
- {Number} The collision mask for collisionObj
- Returns:
- {Number} A status indicating whether to continue checking, or to stop