Sprite jump, with height duration
Problem it solves
You want the player or an enemy to do a smooth, predictable jump into the air and land after a specific amount of time.
What this block does
Calculates vertical launch speed and gravity automatically so the sprite reaches an exact peak height and lands after the given duration.
The block
Block ID: rcRender_jumpWithHeightAndDuration
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The sprite that will jump. |
| height | number | 16 | Maximum jump height in pixels. |
| duration | number | 500 | Total airtime in milliseconds from takeoff to landing. |
Returns
void — Nothing.
Example
controller.A.onEvent(ControllerButtonEvent.Pressed, function () {
Render.jumpWithHeightAndDuration(Render.getRenderSpriteInstance(), 16, 500)
})Add the extension
Add github:The-Code-Zone/Raycasting-pxt-extension to your project, or open: Import Raycasting-pxt-extension.