34 lines
869 B
TypeScript
34 lines
869 B
TypeScript
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
|
import { Player_Events } from "../../sword_enums";
|
|
import InputWrapper from "../../Tools/InputWrapper";
|
|
import { PlayerStates } from "../PlayerController";
|
|
import OnGround from "./OnGround";
|
|
|
|
export default class Walk extends OnGround {
|
|
owner: AnimatedSprite;
|
|
|
|
onEnter(options: Record<string, any>): void {
|
|
this.parent.speed = this.parent.MIN_SPEED;
|
|
}
|
|
|
|
|
|
update(deltaT: number): void {
|
|
//console.log("walking anim");
|
|
this.owner.animation.playIfNotAlready("WALK", true);
|
|
|
|
let dir = this.getInputDirection();
|
|
|
|
if(dir.isZero()){
|
|
this.finished(PlayerStates.IDLE);
|
|
}
|
|
|
|
this.parent.velocity.x = dir.x * (this.parent.speed + this.parent.CURRENT_BUFFS.speed);
|
|
|
|
super.update(deltaT);
|
|
}
|
|
|
|
onExit(): Record<string, any> {
|
|
this.owner.animation.stop();
|
|
return {};
|
|
}
|
|
} |