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
Summary
Actions Summary Table
Actions | Description |
---|---|
AddCollisionListener(Libraries.Interface.Events.CollisionListener2D listener) | This action adds a CollisionListener2D to the current CollisionManager2D. |
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. |
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. |
Destroy(Libraries.Interface.Events.CollisionEvent2D collision) | This action tests deletes a CollisionEvent2D in a doubly linked list of CollisionEvent2D. |
Equals(Libraries.Language.Object object) | This action determines if two objects are equal based on their hash code values. |
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. |
GetCollisionCount() | This class returns how many CollisionEvent2D are available in this CollisionManager2D. |
GetCollisionList() | This action returns 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. |
GetHashCode() | This action gets the hash code for an object. |
RemoveCollisionListener(Libraries.Interface.Events.CollisionListener2D listener) | This action removes a CollisionListener2D from the current CollisionManager2D. |
SetLayer(Libraries.Game.Layer2D layer) | This action sets the 2D layer at which the objects lie on. |
Actions Documentation
AddCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)
This action adds a CollisionListener2D to the current CollisionManager2D.
Parameters
- Libraries.Interface.Events.CollisionListener2D: The CollisionListener2D to be added to the current CollisionManager2D.
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
- Libraries.Game.Collision.Item2DNode: The first node.
- Libraries.Game.Collision.Item2DNode: The second node.
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.
Example Code
Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
Parameters
- Libraries.Language.Object: The object to compare to.
Return
integer: The Compare result, Smaller, Equal, or Larger.
Destroy(Libraries.Interface.Events.CollisionEvent2D collision)
This action tests deletes a CollisionEvent2D in a doubly linked list of CollisionEvent2D.
Parameters
- Libraries.Interface.Events.CollisionEvent2D: The CollisionEvent2D to be deleted.
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their hash code values.
Example Code
use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)
Parameters
- Libraries.Language.Object: The to be compared.
Return
boolean: True if the hash codes are equal and false if they are not equal.
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.
Example Code
use Libraries.Game.Collision.BroadphaseCollision2D
use Libraries.Game.Collision.CollisionManager2D
BroadphaseCollision2D broadphase
CollisionManager2D collision
broadphase = collision:GetBroadphase()
Return
Libraries.Game.Collision.BroadphaseCollision2D: The BroadphaseCollision2D that is used to solve a collision.
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.
Example Code
Object o
integer hash = o:GetHashCode()
Return
integer: The integer hash code of the object.
RemoveCollisionListener(Libraries.Interface.Events.CollisionListener2D listener)
This action removes a CollisionListener2D from the current CollisionManager2D.
Parameters
- Libraries.Interface.Events.CollisionListener2D: The CollisionListener2D to be removed from the current CollisionManager2D.
SetLayer(Libraries.Game.Layer2D layer)
This action sets the 2D layer at which the objects lie on.
Parameters
- Libraries.Game.Layer2D: The 2D layer at which the objects lie on.