Jumper Component


When entity is about to jump. This event is triggered with the object the entity is about to jump from (if it exists). Third parties can respond to this event and enable the entity to jump.

Make the entity jump in response to key events. Simulates jumping and falling when used with the Gravity component.

Additionally, this component provides the entity with Supportable, Motion and Keyboard methods & events.


Back to top


The canJump function determines if the entity is allowed to jump or not (e.g. perhaps the entity should be able to double jump). The Jumper component will trigger a "CheckJumping" event. Interested parties can listen to this event and enable the entity to jump by setting canJump to true.


var player = Crafty.e("2D, Jumper");
player.hasDoubleJumpPowerUp = true; // allow player to double jump by granting him a powerup
player.bind("CheckJumping", function(ground) {
    if (!ground && player.hasDoubleJumpPowerUp) { // allow player to double jump by using up his double jump powerup
        player.canJump = true;
        player.hasDoubleJumpPowerUp = false;
player.bind("LandedOnGround", function(ground) {
    player.hasDoubleJumpPowerUp = true; // give player new double jump powerup upon landing
Back to top


public this .jump()

Directly trigger the entity to jump.

Back to top


public this .jumper([Number jumpSpeed,] Array jumpKeys)

Vertical jump speed in pixels per second


Keys to listen for and make entity jump in response

public this .jumper([Number jumpSpeed,] Object jumpInputs)

Vertical jump speed in pixels per second


An object with two properties, keys and mouseButtons.

Constructor to initialize the power of jump and keys to listen to. Component will listen for key events and make the entity jump appropriately.

If second argument is an object, the properties keys and mouseButtons will be used as triggers.


this.jumper(300, ['UP_ARROW', 'W']);
this.jumper(['UP_ARROW', 'W']);

See Also

Back to top


public this .jumpSpeed(Number jumpSpeed)

new vertical jump speed

Change the vertical jump speed.