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

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

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.

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.

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.

Equals(Libraries.Language.Object object)

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

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)
``````

integer

integer

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

GetNodeA()

let p2 be the most current evaluation of collisionPoints

GetNodeB()

calculate the new "collisionPoints"

GetPrevious()

local collision points

number

number

number

GetTimeOfImpactCount()

this would be the incident polygon

integer:

HasPhysicsResponse()

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

boolean:

InCollisionGroup()

when the circles are NOT colliding, return

boolean:

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

True when the shapes are touching.

IsEnabled()

The first item involved in the collision.

boolean:

IsTouching()

you have to specify which "child" of itemA it is.

boolean:

SetEnabled(boolean enabled)

The second item involved in the collision.

Parameters

• boolean enabled

SetFriction(number friction)

Parameters

• number friction

SetHasPhysicsResponse(boolean flag)

False when the user doesn't want to count this as an collision.

• boolean flag

SetInCollisionGroup(boolean flag)

This action finds the collision point on the incident edge.

• boolean flag

SetNext(Libraries.Interface.Events.CollisionEvent2D event)

you have to specify which "child" of itemB it is.

SetPrevious(Libraries.Interface.Events.CollisionEvent2D event)

other way around, so flip them here

SetRestitution(number restitution)

Parameters

• number restitution

• number speed

SetTimeOfImpact(number toi)

this would be the reference polygon

• number toi

SetTimeOfImpactCount(integer count)

this stores the index of the reference edge

Parameters

• integer count

SetTimeOfImpactSolved(boolean flag)

A becomes the indicent polygon

• boolean flag

TimeOfImpactSolved()

B becomes the reference polygon

boolean: