1 decade ago by matthew
I'm creating a basic demo based on the Box2D example and for some reason my entity will not move when I hit the mapped key. My code is virtually identical to the demo. The only thing that's really different is that mine is not animating (because there is no animation. I'll include the code, hopefully someone noticing something.
EntityKnocker = ig.Box2DEntity.extend({ size: {x:48, y:24}, //offset: {x: 4, y: 2}, collides: ig.Entity.COLLIDES.NEVER, type: ig.Entity.TYPE.A, checkAgainst: ig.Entity.TYPE.NONE, animSheet: new ig.AnimationSheet('media/cloud.png',48,24), init: function(x, y, settings) { this.parent(x, y, settings); this.addAnim('idle', 1, [0]); }, update: function() { if(ig.input.state('right')) { this.body.ApplyForce( new b2.Vec2(20,0), this.body.GetPosition() ); } this.body.SetXForm(this.body.GetPosition(), 0); // Move it! this.parent(); } });