MakeCode Games!

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

← Back to extensions

Lantern

Create dark levels with dynamic lighting effects like circular lanterns, glowing torches, and directional flashlights.

add flash light source

Problem it solves

Your player is searching an abandoned house with a flashlight that should only reveal what is directly in the direction they are facing.

What this block does

Attaches a directional cone of light to a sprite in the multi-light system, controlling its angle, direction, and beam range.

The block

true block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite holding the flashlight.
directionnumber0The aiming angle in degrees (0 is right, 90 is down, 180 is left, 270 is up).
lightRangenumber32How far forward the flashlight beam reaches in pixels.
angleRangenumber30How wide the flashlight beam spread is in degrees.
bandWidthnumber5The softness and edge width of the light beam.

Example

let player = sprites.create(img`.`, SpriteKind.Player)
multilights.toggleLighting(true)
multilights.addFlashLightSource(player, 0, 48, 40, 5)

Add the extension

Add github:felixtsu/pxt-lantern to your project, or open: Import pxt-lantern.