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
Variables | Description |
---|---|
number EPSILON | A 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
- Libraries.Containers.Array
- Libraries.Containers.Array
- Libraries.Compute.Vector2
- number offset
- integer vertexIndexA
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
- Libraries.Language.Object: The object to compare to.
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
- Libraries.Language.Object: The to be compared.
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
GetCollisionPoints()
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()
GetItemA()
GetItemB()
GetNext()
this assumes that each item is made up of one shape
Return
GetNodeA()
let p2 be the most current evaluation of collisionPoints
Return
GetNodeB()
GetPrevious()
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
- Libraries.Interface.Item2D
- integer indexA
- Libraries.Interface.Item2D
- integer indexB
IsEnabled()
The first item involved in the collision.
Return
boolean:
IsTouching()
you have to specify which "child" of itemA it is.
Return
boolean:
ResetFriction()
ResetRestitution()
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.
Parameters
- boolean flag
SetInCollisionGroup(boolean flag)
This action finds the collision point on the incident edge.
Parameters
- boolean flag
SetNext(Libraries.Interface.Events.CollisionEvent2D event)
you have to specify which "child" of itemB it is.
Parameters
SetPrevious(Libraries.Interface.Events.CollisionEvent2D event)
SetRestitution(number restitution)
Parameters
- number restitution
SetTangentSpeed(number speed)
Parameters
- number speed
SetTimeOfImpact(number toi)
this would be the reference polygon
Parameters
- number toi
SetTimeOfImpactCount(integer count)
this stores the index of the reference edge
Parameters
- integer count
SetTimeOfImpactSolved(boolean flag)
A becomes the indicent polygon
Parameters
- boolean flag
TimeOfImpactSolved()
B becomes the reference polygon
Return
boolean:
On this page
Variables TableAction Documentation- CalculateTotalFriction(number friction1, number friction2)
- CalculateTotalRestitution(number restitution1, number restitution2)
- ClipSegmentToLine(Libraries.Containers.Array
vOut, Libraries.Containers.Array vIn, Libraries.Compute.Vector2 normal, number offset, integer vertexIndexA) - Compare(Libraries.Language.Object object)
- DispatchCollision(Libraries.Containers.Array
listeners) - Equals(Libraries.Language.Object object)
- GetChildIndexA()
- GetChildIndexB()
- GetCollisionPoints()
- GetFriction()
- GetHashCode()
- GetItemA()
- GetItemB()
- GetNext()
- GetNodeA()
- GetNodeB()
- GetPrevious()
- GetRestitution()
- GetTangentSpeed()
- GetTimeOfImpact()
- GetTimeOfImpactCount()
- HasPhysicsResponse()
- InCollisionGroup()
- Initialize(Libraries.Interface.Item2D itemA, integer indexA, Libraries.Interface.Item2D itemB, integer indexB)
- IsEnabled()
- IsTouching()
- ResetFriction()
- ResetRestitution()
- SetEnabled(boolean enabled)
- SetFriction(number friction)
- SetHasPhysicsResponse(boolean flag)
- SetInCollisionGroup(boolean flag)
- SetNext(Libraries.Interface.Events.CollisionEvent2D event)
- SetPrevious(Libraries.Interface.Events.CollisionEvent2D event)
- SetRestitution(number restitution)
- SetTangentSpeed(number speed)
- SetTimeOfImpact(number toi)
- SetTimeOfImpactCount(integer count)
- SetTimeOfImpactSolved(boolean flag)
- TimeOfImpactSolved()