33 lines
753 B
TypeScript
33 lines
753 B
TypeScript
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
|
import { PlayerStates } from "../PlayerController";
|
|
import OnGround from "./OnGround";
|
|
|
|
export default class Idle extends OnGround {
|
|
owner: AnimatedSprite;
|
|
|
|
onEnter(options: Record<string, any>): void {
|
|
this.parent.speed = this.parent.MIN_SPEED;
|
|
}
|
|
|
|
|
|
update(deltaT: number): void {
|
|
|
|
|
|
this.owner.animation.playIfNotAlready("IDLE", true);
|
|
|
|
let dir = this.getInputDirection();
|
|
|
|
if(!dir.isZero() && dir.y === 0){
|
|
this.finished(PlayerStates.WALK);
|
|
}
|
|
|
|
this.parent.velocity.x = 0;
|
|
super.update(deltaT);
|
|
this.owner.move(this.parent.velocity.scaled(deltaT));
|
|
}
|
|
|
|
onExit(): Record<string, any> {
|
|
this.owner.animation.stop();
|
|
return {};
|
|
}
|
|
} |