Difference between revisions of "B2.WorldManifold"

From GiderosMobile
Line 2: Line 2:
 
'''Supported platforms:''' <br/>
 
'''Supported platforms:''' <br/>
 
'''Available since:''' Gideros 2012.09.6<br/>
 
'''Available since:''' Gideros 2012.09.6<br/>
=== Description ===
+
=== <translate>Description</translate> ===
 
<translate>Contains information about contact relative to the world</translate>
 
<translate>Contains information about contact relative to the world</translate>
=== Examples ===
+
=== <translate>Examples</translate> ===
 
'''Checking collisions from bottom using b2.Contact'''<br/>
 
'''Checking collisions from bottom using b2.Contact'''<br/>
 
<source lang="lua">local isTouchingGround = false
 
<source lang="lua">local isTouchingGround = false
Line 38: Line 38:
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Methods ===
+
=== <translate>Methods</translate> ===
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Events ===
+
=== <translate>Events</translate> ===
=== Constants ===
+
=== <translate>Constants</translate> ===
 
[[Special:MyLanguage/normal|normal]]<br/>
 
[[Special:MyLanguage/normal|normal]]<br/>
 
[[Special:MyLanguage/points|points]]<br/>
 
[[Special:MyLanguage/points|points]]<br/>
 
|}
 
|}

Revision as of 07:29, 24 August 2018

Supported platforms:
Available since: Gideros 2012.09.6

Description

Contains information about contact relative to the world

Examples

Checking collisions from bottom using b2.Contact

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)

Example content of b2.WorldManifold

[normal] => Table {
        {
          [y] => -1
          [x] => 0
        }
[points] => Table {
        {
          [1] => Table {
             {
               [y] => 319.92502212524
               [x] => 99.999997615814
             }
        }

Methods

Events

Constants

normal
points