class Shape
package nape.shape
extends Interactor
extended by Circle, Polygon
Available with nape plugin
Base type for Nape Shape's
Static variables
Variables
body:Null<Body>
Body this Shape is assigned to.
This value can be set to add Shape to the given Body, and set to null
to remove it from its present Body.
read onlyworldCOM:Vec2
World space centre of mass of this Shape.
This value can be accessed even if Shape is not in a Body, but
attempting to query the values of it will return an error in debug
builds unless the Shape is in a Body.
This Vec2 is immutable.
localCOM:Vec2
Local space centre of mass of this Shape.
This Vec2 can be set and is equivalent to performing the necessary
translation of the Shape in local coordinates, and also equivalent
to this.localCOM.set(value)
.
Setting this value whilst this shape is part of a static Body that
is part of a Space is not permitted.
fluidProperties:FluidProperties
FluidProperties used by this shape.
This object provides information for buoyancy and fluid drag computations
when this shape is interacting as a fluid.
fluidEnabled:Bool
Whether this shape is able to interact as a fluid.
Unless this field is true, this Shape can never interact as a fluid.
Just because this field is true however, does not mean this shape will always
interact as a fluid, the final result is down to the combination of
InteractionFilters on the pairing of shapes and sensory interaction
takes higher priority.
sensorEnabled:Bool
Whether this shape is able to interact as sensor.
Unless this field is true, this Shape can never interact as a sensor.
Just because this field is true however, does not mean this shape will always
interact as a sensor, the final result is down to the combination of
InteractionFilters on the pairing of shapes. Sensor interaction has highest priority.
Methods
inlineisCircle():Bool
Faster equivalent to type == ShapeType.CIRCLE
Returns:
True if shape is a Circle type.
inlineisPolygon():Bool
Faster equivalent to type == ShapeType.POLYGON
Returns:
True if shape is a Polygon type.
translate(translation:Vec2):Shape
Translate this shape in its local coordinate system.
This is equivalent to: shape.localCOM.addeq(displacement)
Parameters:
translation | The local translation to apply to Shape. |
---|
Returns:
A reference to 'this' Shape.
Throws:
# | If translation is null or has been disposed of. |
---|---|
# | If this shape is part of a static body that is inside of a Space. |
scale(scalex:Float, scaley:Float):Shape
Scale this shape in its local coordinate system.
For Circle shapes, scalex and scaley must be exactly equal.
Parameters:
scalex | The x-coordinate scaling to apply to Shape. |
---|---|
scaley | The y-coordinate scaling to apply to Shape. |
Returns:
A reference to 'this' Shape.
Throws:
# | If this shape is part of a static body that is inside of a Space. |
---|---|
# | If scalex or scaley is 0. Negative values 'are' permitted. |
rotate(angle:Float):Shape
Rotate this shape in its local coordinate system.
Parameters:
angle | The number of radians to rotate this Shape by in a clockwise direction. |
---|
Returns:
A reference to 'this' Shape.
Throws:
# | If this shape is part of a static body that is inside of a Space. |
---|
transform(matrix:Mat23):Shape
Apply local transformation matrix to Shape.
For Circle shapes, the matrix must be equiorthogonal.
Parameters:
matrix | The matrix to transform Shape by. |
---|
Returns:
A reference to 'this' Shape.
Throws:
# | If matrix is null or singular. |
---|---|
# | If shape is a Circle, and matrix is not equiorthogonal. |
# | If this shape is part of a static body that is inside of a Space. |
contains(point:Vec2):Bool
Test containment of world-space coordinate in Shape.
This Shape must be part of a Body so that world coordinates are
defined.
Parameters:
point | The point to check for containment. |
---|
Returns:
True if point is contained within the Shape.
Throws:
If | point is null or disposed of. |
---|---|
If | this shape is not part of a Body. |