LocalCollisionPoints2D
Package: Libraries.Game.Collision · Inherits from: Libraries.Language.Object
This class records the all of the local collision points during one collision using the array called "points," from the perspective of one of the 2D object that is involved in the collision. This 2D object will be called as a reference object (because all of the local collision points are recorded from the perspective of that 2D object). Collision points will be evaluated when a CollisionEvent2D occurs, where the CollisionEvent2D uses the narrow phase evaluation to calculate where the collision points that are relative to the reference object (defined above). This class is also known as manifolds. This class is used by GlobalCollisionPoints2D.
Variables
integer type: This is the number of CollisionPoint2D objects that is inside the array named "points." 1 indicates that the collision caused a point contact, and 2 indicates that the collision caused a line contact.integer MAX_COLLISION_POINTSinteger FACE_A: the reference object will be selected as circleAinteger pointCount: This is the number of CollisionPoint2D objects that is inside the array named "points." 1 indicates that the collision caused a point contact, and 2 indicates that the collision caused a line contact.integer CIRCLES: the reference object will be selected as circleAinteger FACE_B: in a circle-polygon collision, the polygon will be selected as the reference object
Actions
GetLocalNormal()
This action returns the actual direction (with respect to the reference object) at which you should apply the normal impulse to the objects to separate the objects. In the case where the reference object is a circle (circleA), localNormal can't be used. In the case where the reference object is a polygon, localNormal would be the direction of normal impulse in reference to that polygon pointing away from the polygon.
Returns
Libraries.Compute.Vector2: the direction that you should apply the normal impulse to the objects to separate the objects.
GetLocalPoint()
This action returns the estimated point of contact. In the case where the reference object is a circle, this would be the local center of circleA. In the case where the reference object is a polygon, this would be the local center of that polygon.
Returns
Libraries.Compute.Vector2: the estimated point of contact.
GetPointCount()
This action returns how many collision points there is between two objects. 1 indicates that the collision caused a point contact, and 2 indicates that the collision caused a line contact.
Returns
integer: how many collision points there is between two objects.
GetPoints()
This action returns all of the collision points stored inside this LocalCollisionPoints2D from the point of view of the reference object that is involved in the collision. The amount of items in the returning array tells you whether the contact is a line (2 CollisionPoint2D) or just a point (1 CollisionPoint2D object in the array).
Returns
Libraries.Containers.Array<Libraries.Game.Collision.CollisionPoint2D>: all of the collision points stored inside this LocalCollisionPoints2D.
GetType()
This action returns the type of the collision. Here are possible types in a code box for better viewing:
Returns
integer
Example
CIRCLES = 0 //when two circles collide, both 2D objects are going to be circles
//the reference object will be selected as circleA
FACE_A = 1 //when circle collide with polygon -OR- polygon collide with polygon
//the "type" of the LocalCollisionPoints2D is selected as FACE_A when A is the reference polygon
//in a circle-polygon collision, the polygon will be selected as the reference object
FACE_B = 2 //when polygon collides with polygon
//the "type" of the LocalCollisionPoints2D is selected as FACE_B when B is the reference polygon
Set(Libraries.Game.Collision.LocalCollisionPoints2D other)
This action sets the current LocalCollisionPoints2D with another LocalCollisionPoints2D.
Parameters
otherLibraries.Game.Collision.LocalCollisionPoints2D: The other LocalCollisionPoints2D to copy from.
SetLocalNormal(Libraries.Compute.Vector2 normal)
This action sets the direction that you should apply the normal impulse to the objects to separate the objects.
Parameters
normalLibraries.Compute.Vector2: The direction that you should apply the normal impulse to the objects to separate the objects.
SetLocalPoint(Libraries.Compute.Vector2 point)
This action sets the estimated point of contact.
Parameters
pointLibraries.Compute.Vector2: The estimated point of contact.
SetPointCount(integer count)
This action sets how many collision points there is between two objects.
Parameters
countinteger: How many collision points there is between two objects.
SetType(integer type)
This action sets the type of collision.
Parameters
typeinteger: The type of collision.