1 decade ago by alexandre
From this post, in which ThatAnalog asks:
Here's one (tested) way:
I want the user to be able to tap the button for a small jump, and hold it down for a bigger one
Here's one (tested) way:
jump: 200,
jumpX: 0, // jump extender
update: function()
{
if (ig.input.pressed('jump') && this.standing)
{
this.vel.y = -this.jump;
this.jumpX = 1;
}
if (ig.input.state('jump'))
{
this.vel.y -= this.jump*0.1*this.jumpX;
this.jumpX = (this.jumpX > 0.1 ? this.jumpX*0.95 : 0);
}
this.parent();
}
