# plane_game **Repository Path**: game_cocos/plane_game ## Basic Information - **Project Name**: plane_game - **Description**: 飞机大战-完整 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-01-05 - **Last Updated**: 2024-02-05 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 无法在碰撞检测中销毁节点 如果在碰撞检测中销毁当前节点会报错: `You are trying to destroy a object twice or more.` 需要在碰撞周期外销毁,可使用 setTimeOut: ```javascript onCollisionEnter(selfCollider: Collider2D, otherCollider: Collider2D) { setTimeout(() => { this.node.destroy() }, 10); } ``` 实例化预制体需要挂载父节点后才能设置世界坐标 ```ts const enemyIns: Node = instantiate(this.enemyPrefab); enemyIns.setWorldPosition(new Vec3(10, 10, 0)); // 设置的是相对位置,跟setPosition效果相同 enemyIns.setParent(this.node); ``` 由于节点的世界坐标是在场景加载和节点布局完成后计算的,所以必须添加到场景上才能设置世界坐标,即放在 setParent 方法后面设置。 # 适配方案 https://github.com/zhitaocai/CocosCreator-Multi-resolution-Adapter # 响应无效 `director.pause()` 会导致点击事件无效,接近方案,延时一会执行 ```ts // 显示弹窗 this.dialog.active = true; setTimeout(() => { director.pause(); }, 30); ```