jump impulse
Problem it solves
You want a platformer jump that reaches roughly the same height no matter how strong gravity is set to, instead of guessing a velocity by trial and error.
What this block does
Gives a sprite an instant upward velocity, calculated from its current gravity (acceleration y), so it jumps to approximately the given height in pixels.
The block
Block ID: spriteutiljumpimpulse
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite to make jump |
| pixels | number | 34 | The approximate jump height |
Example
let mySprite = sprites.create(img`.`, SpriteKind.Player) let myEnemy = sprites.create(img`.`, SpriteKind.Enemy) mySprite.ay = 200 spriteutils.jumpImpulse(mySprite, 34)
Add the extension
Add github:jwunderl/arcade-sprite-util to your project, or open: Import arcade-sprite-util.