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.

flashlight source attached to

Problem it solves

Your player changed walking directions and you need to update the flashlight's aim angle so the beam points wherever the player moves.

What this block does

Gets the flashlight object attached to a sprite so you can read or modify its direction, lightRange, and angleRange properties.

The block

true block

Parameters

NameTypeDefaultMeaning
spriteSpritemySpriteThe sprite whose attached flashlight you want to access.

Returns

lightsource.FlashlightLightSource — The flashlight object attached to the sprite, allowing you to update its direction or range.

Example

let player = sprites.create(img`.`, SpriteKind.Player)
multilights.addFlashLightSource(player, 0, 48, 40, 5)
let flash = multilights.flashlightSourceAttachedTo(player)
flash.direction = 180

Add the extension

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