Difference between revisions of "B2.Contact"
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
Line 10: | Line 10: | ||
=== Examples === | === Examples === | ||
'''Checking collisions from bottom using b2.Contact''' | '''Checking collisions from bottom using b2.Contact''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
local isTouchingGround = false | local isTouchingGround = false | ||
world:addEventListener(Event.BEGIN_CONTACT, function(e) | world:addEventListener(Event.BEGIN_CONTACT, function(e) |
Revision as of 16:37, 12 July 2023
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 <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>