Libraries.Game.Collision.Shapes.CollisionShape2D Documentation

This class includes the features for all of the 2D shapes that could be used to determine collision with other 2D shapes. Please see the Circle and the Polygon class for the implementation of the blueprints in this class.

Inherits from: Libraries.Language.Object

Variables Table

VariablesDescription
integer CIRCLE
integer CHAINthe default type is POLYGON
integer POLYGON
integer EDGE

Actions Documentation

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)

ComputeArea()

This action finds the area of a CollisionShape2D.

Return

number:

ComputeBoundingBox(Libraries.Game.Collision.BoundingBox2D boundingBox, Libraries.Game.Collision.PhysicsPosition2D transform, integer childIndex)

When you pass in the location of the 2D object (PhysicsPosition2D transform), this action will help you return what the bounding box "BoundingBox2D boundingBox" will look like for the shape's child #"integer childIndex".

Parameters

ComputeDistance(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 point, integer childIndex, Libraries.Compute.Vector2 normalOut)

This action finds the distance of a point relative to the edge of the shape.

Parameters

Return

number:

ComputeMass(Libraries.Game.Physics.Mass2D mass, number density)

This action finds the mass of a 2D object based on the shape of the object and the design of the object.

Parameters

Copy()

This action returns a copy of this CollisionShape2D.

Return

Libraries.Game.Collision.Shapes.CollisionShape2D:

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)

GetChildCount()

Child Shape: a more primitive shape (circle, rectangle, edge) that makes up this shape.

Return

integer:

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

GetRadius()

This action returns the radius of the shape.

Return

number:

GetType()

This action gets the type of the shape that is used to collide with another 2D shape.

Return

integer:

Scale(number scaleX, number scaleY)

This action scales the CollisionShape2D in both x and y directions for polygons and scales the a circle uniformly.

Parameters

  • number scaleX: How much you want to squeeze the circle or polygon in x direction.
  • number scaleY: How much you want to squeeze the polygon in the y direction.

SetRadius(number radius)

This action sets the radius of the shape.

Parameters

  • number radius

SetType(integer type)

This action sets the type of the shape that will be used to collide with another 2D shape.

Parameters

  • integer type

TestPoint(Libraries.Game.Collision.PhysicsPosition2D transform, Libraries.Compute.Vector2 point)

For convex shapes, this will see if the "Vector2 point," in global coordiantes, that you passed in is a point inside that convex shape.

Parameters

Return

boolean: