new CircleComponent(pRadius, pOwner)
A circle component is a physic component to add to a game object for
for collisions and physics behaviors as a circle.
Parameters:
Name | Type | Description |
---|---|---|
pRadius |
int | The radius of the circle component. |
pOwner |
FM.GameObject | The game object to which the component belongs. |
Extends
Members
-
acceleration :FM.Vector
-
Acceleration applied to the physic object.
Type:
- Inherited From:
- Source:
-
angularDrag :FM.Vector
-
How much the object's velocity is decreasing when acceleration is equal to 0.
Type:
- Inherited From:
- Source:
-
angularVelocity :int
-
Angular velocity.
Type:
- int
- Inherited From:
- Source:
-
drag :FM.Vector
-
How much the object's velocity is decreasing when acceleration is equal to 0.
Type:
- Inherited From:
- Source:
-
elasticity :float
-
Elasticity is a factor between 0 and 1 used for bouncing purposes.
Type:
- float
- Inherited From:
- Source:
-
height :int
-
Height of the collider.
Type:
- int
- Inherited From:
- Source:
-
maxAngularVelocity :int
-
Maximum angular velocity.
Type:
- int
- Inherited From:
- Source:
-
maxVelocity :FM.Vector
-
Represent the maximum absolute value of the velocity.
Type:
- Inherited From:
- Source:
-
name :FM.ComponentTypes
-
Component's name.
Type:
- Inherited From:
- Source:
-
offset :FM.Vector
-
Offset of the bounding box or circle.
Type:
- Inherited From:
- Source:
-
owner :FM.GameObject
-
Component's owner.
Type:
- Inherited From:
- Source:
-
radius :int
-
Radius of the circle.
Type:
- int
-
velocity :FM.Vector
-
Velocity of the physic component.
Type:
- Inherited From:
- Source:
-
width :int
-
Width of the collider.
Type:
- int
- Inherited From:
- Source:
Methods
-
addCollision(pCollision)
-
Add a collision object representing the collision to the list of current collisions.
Parameters:
Name Type Description pCollision
FM.Collision The collision object to add. - Inherited From:
- Source:
-
addTypeToCollideWith(pType)
-
Ensure that a game object collides with a certain type of other game objects (with physic components of course).
Parameters:
Name Type Description pType
FM.ObjectType The type to add to the list of types that this object can collide with. - Inherited From:
- Source:
-
destroy()
-
Destroy the component and its objects.
-
drawDebug(bufferContext, newPosition)
-
Draw debug information.
Parameters:
Name Type Description bufferContext
CanvasRenderingContext2D Context on wich drawing is done. newPosition
FM.Vector Position of the sprite to render. -
getInvMass() → {int}
-
Retrieve the inverse mass of the physic object.
- Inherited From:
- Source:
Returns:
The inverse mass of this object.- Type
- int
-
getLinearVelocity() → {FM.Vector}
-
Get the velocity.
- Inherited From:
- Source:
Returns:
The vector containing the current velocity of the object.- Type
- FM.Vector
-
getMass() → {int}
-
Retrieve the mass of the physic object.
- Inherited From:
- Source:
Returns:
The mass of this object.- Type
- int
-
isCollidingWith(pOtherGameObject) → {boolean}
-
Check if the current physic component is colliding with another one.
Parameters:
Name Type Description pOtherGameObject
FM.GameObject The game object to test for collision with this one. - Inherited From:
- Source:
Returns:
Whether there is already collision between the physic components.- Type
- boolean
-
isCollidingWithType(pOtherType) → {boolean}
-
Check if the current physic component is colliding a specified type of physic component.
Parameters:
Name Type Description pOtherType
FM.ObjectType The type of objects to test for collision with this one. - Inherited From:
- Source:
Returns:
Whether there is already collision between the the current physic component and the specified type of physic component.- Type
- boolean
-
overlapsWithAabb(aabb) → {FM.Collision}
-
Check if the current circle is overlapping with the specified aabb.
Parameters:
Name Type Description aabb
FM.AabbComponent The aabb component that needs to be tested for overlap with the current circle component. Returns:
The collision object that contains the data of the collision if there is one, null otherwise.- Type
- FM.Collision
-
overlapsWithCircle(circle) → {FM.Collision}
-
Check if the current circle is overlapping with the specified circle.
Parameters:
Name Type Description circle
FM.CircleComponent The circle component that needs to be tested for overlap with the current circle component. Returns:
The collision object that contains the data of the collision if there is one, null otherwise.- Type
- FM.Collision
-
overlapsWithObject(pPhysic) → {FM.Collision}
-
Check if the current circle is overlapping with the specified physic object.
Parameters:
Name Type Description pPhysic
FM.PhysicComponent The physic component to test for overlap with the current one. Returns:
The collision object that contains the data of the collision if there is one, null otherwise.- Type
- FM.Collision
-
overlapsWithType(pType) → {FM.Collision}
-
Check if the current circle is overlapping with the specified type.
Parameters:
Name Type Description pType
FM.ObjectType The type to test for overlap with this circle component. Returns:
The collision object that contains the data of the collision if there is one, null otherwise.- Type
- FM.Collision
-
removeTypeToCollideWith(pType)
-
Remove a type that was supposed to collide with this game object.
Parameters:
Name Type Description pType
FM.ObjectType The type to remove from the list of types that this object can collide with. - Inherited From:
- Source:
-
resolveCollision(pOtherPhysic, pCollision)
-
Resolve collision between current game object and the specified one.
Parameters:
Name Type Description pOtherPhysic
FM.PhysicComponent The other physic component of the collision. pCollision
FM.Collision The collision object containing the data about the collision to resolve. - Inherited From:
- Source:
-
setMass(pNewMass)
-
Set the mass of the physic object.
Parameters:
Name Type Description pNewMass
int The new mass to set. - Inherited From:
- Source:
-
update(dt)
-
Update the component.
Parameters:
Name Type Description dt
float The fixed delta time since the last frame. - Inherited From:
- Source: