From 6f988dabed3fd4edfe885f3bc44f2e2c2c8e096f Mon Sep 17 00:00:00 2001 From: panFD Date: Sun, 16 Aug 2026 16:49:12 +0800 Subject: [PATCH] feat(skill): add force spawn position setting for skills add forceStartX and forceStartY properties to control skill spawn position directly use world coordinates when the values are >=0, otherwise use original offset logic --- assets/script/game/skill/Skill.ts | 13 +++++++++++-- assets/script/game/skill/SkillView.ts | 8 ++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index 5fa70e1f..28e466fc 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -159,8 +159,17 @@ export class Skill extends ecs.Entity { SView.group = caster.box_group this.add(SView); - startPos.x = startPos.x + SView.atk_x * face - startPos.y = startPos.y + SView.atk_y + // 强制出生点:-1=不强制使用 atk_x/atk_y 偏移,>=0=强制世界坐标 + if (SView.forceStartX >= 0) { + startPos.x = SView.forceStartX; + } else { + startPos.x = startPos.x + SView.atk_x * face; + } + if (SView.forceStartY >= 0) { + startPos.y = SView.forceStartY; + } else { + startPos.y = startPos.y + SView.atk_y; + } node.setPosition(startPos); diff --git a/assets/script/game/skill/SkillView.ts b/assets/script/game/skill/SkillView.ts index f2465939..e12b8ef3 100644 --- a/assets/script/game/skill/SkillView.ts +++ b/assets/script/game/skill/SkillView.ts @@ -42,6 +42,14 @@ export class SkillView extends CCComp { @property({ type: CCFloat, slide: true, range: [0, 2000, 10], tooltip: "直线飞行距离(仅 linear 生效)" }) distance: number = 0; + /** 强制出生点世界坐标X(-1=不强制,使用 atk_x 偏移;>=0 时强制使用该值,如 0=屏幕中心) */ + @property({ type: CCFloat, tooltip: "强制出生点X:-1=不强制,>=0=强制世界坐标X" }) + forceStartX: number = -1; + + /** 强制出生点世界坐标Y(-1=不强制,使用 atk_y 偏移;>=0 时强制使用该值) */ + @property({ type: CCFloat, tooltip: "强制出生点Y:-1=不强制,>=0=强制世界坐标Y" }) + forceStartY: number = -1; + private debugMode: boolean = false; anim: Animation = null;