Type PhysicsContact Event preCollision Revision Release 2025.3721 Keywords preCollision, contact
During a pre-collision, there are multiple contact points that occur. You can manipulate these contact points to create certain effects like
You should not hold onto the contact object. It is only valid in the scope of your collision listener.
event.contact.isEnabled — enables or disables the collision associated with the contact.event.contact.isTouching — indicates whether the two objects are touching event.contact.bounce — specifies the bounce factor of the collision event.contact.friction — specifies the friction factor of the collision 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 function preCollisionEvent( self, event )
local collideObject = event.other
if ( collideObject.collType == "passthru" ) then
event.contact.isEnabled = false -- Disable this specific collision
end
end
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 } )
ball.preCollision = preCollisionEvent
ball:addEventListener( "preCollision", ball )