cocos学习笔记
碰撞事件
// 发生碰撞 onCollisionEnter(other: cc.Collider, self: cc.Collider): void { console.log(other.tag); } // 持续碰撞 onCollisionStay(other: cc.Collider, self: cc.Collider): void { console.log(other.tag); } // 离开碰撞 onCollisionExit(other: cc.Collider, self: cc.Collider):void { console.log("离开碰撞"); }
开启碰撞
let cm = cc.director.getCollisionManager() cm.enabled = true // 开启碰撞 cm.enabledDebugDraw = true // 显示碰撞边界 cm.enabledDrawBoundingBox = true // 节点对象的边界