Difference between revisions of "B2.Contact"
From GiderosMobile
Line 2: | Line 2: | ||
<languages /> | <languages /> | ||
<!-- GIDEROSOBJ:b2.Contact --> | <!-- GIDEROSOBJ:b2.Contact --> | ||
− | ''' | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> |
− | ''' | + | '''Available since:''' Gideros 2012.09.6<br/> |
− | === | + | |
− | + | === 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. | + | 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''' | + | '''Checking collisions from bottom using b2.Contact''' |
− | <source lang="lua">local isTouchingGround = false | + | <source lang="lua"> |
+ | local isTouchingGround = false | ||
world:addEventListener(Event.BEGIN_CONTACT, function(e) | world:addEventListener(Event.BEGIN_CONTACT, function(e) | ||
local manifold = e.contact:getWorldManifold() | local manifold = e.contact:getWorldManifold() | ||
Line 25: | Line 26: | ||
isTouchingGround = false | isTouchingGround = false | ||
end | end | ||
− | end)</source> | + | end) |
+ | </source> | ||
+ | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Methods === |
[[Special:MyLanguage/b2.Contact:getChildIndexA|b2.Contact:getChildIndexA]] <br/><!-- GIDEROSMTD:b2.Contact:getChildIndexA() --> | [[Special:MyLanguage/b2.Contact:getChildIndexA|b2.Contact:getChildIndexA]] <br/><!-- GIDEROSMTD:b2.Contact:getChildIndexA() --> | ||
[[Special:MyLanguage/b2.Contact:getChildIndexB|b2.Contact:getChildIndexB]] <br/><!-- GIDEROSMTD:b2.Contact:getChildIndexB() --> | [[Special:MyLanguage/b2.Contact:getChildIndexB|b2.Contact:getChildIndexB]] <br/><!-- GIDEROSMTD:b2.Contact:getChildIndexB() --> | ||
Line 43: | Line 46: | ||
[[Special:MyLanguage/b2.Contact:setFriction|b2.Contact:setFriction]] <br/><!-- GIDEROSMTD:b2.Contact:setFriction(friction) --> | [[Special:MyLanguage/b2.Contact:setFriction|b2.Contact:setFriction]] <br/><!-- GIDEROSMTD:b2.Contact:setFriction(friction) --> | ||
[[Special:MyLanguage/b2.Contact:setRestitution|b2.Contact:setRestitution]] <br/><!-- GIDEROSMTD:b2.Contact:setRestitution(restitution) --> | [[Special:MyLanguage/b2.Contact:setRestitution|b2.Contact:setRestitution]] <br/><!-- GIDEROSMTD:b2.Contact:setRestitution(restitution) --> | ||
+ | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
− | === | + | === Events === |
− | === | + | === Constants === |
|} | |} | ||
− | + | ---- | |
+ | *'''[[LiquidFun]]''' |
Revision as of 07:24, 17 February 2020
Supported platforms:
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)