Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by denniss

I am following the book "HTML5 Game Development" and I am at the point where I am supposed to make my character move. When I put my character on a non-collision tile, I can&039;t seem to move the character even after I put some logging inside my #update function.

update:function () {
        var accel = this.standing ? this.accelGround : this.accelAir;
        if (ig.input.state('left')) {
          this.accel.x = -accel;
          this.flip = true;
        } else if (ig.input.state('right')) {
          this.accel.x = accel;
          this.flip = false;
        } else {
          this.accel.x = 0;
        }

        //jump
        if (this.standing && ig.input.pressed('jump')) {
          this.vel.y = -this.jump;
        }
        this.parent();
      },

1 decade ago by Hareesun

Just checking, in your main.js file, does your init function look like this...

    init: function() {
      ig.input.bind(ig.KEY.LEFT_ARROW, 'left');
      ig.input.bind(ig.KEY.RIGHT_ARROW, 'right');
      ig.input.bind(ig.KEY.X, 'jump');
    },

Also, when pasting code wrap it in two ##'s above and below the snippet. So the #'s have their own line. :)
Page 1 of 1
« first « previous next › last »