pxt-common-packages 9.4.1 → 9.4.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.
Files changed (65) hide show
  1. package/built/common-sim.d.ts +8 -0
  2. package/built/common-sim.js +74 -0
  3. package/libs/azureiot/built/debug/binary.js +461 -461
  4. package/libs/color/built/debug/binary.js +8 -8
  5. package/libs/color-sensor/built/debug/binary.js +8 -8
  6. package/libs/controller/built/debug/binary.js +7126 -6975
  7. package/libs/controller---none/built/debug/binary.js +7105 -6954
  8. package/libs/core---esp32/pins.cpp +30 -4
  9. package/libs/core---esp32/shims.d.ts +15 -0
  10. package/libs/core---esp32s2/shims.d.ts +15 -0
  11. package/libs/datalogger/built/debug/binary.js +63 -63
  12. package/libs/edge-connector/built/debug/binary.js +8 -8
  13. package/libs/esp32/built/debug/binary.js +462 -462
  14. package/libs/game/_locales/game-jsdoc-strings.json +10 -1
  15. package/libs/game/_locales/game-strings.json +18 -2
  16. package/libs/game/assetTemplates.ts +2 -0
  17. package/libs/game/built/debug/binary.js +7018 -6867
  18. package/libs/game/docs/reference/scene/get-tile-location.md +96 -0
  19. package/libs/game/docs/reference/scene/get-tiles-by-type.md +64 -43
  20. package/libs/game/docs/reference/scene/is-hitting-tile.md +87 -0
  21. package/libs/game/docs/reference/scene/on-hit-wall.md +88 -0
  22. package/libs/game/docs/reference/scene/on-overlap-tile.md +88 -0
  23. package/libs/game/docs/reference/scene/place-on-random-tile.md +95 -41
  24. package/libs/game/docs/reference/scene/place-on-tile.md +88 -0
  25. package/libs/game/docs/reference/scene/set-tile-at.md +45 -41
  26. package/libs/game/docs/reference/scene/set-tilemap.md +89 -0
  27. package/libs/game/docs/reference/scene/set-wall-at.md +86 -0
  28. package/libs/game/docs/reference/scene/tile-at-location-equals.md +97 -0
  29. package/libs/game/docs/reference/scene/tile-kind-at.md +118 -0
  30. package/libs/game/docs/reference/scene.md +20 -16
  31. package/libs/game/docs/reference/sprites/sprite/ax.md +34 -3
  32. package/libs/game/docs/reference/sprites/sprite/ay.md +34 -3
  33. package/libs/game/docs/reference/sprites/sprite/fx.md +123 -0
  34. package/libs/game/docs/reference/sprites/sprite/fy.md +123 -0
  35. package/libs/game/docs/reference/sprites.md +2 -0
  36. package/libs/game/physics.ts +1 -1
  37. package/libs/game/renderText.ts +74 -11
  38. package/libs/game/scenes.ts +5 -1
  39. package/libs/game/sprite.ts +23 -6
  40. package/libs/game/spriteevents.ts +7 -7
  41. package/libs/game/sprites.ts +16 -0
  42. package/libs/game/spritesay.ts +204 -51
  43. package/libs/game/tilemap.ts +173 -27
  44. package/libs/lcd/built/debug/binary.js +8 -8
  45. package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
  46. package/libs/lora/built/debug/binary.js +8 -8
  47. package/libs/matrix-keypad/built/debug/binary.js +8 -8
  48. package/libs/mqtt/built/debug/binary.js +176 -176
  49. package/libs/net/built/debug/binary.js +176 -176
  50. package/libs/net-game/built/debug/binary.js +8802 -8651
  51. package/libs/palette/built/debug/binary.js +7017 -6866
  52. package/libs/pixel/built/debug/binary.js +8 -8
  53. package/libs/power/built/debug/binary.js +8 -8
  54. package/libs/proximity/built/debug/binary.js +8 -8
  55. package/libs/radio/built/debug/binary.js +8 -8
  56. package/libs/radio-broadcast/built/debug/binary.js +8 -8
  57. package/libs/rotary-encoder/built/debug/binary.js +8 -8
  58. package/libs/screen/built/debug/binary.js +50 -50
  59. package/libs/servo/built/debug/binary.js +8 -8
  60. package/libs/storyboard/built/debug/binary.js +7017 -6866
  61. package/libs/text-to-speech/pxt.json +14 -0
  62. package/libs/text-to-speech/shims.d.ts +47 -0
  63. package/libs/text-to-speech/sim/tts.ts +72 -0
  64. package/libs/text-to-speech/tts.ts +70 -0
  65. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ # get Tile Location
2
+
3
+ Get the tile location object for a particular column and row position in the tilemap.
4
+
5
+ ```sig
6
+ tiles.getTileLocation(0, 0)
7
+ ```
8
+
9
+ A tile location object represents a column and a row position in the tilemap. Location objects are used to get and set tiles or tile information for specific places in the tilemap.
10
+
11
+ ## Parameters
12
+
13
+ * **col**: a [number](/types/number) that is the tilemap column of the tile location.
14
+ * **row**: a [number](/types/number) that is the tilemap row of the tile location.
15
+
16
+ ## Returns
17
+
18
+ * a tile location object for a given column and row in the tilemap.
19
+
20
+ ## Example #example
21
+
22
+ Make a grid tilemap with two tile colors. Create a round shaped sprite. Ramdomly choose a tile location to place the sprite at in the grid.
23
+
24
+ ```blocks
25
+ tiles.setTilemap(tilemap`level1`)
26
+ let mySprite = sprites.create(img`
27
+ . . . . . . . . . . . . . . . .
28
+ . . . . . . . . . . . . . . . .
29
+ . . . . . 7 7 7 7 7 7 . . . . .
30
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
31
+ . . . 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 7 7 . .
35
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
36
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
37
+ . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
38
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
39
+ . . . 7 7 7 7 7 7 7 7 7 7 . . .
40
+ . . . . . 7 7 7 7 7 7 . . . . .
41
+ . . . . . . . . . . . . . . . .
42
+ . . . . . . . . . . . . . . . .
43
+ `, SpriteKind.Player)
44
+
45
+ forever(function () {
46
+ tiles.placeOnTile(mySprite, tiles.getTileLocation(randint(0, 9), randint(0, 6)))
47
+ pause(500)
48
+ })
49
+ ```
50
+
51
+ ## Returns
52
+
53
+ * a tile location for the column and row specifed.
54
+
55
+ ## See also #seealso
56
+
57
+ [set tile at](/reference/scene/set-tile-at),
58
+ [place on tile](/reference/scene/place-on-tile)
59
+
60
+ ```jres
61
+ {
62
+ "transparency16": {
63
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
64
+ "mimeType": "image/x-mkcd-f4",
65
+ "tilemapTile": true
66
+ },
67
+ "tile1": {
68
+ "data": "hwQQABAAAADd3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3Q==",
69
+ "mimeType": "image/x-mkcd-f4",
70
+ "tilemapTile": true,
71
+ "displayName": "myTile"
72
+ },
73
+ "tile2": {
74
+ "data": "hwQQABAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==",
75
+ "mimeType": "image/x-mkcd-f4",
76
+ "tilemapTile": true,
77
+ "displayName": "myTile0"
78
+ },
79
+ "level1": {
80
+ "id": "level1",
81
+ "mimeType": "application/mkcd-tilemap",
82
+ "data": "MTAwYTAwMDgwMDAxMDIwMTAyMDEwMjAxMDIwMTAyMDIwMTAyMDEwMjAxMDIwMTAyMDEwMTAyMDEwMjAxMDIwMTAyMDEwMjAyMDEwMjAxMDIwMTAyMDEwMjAxMDEwMjAxMDIwMTAyMDEwMjAxMDIwMjAxMDIwMTAyMDEwMjAxMDIwMTAxMDIwMTAyMDEwMjAxMDIwMTAyMDIwMTAyMDEwMjAxMDIwMTAyMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
83
+ "tileset": [
84
+ "myTiles.transparency16",
85
+ "myTiles.tile1",
86
+ "myTiles.tile2"
87
+ ],
88
+ "displayName": "level1"
89
+ },
90
+ "*": {
91
+ "mimeType": "image/x-mkcd-f4",
92
+ "dataEncoding": "base64",
93
+ "namespace": "myTiles"
94
+ }
95
+ }
96
+ ```
@@ -1,65 +1,86 @@
1
1
  # get Tiles By Type
2
2
 
3
- Get a list of tiles in the tilemap that have the same color index.
3
+ Return an array of tile locations from the tilemap that contain the specified tile.
4
4
 
5
5
  ```sig
6
- scene.getTilesByType(0)
6
+ tiles.getTilesByType(null)
7
7
  ```
8
8
 
9
- All the tiles in the tilemap with the chosen **index** are returned in an array of [tiles](/types/tile). You can use this array to change or replace the tiles as one group.
10
-
11
9
  ## Parameters
12
10
 
13
- * **index**: the color index to the tiles to make a list for.
11
+ * **tile**: a tile [image](/types/image) to search the tilemap for.
14
12
 
15
13
  ## Returns
16
14
 
17
- * an [array](/types/array) of [tiles](/types/tile) from the tilemap that have the same color **index**.
15
+ * an [array](/types/array) of tile locations from the tilemap that have the tile specified in **tile**.
18
16
 
19
17
  ## Example #example
20
18
 
21
- Get a list of all the tiles in the center of the tilemap. Replace all of them with the tile type used for the border.
19
+ Make a column of tiles from top to bottom of the screen. Set a sprite in motion and set it to bounce on walls. Every `5` seconds, find the column tiles in the tilemap and set them as either wall tiles or regular tiles.
22
20
 
23
21
  ```blocks
24
- scene.setTile(2, img`
25
- a a a a a a a a a a a a a a a a
26
- a a a a a a a a a a a a a a a a
27
- a a a a a a a a a a a a a a a a
28
- a a a a a a a a a a a a a a a a
29
- a a a a a a a a a a a a a a a a
30
- a a a a a a a a a a a a a a a a
31
- a a a a a a a a a a a a a a a a
32
- a a a a a a a a a a a a a a a a
33
- a a a a a a a a a a a a a a a a
34
- a a a a a a a a a a a a a a a a
35
- a a a a a a a a a a a a a a a a
36
- a a a a a a a a a a a a a a a a
37
- a a a a a a a a a a a a a a a a
38
- a a a a a a a a a a a a a a a a
39
- a a a a a a a a a a a a a a a a
40
- a a a a a a a a a a a a a a a a
41
- `)
42
- scene.setTileMap(img`
43
- 2 2 2 2 2 2 2 2 2 2
44
- 2 8 . . . 8 . . . 2
45
- 2 . 8 . 8 . 8 . 8 2
46
- 2 . . 8 . . . 8 . 2
47
- 2 . 8 . 8 . 8 . 8 2
48
- 2 8 . . . 8 . . . 2
49
- 2 2 2 2 2 2 2 2 2 2
50
- . . . . . . . . . .
51
- `)
52
- for (let tile of scene.getTilesByType(8)) {
53
- scene.setTileAt(tile, 2)
54
- pause(500)
55
- }
22
+ let isWall = false
23
+ tiles.setTilemap(tilemap`level1`)
24
+ let mySprite = sprites.create(img`
25
+ . . . . . . . . . . . . . . . .
26
+ . . . . . . . . . . . . . . . .
27
+ . . . . . 1 1 1 1 1 1 . . . . .
28
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
29
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
30
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
31
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
32
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
33
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
34
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
35
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
36
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
37
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
38
+ . . . . . 1 1 1 1 1 1 . . . . .
39
+ . . . . . . . . . . . . . . . .
40
+ . . . . . . . . . . . . . . . .
41
+ `, SpriteKind.Player)
42
+ mySprite.setBounceOnWall(true)
43
+ mySprite.vx = 80
44
+ mySprite.vy = 70
45
+ game.onUpdateInterval(5000, function () {
46
+ isWall = !(isWall)
47
+ for (let wallTile of tiles.getTilesByType(assets.tile`myTile`)) {
48
+ tiles.setWallAt(wallTile, isWall)
49
+ }
50
+ })
56
51
  ```
57
52
 
58
53
  ## See also #seealso
59
54
 
60
- [get tile](/reference/scene/get-tile),
61
- [set tile at](/reference/scene/set-tile-at)
55
+ [get tile location](/reference/scene/get-tile-location)
62
56
 
63
- ```package
64
- color-coded-tilemap
57
+ ```jres
58
+ {
59
+ "transparency16": {
60
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
61
+ "mimeType": "image/x-mkcd-f4",
62
+ "tilemapTile": true
63
+ },
64
+ "tile1": {
65
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
66
+ "mimeType": "image/x-mkcd-f4",
67
+ "tilemapTile": true,
68
+ "displayName": "myTile"
69
+ },
70
+ "level1": {
71
+ "id": "level1",
72
+ "mimeType": "application/mkcd-tilemap",
73
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
74
+ "tileset": [
75
+ "myTiles.transparency16",
76
+ "myTiles.tile1"
77
+ ],
78
+ "displayName": "level1"
79
+ },
80
+ "*": {
81
+ "mimeType": "image/x-mkcd-f4",
82
+ "dataEncoding": "base64",
83
+ "namespace": "myTiles"
84
+ }
85
+ }
65
86
  ```
@@ -0,0 +1,87 @@
1
+ # is Hitting Tile
2
+
3
+ Check if a sprite is currently hitting a wall.
4
+
5
+ ```sig
6
+ sprites.create(null).isHittingTile(CollisionDirection.Right)
7
+ ```
8
+
9
+ A wall is either a tile set as a wall or the edge of the scene if a tilemap is set.
10
+
11
+ ## Parameters
12
+
13
+ * **direction**: the direction the sprite moves toward when detecting a wall collision: `left`, `right`, `top`, or `bottom`.
14
+
15
+ ## Returns
16
+
17
+ * a [boolean](/types/boolean) value that is `true` if the sprite is hitting a wall on the chosen side or `false` if not.
18
+
19
+ ## Example #example
20
+
21
+ Make a tilemap with a wall going from top to bottom. Set a sprite in motion and make it say "Ouch!" when it hits the wall on its `right` side.
22
+
23
+ ```blocks
24
+ tiles.setTilemap(tilemap`level1`)
25
+ let mySprite = sprites.create(img`
26
+ . . . . . . . . . . . . . . . .
27
+ . . . . . . . . . . . . . . . .
28
+ . . . . . 1 1 1 1 1 1 . . . . .
29
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
30
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
31
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
32
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
33
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
34
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
35
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
36
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
37
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
38
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
39
+ . . . . . 1 1 1 1 1 1 . . . . .
40
+ . . . . . . . . . . . . . . . .
41
+ . . . . . . . . . . . . . . . .
42
+ `, SpriteKind.Player)
43
+ mySprite.setBounceOnWall(true)
44
+ mySprite.vx = 80
45
+ mySprite.vy = 70
46
+ forever(function () {
47
+ if (mySprite.isHittingTile(CollisionDirection.Right)) {
48
+ mySprite.sayText("Ouch!", 200, false)
49
+ }
50
+ })
51
+ ```
52
+
53
+ ## See also #seealso
54
+
55
+ [tile kind at](/reference/scene/tile-kind-at),
56
+ [set tile at](/reference/scene/set-tile-at)
57
+
58
+ ```jres
59
+ {
60
+ "transparency16": {
61
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
62
+ "mimeType": "image/x-mkcd-f4",
63
+ "tilemapTile": true
64
+ },
65
+ "tile1": {
66
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
67
+ "mimeType": "image/x-mkcd-f4",
68
+ "tilemapTile": true,
69
+ "displayName": "myTile"
70
+ },
71
+ "level1": {
72
+ "id": "level1",
73
+ "mimeType": "application/mkcd-tilemap",
74
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDEwMDAwMDAwMDAwMDAwMDAwMDAwMTAwMDAwMDAwMDAyMDAwMDAwMDAwMjAwMDAwMDAwMDIwMDAwMDAwMDAyMDAwMDAwMDAwMjAwMDAwMDAwMDIwMDAwMDAwMDAyMDAwMDAwMDAwMjAwMA==",
75
+ "tileset": [
76
+ "myTiles.transparency16",
77
+ "myTiles.tile1"
78
+ ],
79
+ "displayName": "level1"
80
+ },
81
+ "*": {
82
+ "mimeType": "image/x-mkcd-f4",
83
+ "dataEncoding": "base64",
84
+ "namespace": "myTiles"
85
+ }
86
+ }
87
+ ```
@@ -0,0 +1,88 @@
1
+ # on Hit Wall
2
+
3
+ Run code when a sprite contacts a wall tile.
4
+
5
+ ```sig
6
+ scene.onHitWall(SpriteKind.Player, function (sprite, location) { })
7
+ ```
8
+
9
+ You can detect when a moving sprite contacts a wall tile in the tilemap. If your sprite touches a tile that is set as a wall, you can have some code that runs when that happens. You pick the sprite **kind** to check for.
10
+
11
+ When a wall hit is detected by the sprite of the kind you asked for, it is given to you in the **sprite** parameter of **handler** along with contacted tile's **location**.
12
+
13
+ A sprite hitting a wall is dectected when the outside edges of its image makes contact with the tile. If a sprite has it's ``ghost`` flag set, any contact with the wall tile isn't noticed.
14
+
15
+ ## Parameters
16
+
17
+ * **kind**: the type of sprite to check for a wall hit.
18
+ * **handler**: the code to run when the sprite makes contact. The handler has these parameters passed to it:
19
+ >* **sprite**: the sprite that hit the wall tile.
20
+ >* **location**: the location of the wall the sprite contacted in the tilemap.
21
+
22
+ ## Example #example
23
+
24
+ Create a tilemap with wall tiles surrounding the sides of the scene. Set a sprite in motion and cause it to bounce on wall tiles. When the sprite contacts the wall tiles, make a short fire effect on the sprite.
25
+
26
+ ```blocks
27
+ scene.onHitWall(SpriteKind.Player, function (sprite, location) {
28
+ sprite.startEffect(effects.fire, 200)
29
+ })
30
+ tiles.setTilemap(tilemap`level1`)
31
+ let mySprite = sprites.create(img`
32
+ . . . . . . . . . . . . . . . .
33
+ . . . . . . . . . . . . . . . .
34
+ . . . . . 1 1 1 1 1 1 . . . . .
35
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
36
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
37
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
38
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
39
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
40
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
41
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
42
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
43
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
44
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
45
+ . . . . . 1 1 1 1 1 1 . . . . .
46
+ . . . . . . . . . . . . . . . .
47
+ . . . . . . . . . . . . . . . .
48
+ `, SpriteKind.Player)
49
+ mySprite.setBounceOnWall(true)
50
+ mySprite.vx = 80
51
+ mySprite.vy = 70
52
+ ```
53
+
54
+ ## See also #seealso
55
+
56
+ [get tile location](/reference/scene/get-tile-location),
57
+ [set wall at](/reference/scene/set-wall-at)
58
+
59
+ ```jres
60
+ {
61
+ "transparency16": {
62
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
63
+ "mimeType": "image/x-mkcd-f4",
64
+ "tilemapTile": true
65
+ },
66
+ "tile1": {
67
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
68
+ "mimeType": "image/x-mkcd-f4",
69
+ "tilemapTile": true,
70
+ "displayName": "myTile"
71
+ },
72
+ "level1": {
73
+ "id": "level1",
74
+ "mimeType": "application/mkcd-tilemap",
75
+ "data": "MTAwYTAwMDgwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMDAwMDAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMDAwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEyMjIyMjIyMjIyMDIwMDAwMDAyMDAyMDAwMDAwMjAwMjAwMDAwMDIwMDIwMDAwMDAyMDAyMDAwMDAwMjAwMjAwMDAwMDIwMjIyMjIyMjIyMg==",
76
+ "tileset": [
77
+ "myTiles.transparency16",
78
+ "myTiles.tile1"
79
+ ],
80
+ "displayName": "level1"
81
+ },
82
+ "*": {
83
+ "mimeType": "image/x-mkcd-f4",
84
+ "dataEncoding": "base64",
85
+ "namespace": "myTiles"
86
+ }
87
+ }
88
+ ```
@@ -0,0 +1,88 @@
1
+ # on Overlap Tile
2
+
3
+ Run code when a sprite overlaps a tile.
4
+
5
+ ```sig
6
+ scene.onOverlapTile(SpriteKind.Player, null, function (sprite, location) {})
7
+ ```
8
+
9
+ You can detect when a moving sprite overlaps a tile in the tilemap. If your sprite moves across a tile, you can have some code that runs when that happens. You pick the sprite **kind** to check for.
10
+
11
+ When an overlap is detected by the sprite of the kind you asked for, it is given to you in the **sprite** parameter of **handler** along with overlapped tile's **location**.
12
+
13
+ A sprite hitting a wall is dectected when the outside edges of its image makes starts to overlap the tile.
14
+
15
+ ## Parameters
16
+
17
+ * **kind**: the type of sprite to check for a overlap.
18
+ * **handler**: the code to run when the sprite overlaps a tile. The handler has these parameters passed to it:
19
+ >* **sprite**: the sprite that overlapped the tile.
20
+ >* **location**: the location of the tile that the sprite overlapped in the tilemap.
21
+
22
+ ## Example #example
23
+
24
+ Create a tilemap with a section of tiles in the center of the scene. Set a sprite in motion and cause it to bounce on walls. When the sprite overlaps the tiles, make it trace a trail across the tiles.
25
+
26
+ ```blocks
27
+ scene.onOverlapTile(SpriteKind.Player, assets.tile`myTile`, function (sprite, location) {
28
+ sprite.startEffect(effects.trail, 100)
29
+ })
30
+ tiles.setTilemap(tilemap`level1`)
31
+ let mySprite = sprites.create(img`
32
+ . . . . . . . . . . . . . . . .
33
+ . . . . . . . . . . . . . . . .
34
+ . . . . . 1 1 1 1 1 1 . . . . .
35
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
36
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
37
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
38
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
39
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
40
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
41
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
42
+ . . 1 2 2 2 2 2 2 2 2 2 2 1 . .
43
+ . . . 1 2 2 2 2 2 2 2 2 1 . . .
44
+ . . . 1 1 2 2 2 2 2 2 1 1 . . .
45
+ . . . . . 1 1 1 1 1 1 . . . . .
46
+ . . . . . . . . . . . . . . . .
47
+ . . . . . . . . . . . . . . . .
48
+ `, SpriteKind.Player)
49
+ mySprite.setBounceOnWall(true)
50
+ mySprite.vx = 80
51
+ mySprite.vy = 70
52
+ ```
53
+
54
+ ## See also #seealso
55
+
56
+ [get tile location](/reference/scene/get-tile-location),
57
+ [on hit wall](/reference/scene/on-hit-wall)
58
+
59
+ ```jres
60
+ {
61
+ "transparency16": {
62
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
63
+ "mimeType": "image/x-mkcd-f4",
64
+ "tilemapTile": true
65
+ },
66
+ "tile1": {
67
+ "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
68
+ "mimeType": "image/x-mkcd-f4",
69
+ "tilemapTile": true,
70
+ "displayName": "myTile"
71
+ },
72
+ "level1": {
73
+ "id": "level1",
74
+ "mimeType": "application/mkcd-tilemap",
75
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDEwMTAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMDAwMDAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMDAwMDAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
76
+ "tileset": [
77
+ "myTiles.transparency16",
78
+ "myTiles.tile1"
79
+ ],
80
+ "displayName": "level1"
81
+ },
82
+ "*": {
83
+ "mimeType": "image/x-mkcd-f4",
84
+ "dataEncoding": "base64",
85
+ "namespace": "myTiles"
86
+ }
87
+ }
88
+ ```
@@ -3,63 +3,117 @@
3
3
  Move a sprite's position to the center of a random tile in the scene.
4
4
 
5
5
  ```sig
6
- scene.placeOnRandomTile(null, 0)
6
+ tiles.placeOnRandomTile(null, null)
7
7
  ```
8
8
 
9
- You a can make a sprite to locate itself right on top of a random tile in the tile map. Use the color number of type of tile to select for the sprite to locate on one of them.
10
-
9
+ You can make a sprite locate itself right on top of a random tile in the tilemap. Choose a tile in the tilemap to indicate which type of tile to have the sprite randomly placed on. If there is only one tile of that type, the sprite will always go to that tile. If multiple tiles of the same type are in the tilemap, then the sprite will randomly locate on any one of them.
11
10
 
12
11
  ## Parameters
13
12
 
14
13
  * **sprite**: the sprite to move onto the tile.
15
- * **color**: the color [number](/types/number) of a tile to randomly select.
14
+ * **tile**: the tile type to randomly select in the tilemap.
16
15
 
17
16
  ## Example #example
18
17
 
19
- Make a tilemap with several different tiles. Create a round shaped sprite. Ramdomly place the sprite on a tile with color number `8`.
18
+ Make a tilemap with several different tiles. Create a round shaped sprite. Ramdomly place the sprite on a blue tile.
20
19
 
21
20
  ```blocks
22
- enum SpriteKind {
23
- Player,
24
- Enemy
25
- }
26
- let mySprite: Sprite = null
27
- scene.setTileMap(img`
28
- . . . . . . . . 3 .
29
- . 2 . . . . . . . .
30
- . . . . . 8 . . . .
31
- . . . . . . . b . .
32
- . . 8 . 6 . . . . .
33
- . . . . . . 4 . . .
34
- . a . . . . . . . .
35
- . . . . . . . . e .
36
- `)
37
- mySprite = sprites.create(img`
38
- . . . . . . . . . . . . . . . .
39
- . . . . . . . . . . . . . . . .
40
- . . . . . 7 7 7 7 7 7 . . . . .
41
- . . . 7 7 7 7 7 7 7 7 7 7 . . .
42
- . . . 7 7 7 7 7 7 7 7 7 7 . . .
43
- . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
44
- . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
45
- . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
46
- . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
47
- . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
48
- . . 7 7 7 7 7 7 7 7 7 7 7 7 . .
49
- . . . 7 7 7 7 7 7 7 7 7 7 . . .
50
- . . . 7 7 7 7 7 7 7 7 7 7 . . .
51
- . . . . . 7 7 7 7 7 7 . . . . .
52
- . . . . . . . . . . . . . . . .
53
- . . . . . . . . . . . . . . . .
54
- `, SpriteKind.Player)
21
+ tiles.setTilemap(tilemap`level1`)
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)
55
40
  pause(1000)
56
- scene.placeOnRandomTile(mySprite, 8)
41
+ tiles.placeOnRandomTile(mySprite, assets.tile`myTile`)
57
42
  ```
58
43
 
59
44
  ## See also #seealso
60
45
 
61
46
  [get tile](/reference/scene/get-tile)
62
47
 
63
- ```package
64
- color-coded-tilemap
48
+ ```jres
49
+ {
50
+ "transparency16": {
51
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
52
+ "mimeType": "image/x-mkcd-f4",
53
+ "tilemapTile": true
54
+ },
55
+ "tile7": {
56
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
57
+ "mimeType": "image/x-mkcd-f4",
58
+ "tilemapTile": true,
59
+ "displayName": "myTile5"
60
+ },
61
+ "tile1": {
62
+ "data": "hwQQABAAAACIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiA==",
63
+ "mimeType": "image/x-mkcd-f4",
64
+ "tilemapTile": true,
65
+ "displayName": "myTile"
66
+ },
67
+ "tile2": {
68
+ "data": "hwQQABAAAAAiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIg==",
69
+ "mimeType": "image/x-mkcd-f4",
70
+ "tilemapTile": true,
71
+ "displayName": "myTile0"
72
+ },
73
+ "tile3": {
74
+ "data": "hwQQABAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==",
75
+ "mimeType": "image/x-mkcd-f4",
76
+ "tilemapTile": true,
77
+ "displayName": "myTile1"
78
+ },
79
+ "tile4": {
80
+ "data": "hwQQABAAAAB3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3dw==",
81
+ "mimeType": "image/x-mkcd-f4",
82
+ "tilemapTile": true,
83
+ "displayName": "myTile2"
84
+ },
85
+ "tile5": {
86
+ "data": "hwQQABAAAACqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==",
87
+ "mimeType": "image/x-mkcd-f4",
88
+ "tilemapTile": true,
89
+ "displayName": "myTile3"
90
+ },
91
+ "tile6": {
92
+ "data": "hwQQABAAAACZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmQ==",
93
+ "mimeType": "image/x-mkcd-f4",
94
+ "tilemapTile": true,
95
+ "displayName": "myTile4"
96
+ },
97
+ "level1": {
98
+ "id": "level1",
99
+ "mimeType": "application/mkcd-tilemap",
100
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDAwMDAzMDAwMDAwMDAwMDA2MDAwMDAwMDAwMDAyMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDMwMDAwMDAwMDAwMDAwMDA1MDAwMDAwMDAwMTAwMDAwMDAwMDAwMDA0MDAwMDAwMDAwMDAwMDYwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
101
+ "tileset": [
102
+ "myTiles.transparency16",
103
+ "myTiles.tile1",
104
+ "myTiles.tile2",
105
+ "myTiles.tile3",
106
+ "myTiles.tile4",
107
+ "myTiles.tile5",
108
+ "myTiles.tile6",
109
+ "myTiles.tile7"
110
+ ],
111
+ "displayName": "level1"
112
+ },
113
+ "*": {
114
+ "mimeType": "image/x-mkcd-f4",
115
+ "dataEncoding": "base64",
116
+ "namespace": "myTiles"
117
+ }
118
+ }
65
119
  ```