mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-04-19 13:28:54 +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 strikeTimer: GameTimer;
|
||||||
private strikeState: AnimationState;
|
private strikeState: AnimationState;
|
||||||
private damage: number;
|
private damage: number;
|
||||||
|
private playerDirectionX: number;
|
||||||
|
|
||||||
public init(strikeDelay: number, damage: number): void {
|
public init(strikeDelay: number, damage: number): void {
|
||||||
this.strikeTimer = new GameTimer(strikeDelay);
|
this.strikeTimer = new GameTimer(strikeDelay);
|
||||||
this.damage = damage;
|
this.damage = damage;
|
||||||
this.node.active = false;
|
this.node.active = false;
|
||||||
|
this.setWeaponDirection();
|
||||||
|
|
||||||
this.weaponAnimation.on(Animation.EventType.FINISHED, this.endStrike, this);
|
this.weaponAnimation.on(Animation.EventType.FINISHED, this.endStrike, this);
|
||||||
this.strikeState = this.weaponAnimation.getState(this.weaponAnimation.clips[0].name);
|
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> {
|
public get WeaponStrikeEvent(): ISignal<Weapon> {
|
||||||
return this.weaponStrikeEvent;
|
return this.weaponStrikeEvent;
|
||||||
}
|
}
|
||||||
@ -57,6 +64,7 @@ export class Weapon extends Component {
|
|||||||
|
|
||||||
private strike(): void {
|
private strike(): void {
|
||||||
this.node.active = true;
|
this.node.active = true;
|
||||||
|
this.setWeaponDirection();
|
||||||
this.weaponAnimation.play(this.strikeState.name);
|
this.weaponAnimation.play(this.strikeState.name);
|
||||||
this.weaponStrikeEvent.trigger(this);
|
this.weaponStrikeEvent.trigger(this);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user