From 27c30713a978848b1ddb3d71c60edc7bfc43fd2d Mon Sep 17 00:00:00 2001 From: richarjiang Date: Sat, 11 Oct 2025 14:30:09 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=81=93=E5=85=B7=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E7=AB=99=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/scenes/main.scene | 10 +++++----- assets/scripts/PlayerController.ts | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/assets/scenes/main.scene b/assets/scenes/main.scene index 14bf8a1..a0e36dc 100644 --- a/assets/scenes/main.scene +++ b/assets/scenes/main.scene @@ -4872,8 +4872,8 @@ "_prefab": null, "_lpos": { "__type__": "cc.Vec3", - "x": -79.18, - "y": -44.339, + "x": -150.937, + "y": -79.824, "z": 0 }, "_lrot": { @@ -5292,9 +5292,9 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 + "x": 0.833, + "y": 0.833, + "z": 0.833 }, "_mobility": 0, "_layer": 33554432, diff --git a/assets/scripts/PlayerController.ts b/assets/scripts/PlayerController.ts index cc62df4..e4d2e5a 100644 --- a/assets/scripts/PlayerController.ts +++ b/assets/scripts/PlayerController.ts @@ -607,7 +607,7 @@ export class PlayerController extends Component { if (otherCollider.node.name.startsWith('guai_')) { void this.handleAttack(selfCollider, otherCollider); } else if (otherCollider.node.name.startsWith('box_')) { - this.handleBoxCollision(otherCollider); + void this.handleBoxCollision(selfCollider, otherCollider); } } @@ -918,7 +918,7 @@ export class PlayerController extends Component { }, 1); // 延迟1秒显示失败弹窗,让玩家死亡动画播放完成 } - private handleBoxCollision(otherCollider: Collider2D) { + private async handleBoxCollision(selfCollider: Collider2D, otherCollider: Collider2D) { if (!this.player) { return; } @@ -931,6 +931,16 @@ export class PlayerController extends Component { // 防止重复触发 otherCollider.enabled = false; + this.stopMovement(); + + await this.alignPlayerForAttack(selfCollider, otherCollider); + + if (!this.player || !boxNode.isValid) { + return; + } + + this.switchAnimation('stand'); + const playerHpNode = this.player.getChildByName('hp'); const boxHpNode = boxNode.getChildByName('hp');