类型 PhysicsContact(物理接触) 事件 collision(碰撞) 修订版本 版本 2024.3703 关键词 碰撞,接触
在碰撞过程中,会发生多个接触点。您可以操作这些接触点来创建特定效果。
您不应持有 contact 对象。它仅在碰撞侦听器的范围内有效。
event.contact.isTouching
— 指示两个对象是否接触event.contact.bounce
— 指定碰撞的弹跳系数event.contact.friction
— 指定碰撞的摩擦系数event.contact.tangentSpeed
— 指定沿碰撞表面的切向速度(“传送带”运动),默认为 0local platform = display.newRect( 0, 0, 280, 30 ) platform.surfaceType = "superbounce" platform.x, platform.y = display.contentCenterX, display.contentCenterY+80 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 onCollision( self, event ) local collideObject = event.other if ( collideObject.surfaceType == "superbounce" ) then event.contact.bounce = 20 -- Magnify bounce for this specific collision end end ball.collision = onCollision ball:addEventListener( "collision" )