1 decade ago by Sledge
Greetings All! I am trying to get a bit of code running. I have attached two excerpts from \game\entities\player.js. I define my animations as follows:
I then call inside of the update() method:
Some of you may recognize this code from Jesse Freeman's book. The problem I am having is that none of the animations appear to animate! Each is stuck on the first frame. Otherwise the game runs fine and there are no errors in the console.
I would greatly appreciate any insight into this matter.
setupAnimation: function( offset ) { offset = offset * 10; this.addAnim('idle', 1, [0+offset] ); this.addAnim('run', .07, [0+offset,1+offset,2+offset,3+offset,4+offset,5+offset] ); this.addAnim('jump', 1, [9+offset] ); this.addAnim('fall', .4, [6+offset,7+offset] ); },
I then call inside of the update() method:
this.setupAnimation(this.weapon); if( this.vel.y <0 ) { this.currentAnim = this.anims.jump; }else if( this.vel.y > 0) { this.currentAnim = this.anims.fall; }else if( this.vel.x != 0 ) { this.currentAnim = this.anims.run.rewind(); }else{ this.currentAnim = this.anims.idle; }
Some of you may recognize this code from Jesse Freeman's book. The problem I am having is that none of the animations appear to animate! Each is stuck on the first frame. Otherwise the game runs fine and there are no errors in the console.
I would greatly appreciate any insight into this matter.