MakeCode Games!

A fan-made community library of MakeCode Arcade games. Visit MakeCode Arcade to make a game!

← Back to extensions

Retro FX

Add juicy 8-bit sound synthesizers, screen shakes, particle explosions, camera effects, and retro text displays to your games.

knockback

Problem it solves

A player touches an enemy and you want them flung backwards and upwards away from danger.

What this block does

Directly sets the sprite's X and Y velocity components to push them away with force.

The block

Block ID: retro_knockback

knockback $sprite vx $vx vy $vy block

Parameters

NameTypeDefaultMeaning
spriteSpriteEntityThe sprite to apply knockback velocity to.
vxnumber-50Horizontal push velocity.
vynumber-30Vertical push velocity.

Example

let hero = sprites.create(img`.`, SpriteKind.Player)
Retro.knockback(hero, -80, -40)

Add the extension

Add github:CrzLe0723/RetroFx to your project, or open: Import RetroFx.