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.

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

smart knockback $sprite vx $vx vy $vy block

Parameters

NameTypeDefaultMeaning
spriteSpriteObjectThe sprite receiving smart knockback.
vxnumber-50Base horizontal knockback force.
vynumber-30Base 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.