Difference between revisions of "Category:Physics Engine/Shapes"

From Inspired-Lua Wiki
Jump to navigation Jump to search
(Created page with "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. [[Category:Phy...")
 
 
Line 1: Line 1:
Shapes contain the surface properties of an object such as how much friction or elasticity
+
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.
it has. All collision shapes implement the following accessor routines.
+
 
 +
----
 +
===== BB =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
bb = physics.Shape:BB()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  bb
 +
|  '''in''' physics.BB
 +
|  Bounding box of the Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the [[#BB|bounding box]] of the shape.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== body =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
body = physics.Shape:body()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  body
 +
|  '''out''' physics.Body
 +
|  The Body associated with the Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the [[#Body|body]] attached to the shape. If the shape is static, then it will return nil.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
 
 +
 
 +
===== collisionType =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
coll = physics.Shape:collisionType()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  coll
 +
|  '''out''' number
 +
|  The programmer-assigned integer collision type
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the integer collision type of the Shape.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== data =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
obj = physics.Shape:data()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  obj
 +
|  '''out''' Lua object
 +
|  The programmer-assigned data object assigned to this Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the contents of the programmer data field of the Shape.
 +
 
 +
Introducted in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== friction =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
f = physics.Shape:friction()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  f
 +
|  '''out''' number
 +
|  The coefficient of friction for this Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the friction coefficient of the shape.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== group =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
g = physics.Shape:group()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  g
 +
|  '''out''' number
 +
|  The assigned group number
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the group number of the shape.
 +
{|  width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
 +
|-
 +
|  <span style="color:#AAAA00">'''NOTE'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
The group number is converted to a positive whole number when stored.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== layers =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
layers = physics.Shape:layers()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  layers
 +
|  '''out''' number
 +
|  A bitmap of the layers this shape occupies
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the bitmap of layers the shape occupies.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== rawBB =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
bb = physics.Shape:rawBB()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  bb
 +
|  '''out''' physics.BB
 +
|  The bounding box of the Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the [[#BB|bounding box]] of the shape. Only valid after a call to [[#BB|physics.Shape:BB()]] or [[#step|physics.Space:step()]].
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== restitution =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
r = physics.Shape:restitution()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  r
 +
|  '''out''' number
 +
|  The restitution of the Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the restitution (or elasticity) of the shape.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== sensor =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
s = physics.Shape:sensor()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  s
 +
|  '''out''' boolean
 +
|  True if the Shape is a sensor
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns true if the shape is a sensor.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setCollisionType =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setCollisionType(collisionType)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
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 =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setData(obj)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
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 =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setFriction(f)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the friction coefficient for the shape. Returns ''self''.
 +
{|  width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
 +
|-
 +
|  <span style="color:#AAAA00">'''NOTE'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
May not behave as expected for f larger than 1.0 or less than 0.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
 
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setGroup =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setGroup(group)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  group
 +
|  '''in''' number
 +
|  Group number
 +
|-
 +
|  self
 +
|  '''out''' physics.Shape
 +
|  The input Shape is returned as the output
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the group (a number defined by the programmer) of the shape. Shapes in the same group do not generate collisions. Returns ''self''.
 +
{|  width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
 +
|-
 +
|  <span style="color:#AAAA00">'''NOTE'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
The group number is converted to a positive whole number when stored.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setLayers =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setLayers(layers)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
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 =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setRestitution(r)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
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''.
 +
{|  width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#FFFFCE;"
 +
|-
 +
|  <span style="color:#AAAA00">'''NOTE'''</span><hr>
 +
|-
 +
 
 +
<div style="white-space: pre">
 +
 
 +
May not behave as expected for r larger than 1.0 or less than 0.
 +
 
 +
</div>
 +
|}
 +
<br/>
 +
 
 +
----
 +
===== setSensor =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setSensor(bool)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Determines if the shape is a sensor (true) or not (false). Sensors call [[#CollisionHandler|collision handlers]] but do not generate collisions. Returns ''self''.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== setSurfaceV =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
self = physics.Shape:setSurfaceV(vel)
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  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
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Sets the surface velocity of the shape. Returns ''self''.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
 +
 
 +
----
 +
===== surfaceV =====
 +
 
 +
 
 +
<!-- code start-->
 +
<pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
 +
sv = physics.Shape:surfaceV()
 +
</pre><!-- code end-->
 +
 
 +
 
 +
<!-- table start -->
 +
{| border=1  width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable"
 +
<!-- header row start -->
 +
! Parameter !! Type !! Description
 +
<!-- header row end -->
 +
|-
 +
|  self
 +
|  '''in''' physics.Shape
 +
|  The input Shape
 +
|-
 +
|  sv
 +
|  '''out''' physics.Vect
 +
|  The surface velocity of the Shape
 +
|}<!-- table end -->
 +
 
 +
<br/>
 +
Returns the surface velocity [[#vector|vector]] of the shape.
 +
 
 +
Introduced in platform.apiLevel = '2.0'
  
 
[[Category:Physics_Engine]]
 
[[Category:Physics_Engine]]

Latest revision as of 09:46, 18 July 2012

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.


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.