Category:Physics Engine/Shapes
Shapes contain the surface properties of an object such as how much friction or elasticity it has. All collision shapes implement the following accessor routines.
Contents
BB
bb = physics.Shape:BB()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
bb | in physics.BB | Bounding box of the Shape |
Returns the bounding box of the shape.
Introduced in platform.apiLevel = '2.0'
body
body = physics.Shape:body()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
body | out physics.Body | The Body associated with the Shape |
Returns the body attached to the shape. If the shape is static, then it will return nil.
Introduced in platform.apiLevel = '2.0'
collisionType
coll = physics.Shape:collisionType()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
coll | out number | The programmer-assigned integer collision type |
Returns the integer collision type of the Shape.
Introduced in platform.apiLevel = '2.0'
data
obj = physics.Shape:data()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
obj | out Lua object | The programmer-assigned data object assigned to this Shape |
Returns the contents of the programmer data field of the Shape.
Introducted in platform.apiLevel = '2.0'
friction
f = physics.Shape:friction()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
f | out number | The coefficient of friction for this Shape |
Returns the friction coefficient of the shape.
Introduced in platform.apiLevel = '2.0'
group
g = physics.Shape:group()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
g | out number | The assigned group number |
Returns the group number of the shape.
The group number is converted to a positive whole number when stored.
NOTE |
Introduced in platform.apiLevel = '2.0'
layers
layers = physics.Shape:layers()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
layers | out number | A bitmap of the layers this shape occupies |
Returns the bitmap of layers the shape occupies.
Introduced in platform.apiLevel = '2.0'
rawBB
bb = physics.Shape:rawBB()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
bb | out physics.BB | The bounding box of the Shape |
Returns the bounding box of the shape. Only valid after a call to physics.Shape:BB() or physics.Space:step().
Introduced in platform.apiLevel = '2.0'
restitution
r = physics.Shape:restitution()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
r | out number | The restitution of the Shape |
Returns the restitution (or elasticity) of the shape.
Introduced in platform.apiLevel = '2.0'
sensor
s = physics.Shape:sensor()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
s | out boolean | True if the Shape is a sensor |
Returns true if the shape is a sensor.
Introduced in platform.apiLevel = '2.0'
setCollisionType
self = physics.Shape:setCollisionType(collisionType)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
collisionType | in number | Programmer-defined type of collision |
self | out physics.Shape | The input Shape is returned as the output |
Assigns a collision type (an integer value of your choosing) to the shape. It is used to determine which handler to call when a collision occurs. Returns self.
Introduced in platform.apiLevel = '2.0'
setData
self = physics.Shape:setData(obj)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
obj | in Lua object | An object defined by the programmer |
self | out physics.Shape | The input Shape is returned as the output |
Sets the programmer data field of the Shape. The programmer can store any Lua object in this field. Returns self.
Introduced in platform.apiLevel = '2.0'
setFriction
self = physics.Shape:setFriction(f)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
f | in number | Coefficient of friction for the surface of the Shape |
self | out physics.Shape | The input Shape is returned as the output |
Sets the friction coefficient for the shape. Returns self.
May not behave as expected for f larger than 1.0 or less than 0.
NOTE |
Introduced in platform.apiLevel = '2.0'
setGroup
self = physics.Shape:setGroup(group)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
group | in number | Group number |
self | out physics.Shape | The input Shape is returned as the output |
Sets the group (a number defined by the programmer) of the shape. Shapes in the same group do not generate collisions. Returns self.
The group number is converted to a positive whole number when stored.
NOTE |
Introduced in platform.apiLevel = '2.0'
setLayers
self = physics.Shape:setLayers(layers)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
layers | in number | A bitmap of integer layer numbers. This implementation permits 32 layers |
self | out physics.Shape | The input Shape is returned as the output |
Sets the layers that the shape inhabits. Shapes only collide if they are in the same layer. layers is an integer bitmap of all the layers that the shape occupies. Returns self.
Introduced in platform.apiLevel = '2.0'
setRestitution
self = physics.Shape:setRestitution(r)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
r | in number | The new value for the shape's restitution |
self | out physics.Shape | The input Shape is returned as the output |
Sets the restitution (or elasticity) of the shape. A value of 0.0 gives no bounce and a value of 1.0 gives a perfect bounce. Returns self.
May not behave as expected for r larger than 1.0 or less than 0.
NOTE |
setSensor
self = physics.Shape:setSensor(bool)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
bool | in boolean | True if the shape is a sensor |
self | out physics.Shape | The input Shape is returned as the output |
Determines if the shape is a sensor (true) or not (false). Sensors call collision handlers but do not generate collisions. Returns self.
Introduced in platform.apiLevel = '2.0'
setSurfaceV
self = physics.Shape:setSurfaceV(vel)
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
vel | in physics.Vect | The new vector for the surface velocity |
self | out physics.Shape | The input Shape is returned as the output |
Sets the surface velocity of the shape. Returns self.
Introduced in platform.apiLevel = '2.0'
surfaceV
sv = physics.Shape:surfaceV()
Parameter | Type | Description |
---|---|---|
self | in physics.Shape | The input Shape |
sv | out physics.Vect | The surface velocity of the Shape |
Returns the surface velocity vector of the shape.
Introduced in platform.apiLevel = '2.0'
Subcategories
This category has the following 3 subcategories, out of 3 total.