mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-04-19 05:18:52 +00:00
- spawned weapon blade following player x scale
This commit is contained in:
parent
a1806aaef7
commit
176160cacc
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user