feat(英雄/怪物): 添加受击倒地特效
- 新增 down.prefab 和 down.anim 资源文件
- 在 Hero 和 Monster 的落地逻辑中调用 playEnd("down") 播放特效
- 优化 HeroViewComp 中特效生成逻辑,移除冗余的组件销毁操作
This commit is contained in:
@@ -105,6 +105,7 @@ export class Hero extends ecs.Entity {
|
||||
.call(() => {
|
||||
if (!node || !node.isValid) return;
|
||||
node.setPosition(pos.x, dropToY, 0);
|
||||
hv.playEnd("down");
|
||||
move.moving = true;
|
||||
if (collider) {
|
||||
collider.enabled = true;
|
||||
|
||||
@@ -334,8 +334,6 @@ export class HeroViewComp extends CCComp {
|
||||
private spawnTimedFx(path: string, parent: Node | null, life: number = 0.8, worldPos?: Vec3): Node | null {
|
||||
const node = this.createFxNode(path, parent, worldPos);
|
||||
if (!node) return null;
|
||||
const ender = node.getComponent(oneCom);
|
||||
if (ender) ender.destroy();
|
||||
const timer = node.getComponent(timedCom) || node.addComponent(timedCom);
|
||||
timer.time = Math.max(0.2, life);
|
||||
return node;
|
||||
@@ -343,8 +341,6 @@ export class HeroViewComp extends CCComp {
|
||||
private spawnAnimEndFx(path: string, parent: Node | null, worldPos?: Vec3): Node | null {
|
||||
const node = this.createFxNode(path, parent, worldPos);
|
||||
if (!node) return null;
|
||||
const timer = node.getComponent(timedCom);
|
||||
if (timer) timer.destroy();
|
||||
node.getComponent(oneCom) || node.addComponent(oneCom);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ export class Monster extends ecs.Entity {
|
||||
.call(() => {
|
||||
if (!node || !node.isValid) return;
|
||||
node.setPosition(pos.x, dropToY, 0);
|
||||
view.playEnd("down");
|
||||
move.moving = true;
|
||||
if (collider) {
|
||||
collider.enabled = true;
|
||||
|
||||
Reference in New Issue
Block a user