pxt-common-packages 9.5.2 → 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.
@@ -882,6 +882,8 @@ declare namespace pxsim.radio {
882
882
  function sendRawPacket(buf: RefBuffer): void;
883
883
  function readRawPacket(): RefBuffer;
884
884
  function onDataReceived(handler: RefAction): void;
885
+ function off(): void;
886
+ function on(): void;
885
887
  }
886
888
  declare namespace pxsim {
887
889
  interface RadioBoard extends EventBusBoard {
@@ -924,12 +926,15 @@ declare namespace pxsim {
924
926
  datagram: RadioDatagram;
925
927
  groupId: number;
926
928
  band: number;
929
+ enable: boolean;
927
930
  constructor(runtime: Runtime, board: BaseBoard, dal: RadioDAL);
928
931
  private handleMessage;
929
932
  setGroup(id: number): void;
930
933
  setTransmitPower(power: number): void;
931
934
  setTransmitSerialNumber(sn: boolean): void;
932
935
  setFrequencyBand(band: number): void;
936
+ off(): void;
937
+ on(): void;
933
938
  raiseEvent(id: number, eventid: number): void;
934
939
  receivePacket(packet: SimulatorRadioPacketMessage): void;
935
940
  }
@@ -3119,11 +3119,13 @@ var pxsim;
3119
3119
  function sendRawPacket(buf) {
3120
3120
  let cb = pxsim.getResume();
3121
3121
  const state = pxsim.getRadioState();
3122
- state.datagram.send({
3123
- type: 0,
3124
- groupId: state.groupId,
3125
- bufferData: buf.data
3126
- });
3122
+ if (state.enable) {
3123
+ state.datagram.send({
3124
+ type: 0,
3125
+ groupId: state.groupId,
3126
+ bufferData: buf.data
3127
+ });
3128
+ }
3127
3129
  setTimeout(cb, 1);
3128
3130
  }
3129
3131
  radio.sendRawPacket = sendRawPacket;
@@ -3147,6 +3149,16 @@ var pxsim;
3147
3149
  state.datagram.onReceived(handler);
3148
3150
  }
3149
3151
  radio.onDataReceived = onDataReceived;
3152
+ function off() {
3153
+ const state = pxsim.getRadioState();
3154
+ state.off();
3155
+ }
3156
+ radio.off = off;
3157
+ function on() {
3158
+ const state = pxsim.getRadioState();
3159
+ state.on();
3160
+ }
3161
+ radio.on = on;
3150
3162
  })(radio = pxsim.radio || (pxsim.radio = {}));
3151
3163
  })(pxsim || (pxsim = {}));
3152
3164
  var pxsim;
@@ -3215,6 +3227,7 @@ var pxsim;
3215
3227
  this.power = 6; // default value
3216
3228
  this.groupId = 0;
3217
3229
  this.band = 7; // https://github.com/lancaster-university/microbit-dal/blob/master/inc/core/MicroBitConfig.h#L320
3230
+ this.enable = true;
3218
3231
  this.board.addMessageListener(this.handleMessage.bind(this));
3219
3232
  }
3220
3233
  handleMessage(msg) {
@@ -3224,34 +3237,51 @@ var pxsim;
3224
3237
  }
3225
3238
  }
3226
3239
  setGroup(id) {
3227
- this.groupId = id & 0xff; // byte only
3240
+ if (this.enable) {
3241
+ this.groupId = id & 0xff; // byte only
3242
+ }
3228
3243
  }
3229
3244
  setTransmitPower(power) {
3230
- power = power | 0;
3231
- this.power = Math.max(0, Math.min(7, power));
3245
+ if (this.enable) {
3246
+ power = power | 0;
3247
+ this.power = Math.max(0, Math.min(7, power));
3248
+ }
3232
3249
  }
3233
3250
  setTransmitSerialNumber(sn) {
3234
3251
  this.transmitSerialNumber = !!sn;
3235
3252
  }
3236
3253
  setFrequencyBand(band) {
3237
- band = band | 0;
3238
- if (band < 0 || band > 83)
3239
- return;
3240
- this.band = band;
3254
+ if (this.enable) {
3255
+ band = band | 0;
3256
+ if (band < 0 || band > 83)
3257
+ return;
3258
+ this.band = band;
3259
+ }
3260
+ }
3261
+ off() {
3262
+ this.enable = false;
3263
+ }
3264
+ on() {
3265
+ this.enable = true;
3241
3266
  }
3242
3267
  raiseEvent(id, eventid) {
3243
- pxsim.Runtime.postMessage({
3244
- type: "eventbus",
3245
- broadcast: true,
3246
- id,
3247
- eventid,
3248
- power: this.power,
3249
- group: this.groupId
3250
- });
3268
+ if (this.enable) {
3269
+ pxsim.Runtime.postMessage({
3270
+ type: "eventbus",
3271
+ broadcast: true,
3272
+ id,
3273
+ eventid,
3274
+ power: this.power,
3275
+ group: this.groupId
3276
+ });
3277
+ }
3251
3278
  }
3252
3279
  receivePacket(packet) {
3253
- if (this.groupId == packet.payload.groupId)
3254
- this.datagram.queue(packet);
3280
+ if (this.enable) {
3281
+ if (this.groupId == packet.payload.groupId) {
3282
+ this.datagram.queue(packet);
3283
+ }
3284
+ }
3255
3285
  }
3256
3286
  }
3257
3287
  pxsim.RadioState = RadioState;
@@ -27874,7 +27874,7 @@ switch (step) {
27874
27874
  return leave(s, r0)
27875
27875
  default: oops()
27876
27876
  } } }
27877
- tiles_TileMap_isOnWall__P66260.info = {"start":16824,"length":627,"line":533,"column":8,"endLine":550,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
27877
+ tiles_TileMap_isOnWall__P66260.info = {"start":16837,"length":627,"line":534,"column":8,"endLine":551,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
27878
27878
 
27879
27879
  function tiles_TileMap_isOnWall__P66260_mk(s) {
27880
27880
  checkStack(s.depth);
@@ -27964,7 +27964,7 @@ switch (step) {
27964
27964
  return leave(s, r0)
27965
27965
  default: oops()
27966
27966
  } } }
27967
- tiles_TileMap_isObstacle__P66258.info = {"start":16183,"length":211,"line":514,"column":8,"endLine":519,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
27967
+ tiles_TileMap_isObstacle__P66258.info = {"start":16196,"length":211,"line":515,"column":8,"endLine":520,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
27968
27968
 
27969
27969
  function tiles_TileMap_isObstacle__P66258_mk(s) {
27970
27970
  checkStack(s.depth);
@@ -29618,7 +29618,7 @@ switch (step) {
29618
29618
  return leave(s, r0)
29619
29619
  default: oops()
29620
29620
  } } }
29621
- tiles_getTileImage__P66272.info = {"start":21815,"length":207,"line":672,"column":4,"endLine":676,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
29621
+ tiles_getTileImage__P66272.info = {"start":21828,"length":207,"line":673,"column":4,"endLine":677,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
29622
29622
 
29623
29623
  function tiles_getTileImage__P66272_mk(s) {
29624
29624
  checkStack(s.depth);
@@ -29759,7 +29759,7 @@ switch (step) {
29759
29759
  return leave(s, r0)
29760
29760
  default: oops()
29761
29761
  } } }
29762
- tiles_TileMap_getTileIndex__P66250.info = {"start":11142,"length":105,"line":383,"column":8,"endLine":385,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
29762
+ tiles_TileMap_getTileIndex__P66250.info = {"start":11155,"length":105,"line":384,"column":8,"endLine":386,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
29763
29763
 
29764
29764
  function tiles_TileMap_getTileIndex__P66250_mk(s) {
29765
29765
  checkStack(s.depth);
@@ -29879,7 +29879,7 @@ switch (step) {
29879
29879
  return leave(s, r0)
29880
29880
  default: oops()
29881
29881
  } } }
29882
- tiles_TileMap_getTileImage__P66261.info = {"start":17461,"length":96,"line":552,"column":8,"endLine":554,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
29882
+ tiles_TileMap_getTileImage__P66261.info = {"start":17474,"length":96,"line":553,"column":8,"endLine":555,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
29883
29883
 
29884
29884
  function tiles_TileMap_getTileImage__P66261_mk(s) {
29885
29885
  checkStack(s.depth);
@@ -30129,7 +30129,7 @@ switch (step) {
30129
30129
  return leave(s, r0)
30130
30130
  default: oops()
30131
30131
  } } }
30132
- tiles_TileMap_getTile__P66249.info = {"start":11021,"length":111,"line":379,"column":8,"endLine":381,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
30132
+ tiles_TileMap_getTile__P66249.info = {"start":11034,"length":111,"line":380,"column":8,"endLine":382,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
30133
30133
 
30134
30134
  function tiles_TileMap_getTile__P66249_mk(s) {
30135
30135
  checkStack(s.depth);
@@ -30753,7 +30753,7 @@ switch (step) {
30753
30753
  return leave(s, r0)
30754
30754
  default: oops()
30755
30755
  } } }
30756
- tiles_TileMap_getObstacle__P66259.info = {"start":16404,"length":410,"line":521,"column":8,"endLine":531,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
30756
+ tiles_TileMap_getObstacle__P66259.info = {"start":16417,"length":410,"line":522,"column":8,"endLine":532,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
30757
30757
 
30758
30758
  function tiles_TileMap_getObstacle__P66259_mk(s) {
30759
30759
  checkStack(s.depth);
@@ -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);
@@ -37040,7 +37040,7 @@ switch (step) {
37040
37040
  return leave(s, r0)
37041
37041
  default: oops()
37042
37042
  } } }
37043
- tiles_TileMap_draw__P66257.info = {"start":13949,"length":2224,"line":457,"column":8,"endLine":512,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
37043
+ tiles_TileMap_draw__P66257.info = {"start":13962,"length":2224,"line":458,"column":8,"endLine":513,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
37044
37044
 
37045
37045
  function tiles_TileMap_draw__P66257_mk(s) {
37046
37046
  checkStack(s.depth);
@@ -27765,7 +27765,7 @@ switch (step) {
27765
27765
  return leave(s, r0)
27766
27766
  default: oops()
27767
27767
  } } }
27768
- tiles_TileMap_isOnWall__P81750.info = {"start":16824,"length":627,"line":533,"column":8,"endLine":550,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
27768
+ tiles_TileMap_isOnWall__P81750.info = {"start":16837,"length":627,"line":534,"column":8,"endLine":551,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
27769
27769
 
27770
27770
  function tiles_TileMap_isOnWall__P81750_mk(s) {
27771
27771
  checkStack(s.depth);
@@ -27855,7 +27855,7 @@ switch (step) {
27855
27855
  return leave(s, r0)
27856
27856
  default: oops()
27857
27857
  } } }
27858
- tiles_TileMap_isObstacle__P81748.info = {"start":16183,"length":211,"line":514,"column":8,"endLine":519,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
27858
+ tiles_TileMap_isObstacle__P81748.info = {"start":16196,"length":211,"line":515,"column":8,"endLine":520,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
27859
27859
 
27860
27860
  function tiles_TileMap_isObstacle__P81748_mk(s) {
27861
27861
  checkStack(s.depth);
@@ -29509,7 +29509,7 @@ switch (step) {
29509
29509
  return leave(s, r0)
29510
29510
  default: oops()
29511
29511
  } } }
29512
- tiles_getTileImage__P81762.info = {"start":21815,"length":207,"line":672,"column":4,"endLine":676,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
29512
+ tiles_getTileImage__P81762.info = {"start":21828,"length":207,"line":673,"column":4,"endLine":677,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
29513
29513
 
29514
29514
  function tiles_getTileImage__P81762_mk(s) {
29515
29515
  checkStack(s.depth);
@@ -29650,7 +29650,7 @@ switch (step) {
29650
29650
  return leave(s, r0)
29651
29651
  default: oops()
29652
29652
  } } }
29653
- tiles_TileMap_getTileIndex__P81740.info = {"start":11142,"length":105,"line":383,"column":8,"endLine":385,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
29653
+ tiles_TileMap_getTileIndex__P81740.info = {"start":11155,"length":105,"line":384,"column":8,"endLine":386,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
29654
29654
 
29655
29655
  function tiles_TileMap_getTileIndex__P81740_mk(s) {
29656
29656
  checkStack(s.depth);
@@ -29770,7 +29770,7 @@ switch (step) {
29770
29770
  return leave(s, r0)
29771
29771
  default: oops()
29772
29772
  } } }
29773
- tiles_TileMap_getTileImage__P81751.info = {"start":17461,"length":96,"line":552,"column":8,"endLine":554,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
29773
+ tiles_TileMap_getTileImage__P81751.info = {"start":17474,"length":96,"line":553,"column":8,"endLine":555,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
29774
29774
 
29775
29775
  function tiles_TileMap_getTileImage__P81751_mk(s) {
29776
29776
  checkStack(s.depth);
@@ -30020,7 +30020,7 @@ switch (step) {
30020
30020
  return leave(s, r0)
30021
30021
  default: oops()
30022
30022
  } } }
30023
- tiles_TileMap_getTile__P81739.info = {"start":11021,"length":111,"line":379,"column":8,"endLine":381,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
30023
+ tiles_TileMap_getTile__P81739.info = {"start":11034,"length":111,"line":380,"column":8,"endLine":382,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
30024
30024
 
30025
30025
  function tiles_TileMap_getTile__P81739_mk(s) {
30026
30026
  checkStack(s.depth);
@@ -30644,7 +30644,7 @@ switch (step) {
30644
30644
  return leave(s, r0)
30645
30645
  default: oops()
30646
30646
  } } }
30647
- tiles_TileMap_getObstacle__P81749.info = {"start":16404,"length":410,"line":521,"column":8,"endLine":531,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
30647
+ tiles_TileMap_getObstacle__P81749.info = {"start":16417,"length":410,"line":522,"column":8,"endLine":532,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
30648
30648
 
30649
30649
  function tiles_TileMap_getObstacle__P81749_mk(s) {
30650
30650
  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);
@@ -36931,7 +36931,7 @@ switch (step) {
36931
36931
  return leave(s, r0)
36932
36932
  default: oops()
36933
36933
  } } }
36934
- tiles_TileMap_draw__P81747.info = {"start":13949,"length":2224,"line":457,"column":8,"endLine":512,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
36934
+ tiles_TileMap_draw__P81747.info = {"start":13962,"length":2224,"line":458,"column":8,"endLine":513,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
36935
36935
 
36936
36936
  function tiles_TileMap_draw__P81747_mk(s) {
36937
36937
  checkStack(s.depth);
@@ -27260,7 +27260,7 @@ switch (step) {
27260
27260
  return leave(s, r0)
27261
27261
  default: oops()
27262
27262
  } } }
27263
- tiles_TileMap_isOnWall__P139304.info = {"start":16824,"length":627,"line":533,"column":8,"endLine":550,"endColumn":9,"fileName":"tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
27263
+ tiles_TileMap_isOnWall__P139304.info = {"start":16837,"length":627,"line":534,"column":8,"endLine":551,"endColumn":9,"fileName":"tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
27264
27264
 
27265
27265
  function tiles_TileMap_isOnWall__P139304_mk(s) {
27266
27266
  checkStack(s.depth);
@@ -27350,7 +27350,7 @@ switch (step) {
27350
27350
  return leave(s, r0)
27351
27351
  default: oops()
27352
27352
  } } }
27353
- tiles_TileMap_isObstacle__P139302.info = {"start":16183,"length":211,"line":514,"column":8,"endLine":519,"endColumn":9,"fileName":"tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
27353
+ tiles_TileMap_isObstacle__P139302.info = {"start":16196,"length":211,"line":515,"column":8,"endLine":520,"endColumn":9,"fileName":"tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
27354
27354
 
27355
27355
  function tiles_TileMap_isObstacle__P139302_mk(s) {
27356
27356
  checkStack(s.depth);
@@ -29004,7 +29004,7 @@ switch (step) {
29004
29004
  return leave(s, r0)
29005
29005
  default: oops()
29006
29006
  } } }
29007
- tiles_getTileImage__P139316.info = {"start":21815,"length":207,"line":672,"column":4,"endLine":676,"endColumn":5,"fileName":"tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
29007
+ tiles_getTileImage__P139316.info = {"start":21828,"length":207,"line":673,"column":4,"endLine":677,"endColumn":5,"fileName":"tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
29008
29008
 
29009
29009
  function tiles_getTileImage__P139316_mk(s) {
29010
29010
  checkStack(s.depth);
@@ -29145,7 +29145,7 @@ switch (step) {
29145
29145
  return leave(s, r0)
29146
29146
  default: oops()
29147
29147
  } } }
29148
- tiles_TileMap_getTileIndex__P139294.info = {"start":11142,"length":105,"line":383,"column":8,"endLine":385,"endColumn":9,"fileName":"tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
29148
+ tiles_TileMap_getTileIndex__P139294.info = {"start":11155,"length":105,"line":384,"column":8,"endLine":386,"endColumn":9,"fileName":"tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
29149
29149
 
29150
29150
  function tiles_TileMap_getTileIndex__P139294_mk(s) {
29151
29151
  checkStack(s.depth);
@@ -29265,7 +29265,7 @@ switch (step) {
29265
29265
  return leave(s, r0)
29266
29266
  default: oops()
29267
29267
  } } }
29268
- tiles_TileMap_getTileImage__P139305.info = {"start":17461,"length":96,"line":552,"column":8,"endLine":554,"endColumn":9,"fileName":"tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
29268
+ tiles_TileMap_getTileImage__P139305.info = {"start":17474,"length":96,"line":553,"column":8,"endLine":555,"endColumn":9,"fileName":"tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
29269
29269
 
29270
29270
  function tiles_TileMap_getTileImage__P139305_mk(s) {
29271
29271
  checkStack(s.depth);
@@ -29515,7 +29515,7 @@ switch (step) {
29515
29515
  return leave(s, r0)
29516
29516
  default: oops()
29517
29517
  } } }
29518
- tiles_TileMap_getTile__P139293.info = {"start":11021,"length":111,"line":379,"column":8,"endLine":381,"endColumn":9,"fileName":"tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
29518
+ tiles_TileMap_getTile__P139293.info = {"start":11034,"length":111,"line":380,"column":8,"endLine":382,"endColumn":9,"fileName":"tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
29519
29519
 
29520
29520
  function tiles_TileMap_getTile__P139293_mk(s) {
29521
29521
  checkStack(s.depth);
@@ -30139,7 +30139,7 @@ switch (step) {
30139
30139
  return leave(s, r0)
30140
30140
  default: oops()
30141
30141
  } } }
30142
- tiles_TileMap_getObstacle__P139303.info = {"start":16404,"length":410,"line":521,"column":8,"endLine":531,"endColumn":9,"fileName":"tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
30142
+ tiles_TileMap_getObstacle__P139303.info = {"start":16417,"length":410,"line":522,"column":8,"endLine":532,"endColumn":9,"fileName":"tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
30143
30143
 
30144
30144
  function tiles_TileMap_getObstacle__P139303_mk(s) {
30145
30145
  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);
@@ -36461,7 +36461,7 @@ switch (step) {
36461
36461
  return leave(s, r0)
36462
36462
  default: oops()
36463
36463
  } } }
36464
- tiles_TileMap_draw__P139301.info = {"start":13949,"length":2224,"line":457,"column":8,"endLine":512,"endColumn":9,"fileName":"tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
36464
+ tiles_TileMap_draw__P139301.info = {"start":13962,"length":2224,"line":458,"column":8,"endLine":513,"endColumn":9,"fileName":"tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
36465
36465
 
36466
36466
  function tiles_TileMap_draw__P139301_mk(s) {
36467
36467
  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)
@@ -116,7 +116,6 @@ namespace scene {
116
116
  if (!scene.tileMap)
117
117
  scene.tileMap = new tiles.TileMap();
118
118
  scene.tileMap.setData(map);
119
- scene.tileMap.scale = map.scale;
120
119
  }
121
120
 
122
121
  /**
@@ -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
 
@@ -357,16 +357,17 @@ namespace tiles {
357
357
  const previous = this._map;
358
358
 
359
359
  if (this.handlerState && previous !== map && previous) {
360
- if (map) {
361
- for (const eventHandler of this.handlerState) {
362
- if (eventHandler.event === TileMapEvent.Unloaded) {
363
- eventHandler.callback(previous);
364
- }
360
+ for (const eventHandler of this.handlerState) {
361
+ if (eventHandler.event === TileMapEvent.Unloaded) {
362
+ eventHandler.callback(previous);
365
363
  }
366
364
  }
367
365
  }
368
366
 
369
367
  this._map = map;
368
+ if (map) {
369
+ this._scale = map.scale;
370
+ }
370
371
 
371
372
  if (this.handlerState && previous !== map && map) {
372
373
  for (const eventHandler of this.handlerState) {
@@ -56,7 +56,7 @@ const pxsim_pxtrt = pxsim.pxtrt;
56
56
  const pxsim_numops = pxsim.numops;
57
57
 
58
58
 
59
- function _main___P188722(s) {
59
+ function _main___P188726(s) {
60
60
  let r0 = s.r0, step = s.pc;
61
61
  s.pc = -1;
62
62
 
@@ -66,19 +66,19 @@ if (yieldSteps-- < 0 && maybeYield(s, step, r0) || runtime !== pxsim.runtime) re
66
66
  switch (step) {
67
67
  case 0:
68
68
 
69
- globals._intervals___188965 = (undefined);
70
- globals._pollEventQueue___188978 = (undefined);
69
+ globals._intervals___188969 = (undefined);
70
+ globals._pollEventQueue___188982 = (undefined);
71
71
  r0 = undefined;
72
72
  return leave(s, r0)
73
73
  default: oops()
74
74
  } } }
75
- _main___P188722.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
- _main___P188722.continuations = [ ]
75
+ _main___P188726.info = {"start":0,"length":0,"line":0,"column":0,"endLine":0,"endColumn":0,"fileName":"keypad.ts","functionName":"<main>","argumentNames":[]}
76
+ _main___P188726.continuations = [ ]
77
77
 
78
- function _main___P188722_mk(s) {
78
+ function _main___P188726_mk(s) {
79
79
  checkStack(s.depth);
80
80
  return {
81
- parent: s, fn: _main___P188722, depth: s.depth + 1,
81
+ parent: s, fn: _main___P188726, depth: s.depth + 1,
82
82
  pc: 0, retval: undefined, r0: undefined, overwrittenPC: false, lambdaArgs: null,
83
83
  } }
84
84
 
@@ -88,5 +88,5 @@ function _main___P188722_mk(s) {
88
88
 
89
89
  const breakpoints = setupDebugger(1, [])
90
90
 
91
- return _main___P188722
91
+ return _main___P188726
92
92
  })
@@ -36049,7 +36049,7 @@ switch (step) {
36049
36049
  return leave(s, r0)
36050
36050
  default: oops()
36051
36051
  } } }
36052
- tiles_TileMap_isOnWall__P112669.info = {"start":16824,"length":627,"line":533,"column":8,"endLine":550,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
36052
+ tiles_TileMap_isOnWall__P112669.info = {"start":16837,"length":627,"line":534,"column":8,"endLine":551,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isOnWall","argumentNames":["this","s"]}
36053
36053
 
36054
36054
  function tiles_TileMap_isOnWall__P112669_mk(s) {
36055
36055
  checkStack(s.depth);
@@ -36139,7 +36139,7 @@ switch (step) {
36139
36139
  return leave(s, r0)
36140
36140
  default: oops()
36141
36141
  } } }
36142
- tiles_TileMap_isObstacle__P112667.info = {"start":16183,"length":211,"line":514,"column":8,"endLine":519,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
36142
+ tiles_TileMap_isObstacle__P112667.info = {"start":16196,"length":211,"line":515,"column":8,"endLine":520,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"isObstacle","argumentNames":["this","col","row"]}
36143
36143
 
36144
36144
  function tiles_TileMap_isObstacle__P112667_mk(s) {
36145
36145
  checkStack(s.depth);
@@ -37793,7 +37793,7 @@ switch (step) {
37793
37793
  return leave(s, r0)
37794
37794
  default: oops()
37795
37795
  } } }
37796
- tiles_getTileImage__P112681.info = {"start":21815,"length":207,"line":672,"column":4,"endLine":676,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
37796
+ tiles_getTileImage__P112681.info = {"start":21828,"length":207,"line":673,"column":4,"endLine":677,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
37797
37797
 
37798
37798
  function tiles_getTileImage__P112681_mk(s) {
37799
37799
  checkStack(s.depth);
@@ -37934,7 +37934,7 @@ switch (step) {
37934
37934
  return leave(s, r0)
37935
37935
  default: oops()
37936
37936
  } } }
37937
- tiles_TileMap_getTileIndex__P112659.info = {"start":11142,"length":105,"line":383,"column":8,"endLine":385,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
37937
+ tiles_TileMap_getTileIndex__P112659.info = {"start":11155,"length":105,"line":384,"column":8,"endLine":386,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileIndex","argumentNames":["this","col","row"]}
37938
37938
 
37939
37939
  function tiles_TileMap_getTileIndex__P112659_mk(s) {
37940
37940
  checkStack(s.depth);
@@ -38054,7 +38054,7 @@ switch (step) {
38054
38054
  return leave(s, r0)
38055
38055
  default: oops()
38056
38056
  } } }
38057
- tiles_TileMap_getTileImage__P112670.info = {"start":17461,"length":96,"line":552,"column":8,"endLine":554,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
38057
+ tiles_TileMap_getTileImage__P112670.info = {"start":17474,"length":96,"line":553,"column":8,"endLine":555,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["this","index"]}
38058
38058
 
38059
38059
  function tiles_TileMap_getTileImage__P112670_mk(s) {
38060
38060
  checkStack(s.depth);
@@ -38304,7 +38304,7 @@ switch (step) {
38304
38304
  return leave(s, r0)
38305
38305
  default: oops()
38306
38306
  } } }
38307
- tiles_TileMap_getTile__P112658.info = {"start":11021,"length":111,"line":379,"column":8,"endLine":381,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
38307
+ tiles_TileMap_getTile__P112658.info = {"start":11034,"length":111,"line":380,"column":8,"endLine":382,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTile","argumentNames":["this","col","row"]}
38308
38308
 
38309
38309
  function tiles_TileMap_getTile__P112658_mk(s) {
38310
38310
  checkStack(s.depth);
@@ -38928,7 +38928,7 @@ switch (step) {
38928
38928
  return leave(s, r0)
38929
38929
  default: oops()
38930
38930
  } } }
38931
- tiles_TileMap_getObstacle__P112668.info = {"start":16404,"length":410,"line":521,"column":8,"endLine":531,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
38931
+ tiles_TileMap_getObstacle__P112668.info = {"start":16417,"length":410,"line":522,"column":8,"endLine":532,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getObstacle","argumentNames":["this","col","row"]}
38932
38932
 
38933
38933
  function tiles_TileMap_getObstacle__P112668_mk(s) {
38934
38934
  checkStack(s.depth);
@@ -43533,7 +43533,7 @@ switch (step) {
43533
43533
  return leave(s, r0)
43534
43534
  default: oops()
43535
43535
  } } }
43536
- tiles_TileMap_draw__P112666.info = {"start":13949,"length":2224,"line":457,"column":8,"endLine":512,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
43536
+ tiles_TileMap_draw__P112666.info = {"start":13962,"length":2224,"line":458,"column":8,"endLine":513,"endColumn":9,"fileName":"pxt_modules/game/tilemap.ts","functionName":"draw","argumentNames":["this","target","camera"]}
43537
43537
 
43538
43538
  function tiles_TileMap_draw__P112666_mk(s) {
43539
43539
  checkStack(s.depth);
@@ -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);