Difference between revisions of "B2.Contact"

From GiderosMobile
Line 2: Line 2:
 
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Supported platforms:''' android, ios, mac, pc<br/>
 
'''Available since:''' Gideros 2012.09.6<br/>
 
'''Available since:''' Gideros 2012.09.6<br/>
=== Description ===
+
=== <translate>Description</translate> ===
 
<translate><br />
 
<translate><br />
 
The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.<br />
 
The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.<br />
 
<br /></translate>
 
<br /></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 26: Line 26:
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Methods ===
+
=== <translate>Methods</translate> ===
 
[[Special:MyLanguage/b2.Contact:getChildIndexA|b2.Contact:getChildIndexA]] <br/>
 
[[Special:MyLanguage/b2.Contact:getChildIndexA|b2.Contact:getChildIndexA]] <br/>
 
[[Special:MyLanguage/b2.Contact:getChildIndexB|b2.Contact:getChildIndexB]] <br/>
 
[[Special:MyLanguage/b2.Contact:getChildIndexB|b2.Contact:getChildIndexB]] <br/>
Line 42: Line 42:
 
[[Special:MyLanguage/b2.Contact:setRestitution|b2.Contact:setRestitution]] <br/>
 
[[Special:MyLanguage/b2.Contact:setRestitution|b2.Contact:setRestitution]] <br/>
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== Events ===
+
=== <translate>Events</translate> ===
=== Constants ===
+
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 08:29, 24 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2012.09.6

Description


The class manages contact between two shapes. A contact exists for each overlapping AABB in the broad-phase (except if filtered). Therefore a contact object may exist that has no contact points.

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)

Methods

b2.Contact:getChildIndexA
b2.Contact:getChildIndexB
b2.Contact:getFixtureA
b2.Contact:getFixtureB
b2.Contact:getFriction
b2.Contact:getManifold
b2.Contact:getRestitution
b2.Contact:getWorldManifold
b2.Contact:isTouching
b2.Contact:resetFriction
b2.Contact:resetRestitution
b2.Contact:setEnabled
b2.Contact:setFriction
b2.Contact:setRestitution

Events

Constants