cocos通过碰撞collider进行道具获取 或者出发事件
在sprite添加collider跟rigibody 然后选择sensor
在角色的
判断sensor后根据node名称进行操作
视频 视频
https://www.bilibili.com/video/BV1GrWVzKER5/
// 碰撞回调onBeginContact(selfCollider: Collider2D, otherCollider: Collider2D, contact: IPhysics2DContact | null) {if (otherCollider.sensor) {console.log("Collided with a sensor, ignoring contact points",otherCollider.node.name);if(otherCollider.node.name.includes("daojutiao")){this.jumpci=this.jumpci+3;this.tiao.string=this.jumpci.toString();this.show("jump +3",4);this.xiaohui(otherCollider.node,0);}else if(otherCollider.node.name.includes("tanshe")){//this.scheduleOnce(() => {//this.jump(1670, 700); // 使用更大的力度//}, 0);this.show("超级弹射",4);//this.shangtian(700,1700);const playerAnim=otherCollider.node.getComponent(Animation);playerAnim.play("animation-001");console.log(playerAnim);this.xiaohui(otherCollider.node,4)}else if(otherCollider.node.name.includes("xuanze")){this.show("即将选择装备进化,红色攻击,黄色防御,蓝色速度",7);}}