Skip to content

Commit 995720f

Browse files
More testing
1 parent af81bae commit 995720f

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

docs/attach-to-sprite.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# attach To Sprite
2+
3+
Attach a status bar to a sprite.
4+
5+
```sig
6+
statusbars.create(0,0,StatusBarKind.Health).attachToSprite(null)
7+
```
8+
9+
A status bar is attached to a sprite you specify.
10+
The status bar will follow the sprite around the screen instead of being set in a fixed position.
11+
12+
When a status bar is attached to a sprite, you can use the `status bar attached to mySprite`
13+
and `sprite that statusbar is attached to` blocks to get the sprites / status bars that are attached to each other.
14+
15+
## Parameters
16+
17+
* **toFollow**: the sprite to attach to.
18+
* **padding**: an optional [number](types/number) of pixels to pad around the status bar.
19+
* **offset**: an optional [number](types/number) of pixels away from the sprite to place the status bar.
20+
21+
## Example
22+
23+
```blocks
24+
let statusbar = statusbars.create(20, 4, StatusBarKind.Health)
25+
let mySprite = sprites.create(img`
26+
. . . . . . . . . . b 5 b . . .
27+
. . . . . . . . . b 5 b . . . .
28+
. . . . . . b b b b b b . . . .
29+
. . . . . b b 5 5 5 5 5 b . . .
30+
. . . . b b 5 d 1 f 5 d 4 c . .
31+
. . . . b 5 5 1 f f d d 4 4 4 b
32+
. . . . b 5 5 d f b 4 4 4 4 b .
33+
. . . b d 5 5 5 5 4 4 4 4 b . .
34+
. b b d d d 5 5 5 5 5 5 5 b . .
35+
b d d d b b b 5 5 5 5 5 5 5 b .
36+
c d d b 5 5 d c 5 5 5 5 5 5 b .
37+
c b b d 5 d c d 5 5 5 5 5 5 b .
38+
c b 5 5 b c d d 5 5 5 5 5 5 b .
39+
b b c c c d d d 5 5 5 5 5 d b .
40+
. . . . c c d d d 5 5 5 b b . .
41+
. . . . . . c c c c c b b . . .
42+
`, SpriteKind.Player)
43+
controller.moveSprite(mySprite)
44+
statusbar.attachToSprite(mySprite)
45+
```
46+
47+
```package
48+
pxt-status-bar=github:jwunderl/pxt-status-bar
49+
```

pxtextension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace ml {
5656
//% weight=50
5757
//% parts="v2"
5858
//% group="micro:bit (V2)"
59-
//% help=github:pxt-microbit-ml/docs/on-start
59+
//% help=github:microbit-foundation/pxt-microbit-ml/docs/on-start
6060
export function onStart(event: MlEvent, body: () => void): void {
6161
event.onStartHandler = body;
6262
const wrappedBody = () => {
@@ -80,7 +80,7 @@ namespace ml {
8080
//% weight=40
8181
//% parts="v2"
8282
//% group="micro:bit (V2)"
83-
//% help=github:pxt-microbit-ml/README
83+
//% help=github:microbit-foundation/pxt-microbit-ml/README
8484
export function onStop(event: MlEvent, body: () => void): void {
8585
if (!isRunning()) {
8686
startRunning();
@@ -94,6 +94,7 @@ namespace ml {
9494
//% draggableParameters="reporter"
9595
//% parts="v2"
9696
//% group="micro:bit (V2)"
97+
//% help=github:pxt-status-bar/docs/attach-to-sprite
9798
export function onStopDetailed(
9899
event: MlEvent,
99100
body: (duration: number) => void

0 commit comments

Comments
 (0)