Class: PhysicComponent

PhysicComponent

FM.PhysicComponent

new PhysicComponent(pWidth, pHeight, pOwner)

Parent component of physics components to add to a game object for collisions and physics behavior.
Parameters:
Name Type Description
pWidth int Width of the collider.
pHeight int Height of the collider.
pOwner FM.GameObject The object that owns this component.
Author:
  • Simon Chauvin
Source:

Extends

Members

acceleration :FM.Vector

Acceleration applied to the physic object.
Type:
Source:

angularDrag :FM.Vector

How much the object's velocity is decreasing when acceleration is equal to 0.
Type:
Source:

angularVelocity :int

Angular velocity.
Type:
  • int
Source:

drag :FM.Vector

How much the object's velocity is decreasing when acceleration is equal to 0.
Type:
Source:

elasticity :float

Elasticity is a factor between 0 and 1 used for bouncing purposes.
Type:
  • float
Source:

height :int

Height of the collider.
Type:
  • int
Source:

maxAngularVelocity :int

Maximum angular velocity.
Type:
  • int
Source:

maxVelocity :FM.Vector

Represent the maximum absolute value of the velocity.
Type:
Source:

name :FM.ComponentTypes

Component's name.
Type:
Inherited From:
Source:

offset :FM.Vector

Offset of the bounding box or circle.
Type:
Source:

owner :FM.GameObject

Component's owner.
Type:
Inherited From:
Source:

velocity :FM.Vector

Velocity of the physic component.
Type:
Source:

width :int

Width of the collider.
Type:
  • int
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.
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.
Source:

destroy()

Destroy the component and its objects.
Source:

getInvMass() → {int}

Retrieve the inverse mass of the physic object.
Source:
Returns:
The inverse mass of this object.
Type
int

getLinearVelocity() → {FM.Vector}

Get the velocity.
Source:
Returns:
The vector containing the current velocity of the object.
Type
FM.Vector

getMass() → {int}

Retrieve the mass of the physic object.
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.
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.
Source:
Returns:
Whether there is already collision between the the current physic component and the specified type of physic component.
Type
boolean

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.
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.
Source:

setMass(pNewMass)

Set the mass of the physic object.
Parameters:
Name Type Description
pNewMass int The new mass to set.
Source:

update(dt)

Update the component.
Parameters:
Name Type Description
dt float The fixed delta time since the last frame.
Source: