From 9f08d19742790b3ad532ceb6dcd210af63cf6386 Mon Sep 17 00:00:00 2001 From: walkpan Date: Sat, 3 Jan 2026 21:57:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=87=8D=E7=BD=AE=E6=80=AA=E7=89=A9?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E5=8F=82=E6=95=B0=E5=92=8C=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在Monster类中重置移动参数确保怪物行为一致 在HeroViewComp中初始化状态变量防止未定义行为 --- assets/script/game/hero/HeroViewComp.ts | 3 +++ assets/script/game/hero/Mon.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index cd5db488..6eaa3846 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -92,6 +92,9 @@ export class HeroViewComp extends CCComp { /** 初始化/重置视图状态 */ init() { + this.status = "idle"; + this.deadCD = 0; + this.lastBarUpdateTime = 0; this.as.idle() // 初始化 UI 节点 diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 5c2b912d..b03906c2 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -139,6 +139,7 @@ export class Monster extends ecs.Entity { // 初始化移动参数,包括线路和生成顺序 const move = this.get(MonMoveComp); + move.reset(); move.direction = -1; // 向左移动 move.targetX = -800; // 左边界 move.lane = lane; // 设置线路标识