Difference between revisions of "B2.Contact"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
<!-- GIDEROSOBJ:b2.Contact -->
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2012.09.6<br/>
 
'''<translate>Available since</translate>:''' Gideros 2012.09.6<br/>
Line 27: Line 28:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
[[Special:MyLanguage/b2.Contact:getChildIndexA|b2.Contact:getChildIndexA]] <br/>
+
[[Special:MyLanguage/b2.Contact:getChildIndexA|b2.Contact:getChildIndexA]] <br/><!-- GIDEROSMTD:b2.Contact:getChildIndexA -->
[[Special:MyLanguage/b2.Contact:getChildIndexB|b2.Contact:getChildIndexB]] <br/>
+
[[Special:MyLanguage/b2.Contact:getChildIndexB|b2.Contact:getChildIndexB]] <br/><!-- GIDEROSMTD:b2.Contact:getChildIndexB -->
[[Special:MyLanguage/b2.Contact:getFixtureA|b2.Contact:getFixtureA]] <br/>
+
[[Special:MyLanguage/b2.Contact:getFixtureA|b2.Contact:getFixtureA]] <br/><!-- GIDEROSMTD:b2.Contact:getFixtureA -->
[[Special:MyLanguage/b2.Contact:getFixtureB|b2.Contact:getFixtureB]] <br/>
+
[[Special:MyLanguage/b2.Contact:getFixtureB|b2.Contact:getFixtureB]] <br/><!-- GIDEROSMTD:b2.Contact:getFixtureB -->
[[Special:MyLanguage/b2.Contact:getFriction|b2.Contact:getFriction]] <br/>
+
[[Special:MyLanguage/b2.Contact:getFriction|b2.Contact:getFriction]] <br/><!-- GIDEROSMTD:b2.Contact:getFriction -->
[[Special:MyLanguage/b2.Contact:getManifold|b2.Contact:getManifold]] <br/>
+
[[Special:MyLanguage/b2.Contact:getManifold|b2.Contact:getManifold]] <br/><!-- GIDEROSMTD:b2.Contact:getManifold -->
[[Special:MyLanguage/b2.Contact:getRestitution|b2.Contact:getRestitution]] <br/>
+
[[Special:MyLanguage/b2.Contact:getRestitution|b2.Contact:getRestitution]] <br/><!-- GIDEROSMTD:b2.Contact:getRestitution -->
[[Special:MyLanguage/b2.Contact:getWorldManifold|b2.Contact:getWorldManifold]] <br/>
+
[[Special:MyLanguage/b2.Contact:getWorldManifold|b2.Contact:getWorldManifold]] <br/><!-- GIDEROSMTD:b2.Contact:getWorldManifold -->
[[Special:MyLanguage/b2.Contact:isTouching|b2.Contact:isTouching]] <br/>
+
[[Special:MyLanguage/b2.Contact:isTouching|b2.Contact:isTouching]] <br/><!-- GIDEROSMTD:b2.Contact:isTouching -->
[[Special:MyLanguage/b2.Contact:resetFriction|b2.Contact:resetFriction]] <br/>
+
[[Special:MyLanguage/b2.Contact:resetFriction|b2.Contact:resetFriction]] <br/><!-- GIDEROSMTD:b2.Contact:resetFriction -->
[[Special:MyLanguage/b2.Contact:resetRestitution|b2.Contact:resetRestitution]] <br/>
+
[[Special:MyLanguage/b2.Contact:resetRestitution|b2.Contact:resetRestitution]] <br/><!-- GIDEROSMTD:b2.Contact:resetRestitution -->
[[Special:MyLanguage/b2.Contact:setEnabled|b2.Contact:setEnabled]] <br/>
+
[[Special:MyLanguage/b2.Contact:setEnabled|b2.Contact:setEnabled]] <br/><!-- GIDEROSMTD:b2.Contact:setEnabled -->
[[Special:MyLanguage/b2.Contact:setFriction|b2.Contact:setFriction]] <br/>
+
[[Special:MyLanguage/b2.Contact:setFriction|b2.Contact:setFriction]] <br/><!-- GIDEROSMTD:b2.Contact:setFriction -->
[[Special:MyLanguage/b2.Contact:setRestitution|b2.Contact:setRestitution]] <br/>
+
[[Special:MyLanguage/b2.Contact:setRestitution|b2.Contact:setRestitution]] <br/><!-- GIDEROSMTD:b2.Contact:setRestitution -->
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 15:56, 31 August 2018

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.png
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