polygon

inline fun BodyDefinition.polygon(vertices: FloatArray? = null, init: FixtureDefinition.(PolygonShape) -> Unit = {}): FixtureDefinition

Utility builder method for constructing fixtures with PolygonShape. Note that this method consumes a FloatArray instead of array of Vector2 instances, which might be less readable, but creates slightly less garbage. This method is advised to be used instead of the Vector2-consuming variant on mobile devices.

Return

FixtureDefinition with Fixture properties.

Parameters

vertices

optional. If given, will be converted to PolygonShape points. Each two adjacent numbers represent a point's X and Y.

init

inlined. Allows to modify FixtureDef properties. Receives PolygonShape as first (it) argument.

See also

PolygonShape.set

inline fun BodyDefinition.polygon(vararg vertices: Vector2, init: FixtureDefinition.(PolygonShape) -> Unit = {}): FixtureDefinition

Utility builder method for constructing fixtures with PolygonShape.

Return

FixtureDefinition with Fixture properties.

Parameters

vertices

will be converted to PolygonShape points.

init

inlined. Allows to modify FixtureDef properties. Receives PolygonShape as first (it) argument.

See also

PolygonShape.set

inline fun Body.polygon(vertices: FloatArray? = null, init: FixtureDefinition.(PolygonShape) -> Unit = {}): Fixture

Utility builder method for constructing fixtures with PolygonShape. Note that this method consumes a FloatArray instead of array of Vector2 instances, which might be less readable, but creates slightly less garbage. This method is advised to be used instead of the Vector2-consuming variant on mobile devices.

Return

a fully constructed Fixture with PolygonShape.

Parameters

vertices

optional. If given, will be converted to PolygonShape points. Each two adjacent numbers represent a point's X and Y.

init

inlined. Allows to modify FixtureDef properties. Receives PolygonShape as first (it) argument.

See also

PolygonShape.set

inline fun Body.polygon(vararg vertices: Vector2, init: FixtureDefinition.(PolygonShape) -> Unit = {}): Fixture

Utility builder method for constructing fixtures with PolygonShape.

Return

a fully constructed Fixture with PolygonShape.

Parameters

vertices

will be converted to PolygonShape points.

init

inlined. Allows to modify FixtureDef properties. Receives PolygonShape as first (it) argument.

See also

PolygonShape.set