Base Shape Class. Acts as a Body's collider. Check out echo.shapes for all available shapes.

Static variables

staticread onlydefaults:ShapeOptions

Default Shape Options

Static methods

staticinlinecircle(?x:Float, ?y:Float, ?radius:Float, ?scale_x:Float, ?scale_y:Float):Circle

Gets a Circle from the Circle Classes' Object Pool. Shortcut for Circle.get().

Parameters:

x

The X position of the Circle

y

The Y position of the Circle

radius

The radius of the Circle

Returns:

Rect

staticget(options:ShapeOptions):Shape

Gets a Shape. If one is available, it will be grabbed from the Object Pool. Otherwise a new Shape will be created.

Parameters:

options

Returns:

Shape

staticinlinerect(?x:Float, ?y:Float, ?width:Float, ?height:Float, ?scale_x:Float, ?scale_y:Float):Rect

Gets a Rect from the Rect Classes' Object Pool. Shortcut for Rect.get().

Parameters:

x

The X position of the Rect

y

The Y position of the Rect

width

The width of the Rect

height

The height of the Rect

Returns:

Rect

staticinlinesquare(?x:Float, ?y:Float, ?width:Float):Rect

Gets a Rect with uniform width/height from the Rect Classes' Object Pool. Shortcut for Rect.get().

Parameters:

x

The X position of the Rect

y

The Y position of the Rect

width

The width of the Rect

Returns:

Rect

Variables

read onlybottom:Float

The Lower Bounds of the Shape.

collided:Bool

Flag to determine if the Shape has collided in the last World step. Used Internally for Debugging.

read onlyleft:Float

The Left Bounds of the Shape.

local_x:Float

The Shape's position on the X axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is treated as an offset to the Body's X position.

local_y:Float

The Shape's position on the Y axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is treated as an offset to the Body's Y position.

read onlyright:Float

The Right Bounds of the Shape.

rotation:Float

The Shape's angular rotation.

If added to a Body, this value is relative to the Body's rotation. To get the Shape's local rotation in this case, use local_rotation.

@:value(true)solid:Bool = true

Flag to set whether the Shape collides with other Shapes.

If false, this Shape's Body will not have its position or velocity affected by other Bodies, but it will still call collision callbacks

read onlytop:Float

The Upper Bounds of the Shape.

@:value(new Transform())transform:Transform = new Transform()

type:ShapeType

Enum value determining what shape this Object is (Rect, Circle, Polygon).

x:Float

The Shape's position on the X axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is relative to the Body's X position. To get the Shape's local X position in this case, use local_x.

y:Float

The Shape's position on the Y axis. For Rects, Circles, and simple Polygons, this position is based on the center of the Shape.

If added to a Body, this value is relative to the Body's Y position. To get the Shape's local Y position in this case, use local_y.

Methods

bounds(?aabb:AABB):AABB

Returns an AABB representing the bounds of the Shape.

Parameters:

aabb

Optional AABB to set the values to.

Returns:

AABB

clone():Shape

Clones the Shape into a new Shape

Returns:

Shape return new Shape(x, y)

inlineget_position():Vector2

Gets the Shape's position on the X and Y axis as a Vector2.

inlineset_position(position:Vector2):Void