fix: hurt animation
This commit is contained in:
parent
f72d2968d1
commit
abebaf2615
|
@ -210,13 +210,65 @@
|
|||
"name": "HURT",
|
||||
"repeat": false,
|
||||
"frames": [
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 500
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 500
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -200,15 +200,63 @@
|
|||
},
|
||||
{
|
||||
"name": "HURT",
|
||||
"repeat": true,
|
||||
"repeat": false,
|
||||
"frames": [
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 50
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 50
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 0,
|
||||
"duration": 5
|
||||
},
|
||||
{
|
||||
"index": 39,
|
||||
"duration": 5
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -112,10 +112,10 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
|
|||
activate(options: Record<string, any>): void { }
|
||||
|
||||
damage(damage: number): void {
|
||||
console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left");
|
||||
this.CURRENT_HP -= damage;
|
||||
//TODO -
|
||||
this.owner.animation.play("HURT",false);
|
||||
console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left");
|
||||
|
||||
// If we're low enough, add Low Health status to enemy
|
||||
if (this.CURRENT_HP <= Math.floor(this.maxHealth/2)) {
|
||||
|
|
|
@ -121,8 +121,8 @@ export default class PlayerController extends StateMachineAI implements BattlerA
|
|||
this.CURRENT_SHIELD = newshield; //update shield value
|
||||
}
|
||||
else{
|
||||
//console.log("hurt anim");
|
||||
(<AnimatedSprite>this.owner).animation.play("HURT" );
|
||||
console.log("hurt anim");
|
||||
(<AnimatedSprite>this.owner).animation.play("HURT", false);
|
||||
this.CURRENT_HP -= damage;
|
||||
if(this.CURRENT_HP <= 0){
|
||||
(<AnimatedSprite>this.owner).animation.play("DYING");
|
||||
|
|
|
@ -7,20 +7,25 @@ export default class Fall extends InAir {
|
|||
owner: AnimatedSprite;
|
||||
|
||||
onEnter(options: Record<string, any>): void {
|
||||
this.owner.animation.play("FALL", true);
|
||||
// this.owner.animation.play("FALL", true);
|
||||
}
|
||||
|
||||
update(deltaT: number): void {
|
||||
super.update(deltaT);
|
||||
|
||||
if (this.parent.invincible) {
|
||||
this.owner.animation.playIfNotAlready("HURT");
|
||||
}
|
||||
else {
|
||||
this.owner.animation.playIfNotAlready("FALL", true);
|
||||
}
|
||||
//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( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){
|
||||
this.parent.airjumps --;
|
||||
this.finished("jump");
|
||||
this.parent.velocity.y = -600; // basically jump height
|
||||
|
||||
}
|
||||
|
||||
super.update(deltaT);
|
||||
}
|
||||
onExit(): Record<string, any> {
|
||||
this.owner.animation.stop();
|
||||
|
|
|
@ -11,10 +11,14 @@ export default class Idle extends OnGround {
|
|||
|
||||
|
||||
update(deltaT: number): void {
|
||||
if (this.parent.invincible) {
|
||||
this.owner.animation.playIfNotAlready("HURT");
|
||||
}
|
||||
else {
|
||||
this.owner.animation.playIfNotAlready("IDLE", true);
|
||||
}
|
||||
|
||||
|
||||
this.owner.animation.playIfNotAlready("IDLE", true);
|
||||
|
||||
let dir = this.getInputDirection();
|
||||
|
||||
if(!dir.isZero() && dir.y === 0){
|
||||
|
|
|
@ -17,9 +17,13 @@ export default class Jump extends InAir {
|
|||
|
||||
|
||||
update(deltaT: number): void {
|
||||
super.update(deltaT);
|
||||
if (this.parent.invincible) {
|
||||
this.owner.animation.playIfNotAlready("HURT");
|
||||
}
|
||||
else {
|
||||
this.owner.animation.playIfNotAlready("JUMP", true);
|
||||
}
|
||||
|
||||
this.owner.animation.play("JUMP", true);
|
||||
|
||||
if(this.owner.onCeiling){
|
||||
this.parent.velocity.y = 0;
|
||||
|
@ -38,6 +42,7 @@ export default class Jump extends InAir {
|
|||
if(this.parent.velocity.y >= 0){
|
||||
this.finished(PlayerStates.FALL);
|
||||
}
|
||||
super.update(deltaT);
|
||||
}
|
||||
|
||||
onExit(): Record<string, any> {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import GameEvent from "../../../Wolfie2D/Events/GameEvent";
|
||||
import Game from "../../../Wolfie2D/Loop/Game";
|
||||
import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite";
|
||||
import MathUtils from "../../../Wolfie2D/Utils/MathUtils";
|
||||
import { GameState } from "../../sword_enums";
|
||||
import InputWrapper from "../../Tools/InputWrapper";
|
||||
import PlayerState from "./PlayerState";
|
||||
|
||||
|
@ -31,7 +33,7 @@ export default class OnGround extends PlayerState {
|
|||
this.parent.velocity.y = -600; // basically jump height
|
||||
|
||||
}
|
||||
else if(!this.owner.onGround){
|
||||
else if(!this.owner.onGround && InputWrapper.getState() === GameState.GAMING){
|
||||
this.finished("fall");
|
||||
}
|
||||
super.update(deltaT);
|
||||
|
|
|
@ -9,12 +9,17 @@ export default class Walk extends OnGround {
|
|||
|
||||
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);
|
||||
if (this.parent.invincible) {
|
||||
this.owner.animation.playIfNotAlready("HURT");
|
||||
}
|
||||
else {
|
||||
this.owner.animation.playIfNotAlready("WALK", true);
|
||||
}
|
||||
|
||||
let dir = this.getInputDirection();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user