Skip to main content

Shape

Description:

  Shapes are solid 2d geometrical objects which handle the mass and collision of a Body in love.physics.

type

Type: Function.

Description:

  Gets the type of the object as a string.

Signature:

type: function(self: Shape): string

Returns:

Return TypeDescription
stringThe type as a string.

Of

Type: Function.

Description:

  Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.

Signature:

typeOf: function(self: Shape, type_name: string): boolean

Parameters:

ParameterTypeDescription
type_namestringThe name of the type to check for.

Returns:

Return TypeDescription
booleanTrue if the object is of the specified type, false otherwise.

release

Type: Function.

Description:

  Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector.

Signature:

release: function(self: Shape): boolean

Returns:

Return TypeDescription
booleanTrue if the object was released by this call, false if it had been previously released.

getType

Type: Function.

Description:

  Gets a string representing the Shape. This function can be useful for conditional debug drawing.

Signature:

getType: function(self: Shape): string

Returns:

Return TypeDescription
stringThe type of the Shape.

getRadius

Type: Function.

Description:

  Gets the radius of the shape.

Signature:

getRadius: function(self: Shape): number
getPoints: function(self: Shape): number...
validate: function(self: Shape): boolean
getVertexCount: function(self: Shape): integer
getPoint: function(self: Shape, index: integer): number, number
getChildEdge: function(self: Shape, index: integer): Shape
getPreviousVertex: function(self: Shape): number | nil, number | nil
getNextVertex: function(self: Shape): number | nil, number | nil
setPreviousVertex: function(self: Shape, x?: number, y?: number)
setNextVertex: function(self: Shape, x?: number, y?: number)

Parameters:

ParameterTypeDescription
indexintegerThe index parameter.
xnumberThe x parameter.
ynumberThe y parameter.

Returns:

Return TypeDescription
number or number... or boolean or integer or Shape or number or nilThe radius of the shape.