1 decade ago by Yu
Since I'm an artist so I can only copy and paste, try my very best to digest it. Below is my code copied from pong's source. Keys are binded within main.js.
I'm using the up and down buttons but only the animation runs, the entity itself get stucked at the very same position.
I'm using the up and down buttons but only the animation runs, the entity itself get stucked at the very same position.
ig.module( 'game.entities.cutie' ) .requires( 'impact.entity' ) .defines(function(){ EntityCutie = ig.Entity.extend({ size: {x:32, y:32}, collides: ig.Entity.COLLIDES.ACTIVE, animSheet: new ig.AnimationSheet( 'media/cutie.png', 32, 32 ), init: function( x, y, settings ) { this.addAnim( 'idle', 0.1, [0] ); this.addAnim( 'up', 0.1, [9,10,11] ); this.addAnim( 'down', 0.1, [0,1,2] ); this.addAnim( 'left', 0.1, [3,4,5] ); this.parent( x, y, settings ); }, update: function() { if( ig.input.pressed('up') ) { this.currentAnim = this.anims.up; this.vel.y = -100; } else if( ig.input.pressed('down') ) { this.currentAnim = this.anims.down; this.vel.y = 100; } else { this.vel.y = 0 } this.parent(); } });