Libraries.Game.Collision.CollisionManager2D Documentation

This class can be seen as a "manager" class that uses CollisionEvent2D class and the BoardphaseCollision2D class to record if a collision occured, to decide if a collision occured. This class uses the CollisionEvent2D to record all of the collision that has occured during the current physics step. This class also uses the BroadphaseCollision2D class to determine whether a possible collision has happened.

Inherits from: Libraries.Language.Object

Actions Documentation

AddCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)

This action adds a CollisionListener2D to the current CollisionManager2D.

Parameters

AddPair(Libraries.Game.Collision.Item2DNode nodeA, Libraries.Game.Collision.Item2DNode nodeB)

This action compares the two nodes in the DynamicBoundingVolumeTree2D to determine whether the items in the two nodes collide. If the items in the two nodes do collide, then the collision will be recorded inside this CollisionManager2D.

Parameters

Collide()

This action resolve every collision that is recorded in the CollisionEvent2D doubly linked list.

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)

Destroy(Libraries.Interface.Events.CollisionEvent2D collision)

This action tests deletes a CollisionEvent2D in a doubly linked list of CollisionEvent2D.

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)

FindNewCollisions()

This action uses the broadphase linked to this CollisionManager2D to test if two nodes are colliding.

GetBroadphase()

This action returns the BroadphaseCollison2D that is used to solve a collision.

Return

Libraries.Game.Collision.BroadphaseCollision2D: The BroadphaseCollision2D that is used to solve a collision.

Example

use Libraries.Game.Collision.BroadphaseCollision2D
use Libraries.Game.Collision.CollisionManager2D

    BroadphaseCollision2D broadphase
    CollisionManager2D collision

    broadphase = collision:GetBroadphase()

GetCollisionCount()

This class returns how many CollisionEvent2D are available in this CollisionManager2D.

Return

integer: how many CollisionEvent2D are available in this CollisionManager2D.

GetCollisionList()

This action returns the first event in the doubly linked list of CollisionEvent2D.

Return

Libraries.Interface.Events.CollisionEvent2D: the first event in the doubly linked list of CollisionEvent2D.

GetCollisionListeners()

This action returns all of the CollisionListen2D that is attached to the current CollisionManager2D through an array.

Return

Libraries.Containers.Array: all of the CollisionListen2D that is attached to the current CollisionManager2D through an array.

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

RemoveCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)

This action removes a CollisionListener2D from the current CollisionManager2D.

Parameters

SetLayer(Libraries.Game.Layer2D layer)

This action sets the 2D layer at which the objects lie on.

Parameters