smart knockback
Problem it solves
An enemy gets hit and you want them knocked in the direction opposite to their current momentum.
What this block does
Adds velocity that automatically considers the sprite's current movement direction to create directional knockback.
The block
Block ID: retro_smart_knockback
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | Object | The sprite receiving smart knockback. |
| vx | number | -50 | Base horizontal knockback force. |
| vy | number | -30 | Base vertical knockback force. |
Example
let enemy = sprites.create(img`.`, SpriteKind.Enemy) Retro.smartKnockback(enemy, -60, -20)
Add the extension
Add github:CrzLe0723/RetroFx to your project, or open: Import RetroFx.