feat: add dash animation
This commit is contained in:
parent
201bfccd85
commit
b1028611f2
|
@ -310,23 +310,31 @@
|
||||||
"frames": [
|
"frames": [
|
||||||
{
|
{
|
||||||
"index": 46,
|
"index": 46,
|
||||||
"duration": 5
|
"duration": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 47,
|
"index": 47,
|
||||||
"duration": 5
|
"duration": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 48,
|
"index": 48,
|
||||||
"duration": 5
|
"duration": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 49,
|
"index": 49,
|
||||||
"duration": 5
|
"duration": 2
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"index": 50,
|
"index": 48,
|
||||||
"duration": 10
|
"duration": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 47,
|
||||||
|
"duration": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"index": 46,
|
||||||
|
"duration": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import GameEvent from "../../../Wolfie2D/Events/GameEvent";
|
||||||
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
||||||
import InAir from "./InAir";
|
import InAir from "./InAir";
|
||||||
import InputWrapper from "../../Tools/InputWrapper";
|
import InputWrapper from "../../Tools/InputWrapper";
|
||||||
|
import PlayerState from "./PlayerState";
|
||||||
|
|
||||||
export default class Fall extends InAir {
|
export default class Fall extends InAir {
|
||||||
owner: AnimatedSprite;
|
owner: AnimatedSprite;
|
||||||
|
@ -11,12 +12,17 @@ export default class Fall extends InAir {
|
||||||
}
|
}
|
||||||
|
|
||||||
update(deltaT: number): void {
|
update(deltaT: number): void {
|
||||||
|
if (!PlayerState.dashTimer.isStopped()) {
|
||||||
|
this.owner.animation.playIfNotAlready("DASH");
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (this.parent.invincible) {
|
if (this.parent.invincible) {
|
||||||
this.owner.animation.playIfNotAlready("HURT");
|
this.owner.animation.playIfNotAlready("HURT");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.owner.animation.playIfNotAlready("FALL", true);
|
this.owner.animation.playIfNotAlready("FALL", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//TODO - testing doublejump, may have to move to InAir instead
|
//TODO - testing doublejump, may have to move to InAir instead
|
||||||
// If we jump, move to the Jump state, give a burst of upwards velocity
|
// If we jump, move to the Jump state, give a burst of upwards velocity
|
||||||
if( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){
|
if( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
||||||
import { PlayerStates } from "../PlayerController";
|
import { PlayerStates } from "../PlayerController";
|
||||||
import OnGround from "./OnGround";
|
import OnGround from "./OnGround";
|
||||||
|
import PlayerState from "./PlayerState";
|
||||||
|
|
||||||
export default class Idle extends OnGround {
|
export default class Idle extends OnGround {
|
||||||
owner: AnimatedSprite;
|
owner: AnimatedSprite;
|
||||||
|
@ -13,7 +14,13 @@ export default class Idle extends OnGround {
|
||||||
update(deltaT: number): void {
|
update(deltaT: number): void {
|
||||||
|
|
||||||
//("idle anim");
|
//("idle anim");
|
||||||
|
if (!PlayerState.dashTimer.isStopped()) {
|
||||||
|
console.log("Playing dash");
|
||||||
|
this.owner.animation.playIfNotAlready("DASH");
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.owner.animation.playIfNotAlready("IDLE", true);
|
this.owner.animation.playIfNotAlready("IDLE", true);
|
||||||
|
}
|
||||||
|
|
||||||
let dir = this.getInputDirection();
|
let dir = this.getInputDirection();
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { Player_Events } from "../../sword_enums";
|
||||||
import InputWrapper from "../../Tools/InputWrapper";
|
import InputWrapper from "../../Tools/InputWrapper";
|
||||||
import { PlayerStates } from "../PlayerController";
|
import { PlayerStates } from "../PlayerController";
|
||||||
import InAir from "./InAir";
|
import InAir from "./InAir";
|
||||||
|
import PlayerState from "./PlayerState";
|
||||||
|
|
||||||
export default class Jump extends InAir {
|
export default class Jump extends InAir {
|
||||||
owner: AnimatedSprite;
|
owner: AnimatedSprite;
|
||||||
|
@ -17,12 +18,17 @@ export default class Jump extends InAir {
|
||||||
|
|
||||||
|
|
||||||
update(deltaT: number): void {
|
update(deltaT: number): void {
|
||||||
|
if (!PlayerState.dashTimer.isStopped()) {
|
||||||
|
this.owner.animation.playIfNotAlready("DASH");
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (this.parent.invincible) {
|
if (this.parent.invincible) {
|
||||||
this.owner.animation.playIfNotAlready("HURT");
|
this.owner.animation.playIfNotAlready("HURT");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.owner.animation.playIfNotAlready("JUMP", true);
|
this.owner.animation.playIfNotAlready("JUMP", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(this.owner.onCeiling){
|
if(this.owner.onCeiling){
|
||||||
|
|
|
@ -24,7 +24,7 @@ export default abstract class PlayerState extends State {
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.positionTimer = new Timer(250);
|
this.positionTimer = new Timer(250);
|
||||||
this.positionTimer.start();
|
this.positionTimer.start();
|
||||||
PlayerState.dashTimer = new Timer(50);
|
PlayerState.dashTimer = new Timer(100);
|
||||||
PlayerState.dashCoolDownTimer = new Timer(600);
|
PlayerState.dashCoolDownTimer = new Timer(600);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Player_Events } from "../../sword_enums";
|
||||||
import InputWrapper from "../../Tools/InputWrapper";
|
import InputWrapper from "../../Tools/InputWrapper";
|
||||||
import { PlayerStates } from "../PlayerController";
|
import { PlayerStates } from "../PlayerController";
|
||||||
import OnGround from "./OnGround";
|
import OnGround from "./OnGround";
|
||||||
|
import PlayerState from "./PlayerState";
|
||||||
|
|
||||||
export default class Walk extends OnGround {
|
export default class Walk extends OnGround {
|
||||||
owner: AnimatedSprite;
|
owner: AnimatedSprite;
|
||||||
|
@ -14,13 +15,17 @@ export default class Walk extends OnGround {
|
||||||
|
|
||||||
|
|
||||||
update(deltaT: number): void {
|
update(deltaT: number): void {
|
||||||
|
if (!PlayerState.dashTimer.isStopped()) {
|
||||||
|
this.owner.animation.playIfNotAlready("DASH");
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (this.parent.invincible) {
|
if (this.parent.invincible) {
|
||||||
this.owner.animation.playIfNotAlready("HURT");
|
this.owner.animation.playIfNotAlready("HURT");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.owner.animation.playIfNotAlready("WALK", true);
|
this.owner.animation.playIfNotAlready("WALK", true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
let dir = this.getInputDirection();
|
let dir = this.getInputDirection();
|
||||||
|
|
||||||
if(dir.isZero()){
|
if(dir.isZero()){
|
||||||
|
|
Loading…
Reference in New Issue
Block a user