Line 829: |
Line 829: |
| | | |
| ---- | | ---- |
− | ===== setPositionFunc ===== | + | ===== setPositionFunc ===== |
| | | |
| + | <!-- code start--> |
| + | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">self = physics.Body:setPositionFunc(func) |
| + | </pre><!-- code end--> |
| + | <!-- table start --> |
| | | |
− | <!-- code start-->
| + | {| border="1" width="100%" cellspacing="0" cellpadding="4" style="border-color:#eee" class="wikitable" |
− | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
| + | |- |
− | self = physics.Body:setPositionFunc(func)
| + | ! Parameter |
− | </pre><!-- code end-->
| + | ! Type |
− | | + | ! Description <!-- header row 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 | + | | self |
− | | '''in''' physics.Body | + | | '''in''' physics.Body |
− | | The input Body | + | | The input Body |
| |- | | |- |
− | | func | + | | func |
− | | '''in''' function(body, dt) | + | | '''in''' function(body, dt) |
− | | A callback function that updates the position of the Body on each time step | + | | A callback function that updates the position of the Body on each time step |
| |- | | |- |
− | | self | + | | self |
− | | '''out''' physics.Body | + | | '''out''' physics.Body |
− | | The input Body is returned as the output | + | | The input Body is returned as the output |
− | |}<!-- table end --> | + | |} |
− | | + | <!-- table end --> |
− | <br/> | + | <br> Sets the position function of the body. The position function must be a function that accepts a Body and a time step value and at some point calls body:updatePosition to update the position of the body. |
− | Sets the position function of the body. The position function must be a function that accepts a Body and a time step value and at some point calls body:updatePosition to update the position of the body. | |
| | | |
| Returns the Body. | | Returns the Body. |
− | {| width="100%" style="padding: 20px; margin-left:20px; border:solid; border-color:#aaa; border-width:0px; text-align:left; background-color:#ddffdd;"
| |
− | |-
| |
− | | <span style="color:#00AA00">'''TIP''':</span> '''Example'''<hr>
| |
− | |-
| |
− |
| |
− | <div style="white-space: pre">
| |
− |
| |
− |
| |
− | <!-- code start-->
| |
− | <pre style="margin-left:20px; font-size:1.4em; background-color:#fdfdfd">
| |
− | -- TODO This is a lame example
| |
| | | |
− | function samplePositionFunc(body, dt)
| |
− | -- What goes here?
| |
− | body:updatePosition(dt)
| |
− | end
| |
| | | |
− | body:setPositionFunc(samplePositionFunc)
| |
− | </pre><!-- code end-->
| |
− |
| |
− |
| |
− | </div>
| |
− | |}
| |
− | <br/>
| |
| | | |
| Introduced in platform.apiLevel = '2.0' | | Introduced in platform.apiLevel = '2.0' |
| | | |
| ---- | | ---- |
| + | |
| ===== setTorque ===== | | ===== setTorque ===== |
| | | |