Difference between revisions of "love.physics.newPolygonBody"

(Created page)
 
 
Line 10: Line 10:
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
body = love.physics.newPolygonBody( type, x1, y1, x2, y2, x3, y3, ... )
+
body = love.physics.newPolygonBody( world, type, x1, y1, x2, y2, x3, y3, ... )
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
 +
{{param|World|world|The world to create the body in.}}
 
{{param|BodyType|type|The type of the body.}}
 
{{param|BodyType|type|The type of the body.}}
 
{{param|number|x1|The x position of the first point, in world space.}}
 
{{param|number|x1|The x position of the first point, in world space.}}
Line 22: Line 23:
 
{{param|number|...|You can continue passing more point positions to create the object.}}
 
{{param|number|...|You can continue passing more point positions to create the object.}}
 
=== Returns ===
 
=== Returns ===
{{param|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.}}
+
{{param|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 ==
 
== Function ==

Latest revision as of 21:27, 3 August 2024

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