There are many ways to implement a jumping mechanic, but the simplest method is to add negative y velocity
temporarily to a FlxObject
with positive y acceleration
.
// call super.update first, as it sets touching flags to NONE
super.update(elapsed);
// If sprite is resting on box it will set its touching to DOWN
FlxG.collide(box, sprite);
// jump if touching the box, and jump is pressed
if (sprite.isTouching(DOWN) && pad.buttonA.pressed)
sprite.velocity.y = -300;