From 176160cacc2f48c39ee9c1dd2a966c60fde8db35 Mon Sep 17 00:00:00 2001 From: Boycanss Date: Mon, 7 Apr 2025 22:02:31 +0700 Subject: [PATCH] - spawned weapon blade following player x scale --- assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts b/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts index d27ac30..8e985e7 100644 --- a/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts +++ b/assets/Scripts/Game/Unit/Player/Weapon/Weapon.ts @@ -16,11 +16,13 @@ export class Weapon extends Component { private strikeTimer: GameTimer; private strikeState: AnimationState; private damage: number; + private playerDirectionX: number; public init(strikeDelay: number, damage: number): void { this.strikeTimer = new GameTimer(strikeDelay); this.damage = damage; this.node.active = false; + this.setWeaponDirection(); this.weaponAnimation.on(Animation.EventType.FINISHED, this.endStrike, this); this.strikeState = this.weaponAnimation.getState(this.weaponAnimation.clips[0].name); @@ -36,6 +38,11 @@ export class Weapon extends Component { } } + private setWeaponDirection(){ + this.playerDirectionX = this.node.parent.getChildByName("PlayerGraphics").scale.x; + this.node.setScale(this.playerDirectionX,1,1); + } + public get WeaponStrikeEvent(): ISignal { return this.weaponStrikeEvent; } @@ -57,6 +64,7 @@ export class Weapon extends Component { private strike(): void { this.node.active = true; + this.setWeaponDirection(); this.weaponAnimation.play(this.strikeState.name); this.weaponStrikeEvent.trigger(this); }