From 995720fbfc3567f424ee070be7c5af212516833e Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 22 Nov 2024 11:50:50 +0000 Subject: [PATCH] More testing --- docs/attach-to-sprite.md | 49 ++++++++++++++++++++++++++++++++++++++++ pxtextension.ts | 5 ++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 docs/attach-to-sprite.md diff --git a/docs/attach-to-sprite.md b/docs/attach-to-sprite.md new file mode 100644 index 0000000..1931f73 --- /dev/null +++ b/docs/attach-to-sprite.md @@ -0,0 +1,49 @@ +# attach To Sprite + +Attach a status bar to a sprite. + +```sig +statusbars.create(0,0,StatusBarKind.Health).attachToSprite(null) +``` + +A status bar is attached to a sprite you specify. +The status bar will follow the sprite around the screen instead of being set in a fixed position. + +When a status bar is attached to a sprite, you can use the `status bar attached to mySprite` +and `sprite that statusbar is attached to` blocks to get the sprites / status bars that are attached to each other. + +## Parameters + +* **toFollow**: the sprite to attach to. +* **padding**: an optional [number](types/number) of pixels to pad around the status bar. +* **offset**: an optional [number](types/number) of pixels away from the sprite to place the status bar. + +## Example + +```blocks +let statusbar = statusbars.create(20, 4, StatusBarKind.Health) +let mySprite = sprites.create(img` + . . . . . . . . . . b 5 b . . . + . . . . . . . . . b 5 b . . . . + . . . . . . b b b b b b . . . . + . . . . . b b 5 5 5 5 5 b . . . + . . . . b b 5 d 1 f 5 d 4 c . . + . . . . b 5 5 1 f f d d 4 4 4 b + . . . . b 5 5 d f b 4 4 4 4 b . + . . . b d 5 5 5 5 4 4 4 4 b . . + . b b d d d 5 5 5 5 5 5 5 b . . + b d d d b b b 5 5 5 5 5 5 5 b . + c d d b 5 5 d c 5 5 5 5 5 5 b . + c b b d 5 d c d 5 5 5 5 5 5 b . + c b 5 5 b c d d 5 5 5 5 5 5 b . + b b c c c d d d 5 5 5 5 5 d b . + . . . . c c d d d 5 5 5 b b . . + . . . . . . c c c c c b b . . . + `, SpriteKind.Player) +controller.moveSprite(mySprite) +statusbar.attachToSprite(mySprite) +``` + +```package +pxt-status-bar=github:jwunderl/pxt-status-bar +``` \ No newline at end of file diff --git a/pxtextension.ts b/pxtextension.ts index 02e25b8..99e6590 100644 --- a/pxtextension.ts +++ b/pxtextension.ts @@ -56,7 +56,7 @@ namespace ml { //% weight=50 //% parts="v2" //% group="micro:bit (V2)" - //% help=github:pxt-microbit-ml/docs/on-start + //% help=github:microbit-foundation/pxt-microbit-ml/docs/on-start export function onStart(event: MlEvent, body: () => void): void { event.onStartHandler = body; const wrappedBody = () => { @@ -80,7 +80,7 @@ namespace ml { //% weight=40 //% parts="v2" //% group="micro:bit (V2)" - //% help=github:pxt-microbit-ml/README + //% help=github:microbit-foundation/pxt-microbit-ml/README export function onStop(event: MlEvent, body: () => void): void { if (!isRunning()) { startRunning(); @@ -94,6 +94,7 @@ namespace ml { //% draggableParameters="reporter" //% parts="v2" //% group="micro:bit (V2)" + //% help=github:pxt-status-bar/docs/attach-to-sprite export function onStopDetailed( event: MlEvent, body: (duration: number) => void