Type Boolean Object PhysicsContact Library physics.* Revision 2017.3060 Keywords physics contact, isEnabled See also preCollision
Enable or disable the collision associated with this contact. This is typically used inside a preCollision event listener and may be used to construct
The contact is only enabled/disabled for the current time step. Future contacts will be registered as usual.
local platform = display.newRect( 0, 0, 280, 30 ) platform.x, platform.y = display.contentCenterX, display.contentCenterY+80 platform.collType = "passthru" physics.addBody( platform, "static", { bounce=0.0, friction=0.3 } ) local ball = display.newCircle( 0, 0, 15 ) ball.x, ball.y = display.contentCenterX, display.contentCenterY-40 physics.addBody( ball, "dynamic", { bounce=0.0, radius=20 } ) local function preCollisionEvent( self, event ) local collideObject = event.other if ( collideObject.collType == "passthru" ) then event.contact.isEnabled = false --disable this specific collision end end ball.preCollision = preCollisionEvent ball:addEventListener( "preCollision" )