AddBoxShape
From OxeyeWiki
(Difference between revisions)
Jeb (Talk | contribs)
(Created page with '{{PhysicsMethod| physics:addBoxShape(entityId, shapeDefinition) | Adds a box shape to an entity's body. | {{MethodParam|entityId|An integer|The entity's body identifier, which is...')
(Created page with '{{PhysicsMethod| physics:addBoxShape(entityId, shapeDefinition) | Adds a box shape to an entity's body. | {{MethodParam|entityId|An integer|The entity's body identifier, which is...')
Latest revision as of 12:27, 7 February 2010
physics:addBoxShape(entityId, shapeDefinition) | ||
Adds a box shape to an entity's body. | ||
Parameter | Expected Type | Description |
entityId | An integer | The entity's body identifier, which is returned from the createEntity method. |
bodyDefinition | A table | The body definition table, see below. |
Returns | ||
Returns true if the shape was added successfully. |
Shape Definition Table
The shape definition table holds shape settings. In addition to the box settings, all shapes have the Common Shape Settings too.
Parameter | Expected Type | Description |
x | A number | The centrum X coordinate of the box, in relation to the body's X coordinate. Measured in meters. Defaults to 0 (centered on the body). |
y | A number | The centrum Y coordinate of the box, in relation to the body's Y coordinate. Measured in meters. Defaults to 0 (centered on the body). |
width | A number | The width of the box, measured in meters. Defaults to 1. |
height | A number | The height of the box, measured in meters. Defaults to 1. |
angle | A number | The rotation of the box, measured in radians. Note that this is the fixed rotaion of the shape. It can't be changed later, since setEntityAngle rotates the whole body and not individual shapes. Defaults to 0. |
Example
local playerShapeDef = { x = 0, x = 0, width = 32 * physResolution, height = 64 * physResolution, density = 1.5, filterGroup = player.body, friction = .01, } physics:addBoxShape(player.body, playerShapeDef)