- spawned weapon blade following player x scale

This commit is contained in:
Boycanss 2025-04-07 22:02:31 +07:00
parent a1806aaef7
commit 176160cacc

View File

@ -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<Weapon> {
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);
}