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
Parameters
| Name | Type | Default | Meaning |
|---|---|---|---|
| sprite | Sprite | mySprite | The 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.