Physics.P2#createBody()

createBody(x, y, mass, addToWorld, options, points) → {Phaser.Physics.P2.Body}

Creates a new Body and adds it to the World.

Parameters
Name Type Argument Default Description
x number

The x coordinate of Body.

y number

The y coordinate of Body.

mass number

The mass of the Body. A mass of 0 means a 'static' Body is created.

addToWorld boolean <optional>
false

Automatically add this Body to the world? (usually false as it won't have any shapes on construction).

options object

An object containing the build options:

Properties
Name Type Argument Default Description
optimalDecomp boolean <optional>
false

Set to true if you need optimal decomposition. Warning: very slow for polygons with more than 10 vertices.

skipSimpleCheck boolean <optional>
false

Set to true if you already know that the path is not intersecting itself.

removeCollinearPoints boolean | number <optional>
false

Set to a number (angle threshold value) to remove collinear points, or false to keep all points.

points Array.<number> | number

An array of 2d vectors that form the convex or concave polygon.
Either [[0,0], [0,1],...] or a flat array of numbers that will be interpreted as [x,y, x,y, ...],
or the arguments passed can be flat x,y values e.g. setPolygon(options, x,y, x,y, x,y, ...) where x and y are numbers.

Returns
Source code: physics/p2/World.js (Line 1542)
doc_phaser
2017-02-14 11:00:55
Comments
Leave a Comment

Please login to continue.