Libraries.Interface.Events.CollisionEvent2D Documentation

This class is used to represent collision between two 2D items. One CollisionEvent2D corresponds to one collision between the two items. This class also has a doubly linked list structure which allows you to access all of the collision events that has happened. This doubly linked list encompasses the collision that happened in the whole "world" of a certain game.

Inherits from: Libraries.Language.Object

Variables Table

VariablesDescription
number EPSILONA floating point value that is very close to zero.

Actions Documentation

CalculateTotalFriction(number friction1, number friction2)

This action estimates the friction between the surface of the two 2D objects using friction mixing law such that if one object is frictionless then the surface between the two objects will have 0 friction as well.

Parameters

  • number friction1
  • number friction2

Return

number:

CalculateTotalRestitution(number restitution1, number restitution2)

This action estimates the restitution between the surface of the two 2D objects using restitution mixing law such that if one object is inelastic, then the other object will bounce off the inelastic object easily.

Parameters

  • number restitution1
  • number restitution2

Return

number:

ClipSegmentToLine(Libraries.Containers.Array<Libraries.Game.Collision.ClipVertex2D> vOut, Libraries.Containers.Array<Libraries.Game.Collision.ClipVertex2D> vIn, Libraries.Compute.Vector2 normal, number offset, integer vertexIndexA)

This action finds the collision point on the incident edge.

Parameters

Return

integer:

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

DispatchCollision(Libraries.Containers.Array<Libraries.Interface.Events.CollisionListener2D> listeners)

This action calculates if the collision has started or if the collision has been resolved. Using a CollisionListener, the user can change what would the responses of the system (ex. audio playback) and the objects be when the collision has begun or when the collision has ended.

Parameters

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetChildIndexA()

Return

integer

GetChildIndexB()

Return

integer

GetFriction()

Return

number

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetNext()

this assumes that each item is made up of one shape

Return

Libraries.Interface.Events.CollisionEvent2D:

GetNodeA()

let p2 be the most current evaluation of collisionPoints

Return

Libraries.Game.Collision.CollisionEdge2D:

GetNodeB()

calculate the new "collisionPoints"

Return

Libraries.Game.Collision.CollisionEdge2D:

GetPrevious()

local collision points

Return

Libraries.Interface.Events.CollisionEvent2D:

GetRestitution()

Return

number

GetTangentSpeed()

Return

number

GetTimeOfImpact()

Return

number

GetTimeOfImpactCount()

this would be the incident polygon

Return

integer:

HasPhysicsResponse()

The starting point of the doubly linked list of collisions on the second item that is involved in the collision.

Return

boolean:

InCollisionGroup()

when the circles are NOT colliding, return

Return

boolean:

Initialize(Libraries.Interface.Item2D itemA, integer indexA, Libraries.Interface.Item2D itemB, integer indexB)

True when the shapes are touching.

Parameters

IsEnabled()

The first item involved in the collision.

Return

boolean: