love.physics.newPolygonBody

Available since LÖVE 12.0
This function is not supported in earlier versions.

Creates a new Body with an attached PolygonShape.

This is a convenience constructor which effectively calls love.physics.newBody and love.physics.newPolygonShape.


The shape can have 8 vertices at most, and must be convex.

Function

Synopsis

body = love.physics.newPolygonBody( world, type, x1, y1, x2, y2, x3, y3, ... )

Arguments

World world
The world to create the body in.
BodyType type
The type of the body.
number x1
The x position of the first point, in world space.
number y1
The y position of the first point, in world space.
number x2
The x position of the second point, in world space.
number y2
The y position of the second point, in world space.
number x3
The x position of the third point, in world space.
number y3
The y position of the third point, in world space.
number ...
You can continue passing more point positions to create the object.

Returns

Body body
The new Body with an attached PolygonShape. The body's world position is computed based on the geometric center of the given vertices, and the created shape's local origin is at that center point.

Function

Synopsis

body = love.physics.newPolygonBody( type, vertices )

Arguments

BodyType type
The type of the body.
table vertices
A list of vertices to construct the polygon, in the form of {x1, y1, x2, y2, x3, y3, ...}.

Returns

Body body
The new Body with an attached PolygonShape. The body's world position is computed based on the geometric center of the given vertices, and the created shape's local origin is at that center point.

See Also


Other Languages