pxt-common-packages 9.5.4 → 9.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35606,7 +35606,7 @@ switch (step) {
35606
35606
  return leave(s, r0)
35607
35607
  default: oops()
35608
35608
  } } }
35609
- Sprite_toString__P65941.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35609
+ Sprite_toString__P65941.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35610
35610
 
35611
35611
  function Sprite_toString__P65941_mk(s) {
35612
35612
  checkStack(s.depth);
@@ -35497,7 +35497,7 @@ switch (step) {
35497
35497
  return leave(s, r0)
35498
35498
  default: oops()
35499
35499
  } } }
35500
- Sprite_toString__P81431.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35500
+ Sprite_toString__P81431.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35501
35501
 
35502
35502
  function Sprite_toString__P81431_mk(s) {
35503
35503
  checkStack(s.depth);
@@ -35027,7 +35027,7 @@ switch (step) {
35027
35027
  return leave(s, r0)
35028
35028
  default: oops()
35029
35029
  } } }
35030
- Sprite_toString__P138985.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"sprite.ts","functionName":"toString","argumentNames":["this"]}
35030
+ Sprite_toString__P138985.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"sprite.ts","functionName":"toString","argumentNames":["this"]}
35031
35031
 
35032
35032
  function Sprite_toString__P138985_mk(s) {
35033
35033
  checkStack(s.depth);
@@ -0,0 +1,66 @@
1
+ # follow
2
+
3
+ Set a sprite to always move to the position of another target sprite.
4
+
5
+ ```sig
6
+ sprites.create(null).follow(null, 0)
7
+ ```
8
+
9
+ When you set a sprite to follow a target sprite, it will move toward the target by "chasing" it with a certain speed. If the sprite can reach the target before it moves again, the sprite will stop and occupy the same location as the target sprite. When not moving, the sprites overlap each other at their center locations.
10
+
11
+ ## Parameters
12
+
13
+ * **target**: the target [sprite](/types/sprite) to follow.
14
+ * **speed**: the maximum chase speed after accelerating, in pixels per second, when moving toward the target sprite.
15
+ * **turnRate**: (optional) the time to take in making a turn to toward the target sprite. For example, using the default rate, `400`, the sprite will reach **speed** in 125 milleseconds when turing 180 degrees to chase the target.
16
+
17
+ ## Example
18
+
19
+ Create 2 sprites. Set the second sprite to follow the first one. Every second, randomly change the position of the first sprite on the screen so that the second sprite will keep chasing it.
20
+
21
+ ```blocks
22
+ let mySprite = sprites.create(img`
23
+ . . . . . . . . . . . . . . . .
24
+ . . . . . . . . . . . . . . . .
25
+ . . . . . 7 7 7 7 7 7 . . . . .
26
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
27
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
28
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
29
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
30
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
31
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
32
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
33
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
34
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
35
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
36
+ . . . . . 7 7 7 7 7 7 . . . . .
37
+ . . . . . . . . . . . . . . . .
38
+ . . . . . . . . . . . . . . . .
39
+ `, SpriteKind.Player)
40
+ let mySprite2 = sprites.create(img`
41
+ . . . . . . . . . . . . . . . .
42
+ . . . . . . . . . . . . . . . .
43
+ . . . . . 5 5 5 5 5 5 . . . . .
44
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
45
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
46
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
47
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
48
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
49
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
50
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
51
+ . . 5 5 5 5 5 5 5 5 5 5 5 5 . .
52
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
53
+ . . . 5 5 5 5 5 5 5 5 5 5 . . .
54
+ . . . . . 5 5 5 5 5 5 . . . . .
55
+ . . . . . . . . . . . . . . . .
56
+ . . . . . . . . . . . . . . . .
57
+ `, SpriteKind.Player)
58
+ mySprite2.follow(mySprite, 50,)
59
+ game.onUpdateInterval(1000, function () {
60
+ mySprite.setPosition(randint(0, scene.screenWidth()), randint(0, scene.screenHeight()))
61
+ })
62
+ ```
63
+
64
+ ## See also
65
+
66
+ [overlaps with](/reference/sprites/sprite/overlaps-with)
@@ -43,7 +43,7 @@ mySprite.vx = 50
43
43
  mySprite.vy = 50
44
44
  ```
45
45
 
46
- ### Boucne on the the edge of the screen
46
+ ### Bounce on the the edge of the screen
47
47
 
48
48
  With a scene that has no tilemap set, make a sprite bounce on the edges of the screen.
49
49
 
@@ -97,4 +97,4 @@ mySprite.vy = 50
97
97
 
98
98
  ## See also
99
99
 
100
- [set flag](/reference/sprites/sprite/set-flag), [set stay in screen](/reference/sprites/sprite/set-stay-in-screen)
100
+ [set flag](/reference/sprites/sprite/set-flag), [set stay in screen](/reference/sprites/sprite/set-stay-in-screen)
@@ -998,6 +998,7 @@ class Sprite extends sprites.BaseSprite {
998
998
  //% group="Physics" weight=10
999
999
  //% blockId=spriteFollowOtherSprite
1000
1000
  //% block="set %sprite(myEnemy) follow %target=variables_get(mySprite) || with speed %speed"
1001
+ //% help=sprites/sprite/follow
1001
1002
  follow(target: Sprite, speed = 100, turnRate = 400) {
1002
1003
  if (target === this) return;
1003
1004
 
@@ -44310,7 +44310,7 @@ switch (step) {
44310
44310
  return leave(s, r0)
44311
44311
  default: oops()
44312
44312
  } } }
44313
- Sprite_toString__P112350.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
44313
+ Sprite_toString__P112350.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
44314
44314
 
44315
44315
  function Sprite_toString__P112350_mk(s) {
44316
44316
  checkStack(s.depth);
@@ -35027,7 +35027,7 @@ switch (step) {
35027
35027
  return leave(s, r0)
35028
35028
  default: oops()
35029
35029
  } } }
35030
- Sprite_toString__P171170.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35030
+ Sprite_toString__P171170.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35031
35031
 
35032
35032
  function Sprite_toString__P171170_mk(s) {
35033
35033
  checkStack(s.depth);
@@ -18,5 +18,8 @@
18
18
  "radio.setTransmitPower|block": "radio set transmit power %power",
19
19
  "radio.setTransmitSerialNumber|block": "radio set transmit serial number %transmit",
20
20
  "radio|block": "radio",
21
- "{id:category}Radio": "Radio"
21
+ "{id:category}Radio": "Radio",
22
+ "{id:group}Group": "Group",
23
+ "{id:group}Receive": "Receive",
24
+ "{id:group}Send": "Send"
22
25
  }
@@ -237,6 +237,7 @@ CODAL_RADIO* getRadio() {
237
237
  //% weight=100
238
238
  //% blockId=radio_set_group block="radio set group %ID"
239
239
  //% id.min=0 id.max=255
240
+ //% group="Group"
240
241
  void setGroup(int id) {
241
242
  #ifdef CODAL_RADIO
242
243
  if (radioEnable() != DEVICE_OK) return;
@@ -14,7 +14,7 @@ enum RadioPacketProperty {
14
14
  /**
15
15
  * Communicate data using radio packets
16
16
  */
17
- //% color=#E3008C weight=96 icon="\uf012"
17
+ //% color=#E3008C weight=96 icon="\uf012" groups='["Group", "Broadcast", "Send", "Receive"]'
18
18
  namespace radio {
19
19
 
20
20
  // keep in sync with CODAL
@@ -95,6 +95,8 @@ namespace radio {
95
95
  //% help=radio/on-received-number
96
96
  //% blockId=radio_on_number_drag block="on radio received" blockGap=16
97
97
  //% useLoc="radio.onDataPacketReceived" draggableParameters=reporter
98
+ //% group="Receive"
99
+ //% weight=20
98
100
  export function onReceivedNumber(cb: (receivedNumber: number) => void) {
99
101
  init();
100
102
  onReceivedNumberHandler = cb;
@@ -106,6 +108,8 @@ namespace radio {
106
108
  //% help=radio/on-received-value
107
109
  //% blockId=radio_on_value_drag block="on radio received" blockGap=16
108
110
  //% useLoc="radio.onDataPacketReceived" draggableParameters=reporter
111
+ //% group="Receive"
112
+ //% weight=19
109
113
  export function onReceivedValue(cb: (name: string, value: number) => void) {
110
114
  init();
111
115
  onReceivedValueHandler = cb;
@@ -117,6 +121,8 @@ namespace radio {
117
121
  //% help=radio/on-received-string
118
122
  //% blockId=radio_on_string_drag block="on radio received" blockGap=16
119
123
  //% useLoc="radio.onDataPacketReceived" draggableParameters=reporter
124
+ //% group="Receive"
125
+ //% weight=18
120
126
  export function onReceivedString(cb: (receivedString: string) => void) {
121
127
  init();
122
128
  onReceivedStringHandler = cb;
@@ -138,8 +144,10 @@ namespace radio {
138
144
  * @param type the type of property to retrieve from the last packet
139
145
  */
140
146
  //% help=radio/received-packet
141
- //% weight=11 blockGap=8
147
+ //% blockGap=8
142
148
  //% blockId=radio_received_packet block="received packet %type=radio_packet_property" blockGap=16
149
+ //% group="Receive"
150
+ //% weight=16
143
151
  export function receivedPacket(type: number) {
144
152
  if (lastPacket) {
145
153
  switch (type) {
@@ -272,6 +280,7 @@ namespace radio {
272
280
  //% help=radio/send-number
273
281
  //% weight=60
274
282
  //% blockId=radio_datagram_send block="radio send number %value" blockGap=8
283
+ //% group="Send"
275
284
  export function sendNumber(value: number) {
276
285
  let packet: RadioPacket;
277
286
 
@@ -296,6 +305,7 @@ namespace radio {
296
305
  //% help=radio/send-value
297
306
  //% weight=59
298
307
  //% blockId=radio_datagram_send_value block="radio send|value %name|= %value" blockGap=8
308
+ //% group="Send"
299
309
  export function sendValue(name: string, value: number) {
300
310
  let packet: RadioPacket;
301
311
 
@@ -319,6 +329,7 @@ namespace radio {
319
329
  //% weight=58
320
330
  //% blockId=radio_datagram_send_string block="radio send string %msg"
321
331
  //% msg.shadowOptions.toString=true
332
+ //% group="Send"
322
333
  export function sendString(value: string) {
323
334
  const packet = RadioPacket.mkPacket(PACKET_TYPE_STRING);
324
335
  packet.stringPayload = value;
@@ -58,7 +58,8 @@ declare namespace radio {
58
58
  //% help=radio/set-group
59
59
  //% weight=100
60
60
  //% blockId=radio_set_group block="radio set group %ID"
61
- //% id.min=0 id.max=255 shim=radio::setGroup
61
+ //% id.min=0 id.max=255
62
+ //% group="Group" shim=radio::setGroup
62
63
  function setGroup(id: int32): void;
63
64
 
64
65
  /**
@@ -2,5 +2,6 @@
2
2
  "radio.onReceivedMessage|block": "on radio $msg received",
3
3
  "radio.sendMessage|block": "radio send $msg",
4
4
  "radio|block": "radio",
5
- "{id:category}Radio": "Radio"
5
+ "{id:category}Radio": "Radio",
6
+ "{id:group}Broadcast": "Broadcast"
6
7
  }
@@ -21,6 +21,7 @@ namespace radio {
21
21
  //% weight=200
22
22
  //% blockGap=8
23
23
  //% help=radio/send-message
24
+ //% group="Broadcast"
24
25
  export function sendMessage(msg: number): void {
25
26
  // 0 is MICROBIT_EVT_ANY, shifting by 1
26
27
  radio.raiseEvent(BROADCAST_GENERAL_ID, msg + 1);
@@ -35,6 +36,7 @@ namespace radio {
35
36
  //% msg.shadow=radioMessageCode draggableParameters
36
37
  //% weight=199
37
38
  //% help=radio/on-received-message
39
+ //% group="Broadcast"
38
40
  export function onReceivedMessage(msg: number, handler: () => void) {
39
41
  control.onEvent(BROADCAST_GENERAL_ID, msg + 1, handler);
40
42
  }
@@ -35027,7 +35027,7 @@ switch (step) {
35027
35027
  return leave(s, r0)
35028
35028
  default: oops()
35029
35029
  } } }
35030
- Sprite_toString__P191659.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35030
+ Sprite_toString__P191659.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35031
35031
 
35032
35032
  function Sprite_toString__P191659_mk(s) {
35033
35033
  checkStack(s.depth);
@@ -35027,7 +35027,7 @@ switch (step) {
35027
35027
  return leave(s, r0)
35028
35028
  default: oops()
35029
35029
  } } }
35030
- Sprite_toString__P154569.info = {"start":37683,"length":93,"line":1169,"column":4,"endLine":1171,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35030
+ Sprite_toString__P154569.info = {"start":37718,"length":93,"line":1170,"column":4,"endLine":1172,"endColumn":5,"fileName":"pxt_modules/game/sprite.ts","functionName":"toString","argumentNames":["this"]}
35031
35031
 
35032
35032
  function Sprite_toString__P154569_mk(s) {
35033
35033
  checkStack(s.depth);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pxt-common-packages",
3
- "version": "9.5.4",
3
+ "version": "9.5.5",
4
4
  "description": "Microsoft MakeCode (PXT) common packages",
5
5
  "keywords": [
6
6
  "MakeCode",