Everything has been going smooth using Impact except for one thing. I can't seem to figure out how to do a partial jump, just like in the Biolab Disaster demo. Any ideas on a simple way to pull this off? I'm pretty good at javaScript, but I'm guessing I missed something very simple here.
here's a way to do a mario-style jump (i.e tap jump softly for a normal jump, hold the key for a higher jump )
init: function( x, y, settings ) {
this.parent( x, y, settings );
this.jumpTimer = new ig.Timer();
this.jumpAttackVel = -35;
this.jumpSustainVel = -150;
},
if( ig.input.pressed('jump') && this.standing) {
this.jumpTimer.set(0);
this.vel.y = this.jumpAttackVel;
} else if ( ig.input.state('jump') && this.jumpTimer.delta() < 0.25 ) {
this.vel.y = this.jumpSustainVel;;
} else {
this.accel.y = 0;
}
1 decade ago
by MikeH
I wrote a very simple way of doing it that doesn't use timers.
if( this.standing && ig.input.state('jump') ) {
if (this.vel.y == 0){
this.vel.y = -this.jump;
this.falling = false;
}
}else
if(!this.standing && !ig.input.state('jump') && !this.falling) {
this.vel.y = Math.floor(this.vel.y/3);
this.falling = true;
}
Thank you guys for the help, this will help a lot.
Just wanted to add that the first example provided makes the jumps very spacey (like Mario). While the MikeH's example feels more life like. Would be awesome if your examples could be placed in the docs.
Might have to try and figure out how to integrate the first method without timers. Afraid of bloating code for mobile with them.
Page 1 of 1
« first
« previous
next ›
last »