Difference between revisions of "B2.WorldManifold"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
Line 10: Line 10:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Checking collisions from bottom using b2.Contact'''
 
'''Checking collisions from bottom using b2.Contact'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
local isTouchingGround = false
 
local isTouchingGround = false
 
world:addEventListener(Event.BEGIN_CONTACT, function(e)
 
world:addEventListener(Event.BEGIN_CONTACT, function(e)
Line 30: Line 30:
  
 
'''Example content of b2.WorldManifold'''
 
'''Example content of b2.WorldManifold'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
[normal] => Table {
 
[normal] => Table {
 
         {
 
         {

Revision as of 15:26, 13 July 2023


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2012.09.6

Description

Contains information about contact relative to the world.

Examples

Checking collisions from bottom using b2.Contact <syntaxhighlight lang="lua"> local isTouchingGround = false world:addEventListener(Event.BEGIN_CONTACT, function(e) local manifold = e.contact:getWorldManifold() if manifold.normal.y > 0.9 then --collision came from bottom isTouchingGround = true end end)

world:addEventListener(Event.END_CONTACT, function(e) local manifold = e.contact:getWorldManifold() if manifold.normal.y < 0.1 then --collision ended from bottom isTouchingGround = false end end) </source>

Example content of b2.WorldManifold <syntaxhighlight lang="lua"> [normal] => Table {

       {
         [y] => -1
         [x] => 0
       }

[points] => Table {

       {
         [1] => Table {
            {
              [y] => 319.92502212524
              [x] => 99.999997615814
            }
       }

</source>

Methods

Events

Constants

normal
points