-1
var newGame = {};
newGame.Game.prototype =  {
prepareToJump: function() {
if (ninja.body.velocity.y == 0) {
  powerBar = game.add.sprite(ninja.x, ninja.y - 50, "powerbar");
  powerBar.width = 0;
  powerTween = game.add.tween(powerBar).to({
    width: 100
  }, 1000, "Linear", true);
  game.input.onDown.remove(newGame.Game.prototype.prepareToJump, this);
  game.input.onUp.add(newGame.Game.prototype.jump, this);
}

},
jump: function() {
this.prepareToJump(); // undefinded
//but we can use newGame.Game.prototype.prepareToJump();
}
}

Why can't I use this.prepareToJump()?

Sam
  • 7,252
  • 16
  • 46
  • 65

1 Answers1

0

You dont use it like

this.prepareToJump()

But like this since its inside the constructor

this.prepareToJump