1 decade ago by TheKyngxar
Has anyone followed the HTML5 Game Development with ImpactJS, book?
I'm working through the rpg tutorial but have been stuck for a couple days trying to figure out why my character isn't moving. Here's my player js file. Everything loads up when testing the game but key input does nothing.
I'm working through the rpg tutorial but have been stuck for a couple days trying to figure out why my character isn't moving. Here's my player js file. Everything loads up when testing the game but key input does nothing.
ig.module('game.entities.player') .requires( 'impact.entity') .defines(function(){ EntityPlayer = ig.Entity.extend({ size: {x:32,y:48}, health: 200, animSheet: new ig.AnimationSheet('media/player.png', 32, 48 ), init: function(x,y,settings) { this.parent(x,y,settings); this.addAnim( 'idle',1,[0]); this.addAnim('down',0.1,[0,1,2,3,2,1,0]); this.addAnim('left',0.1,[4,5,6,7,6,5,4]); this.addAnim('right',0.1,[8,9,10,11,10,9,8]); this.addAnim('up',0.1,[12,13,14,15,14,13,12]); }, collides: ig.Entity.COLLIDES.ACTIVE, type: ig.Entity.TYPE.A, checkagainst: ig.Entity.TYPE.B, update: function(){ this.parent(); //Player Movement if(ig.input.state('up')){ this.vel.y = -100; this.currentAnim = this.anims.up; } else if(ig.input.pressed('down')){ this.vel.y = -100; this.currentAnim = this.anims.down; } else if(ig.input.pressed('left')){ this.vel.x = -100; this.currentAnim = this.anims.left; } else if(ig.input.pressed('right')){ this.vel.x = -100; this.currentAnim = this.anims.right; } else{ this.vel.y = 0; this.vel.x = 0; this.currentAnim = this.anims.idle; } } }) });