pxt-common-packages 9.5.5 → 9.5.6

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.
@@ -1,51 +1,92 @@
1
1
  # get Tile Location
2
2
 
3
- Get a tile location from the tilemap.
3
+ Get the tile location object for a particular column and row position in the tilemap.
4
4
 
5
5
  ```sig
6
6
  tiles.getTileLocation(0, 0)
7
7
  ```
8
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
+
9
11
  ## Parameters
10
12
 
11
- * **col**: the column of the tile in the tilemap.
12
- * **row**: the row of the tile in the tilemap.
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.
13
15
 
14
16
  ## Returns
15
17
 
16
- * a [tile](/types/tile) from a location in the tilemap.
18
+ * a tile [location](/reference/tiles/location) object for a given column and row in the tilemap.
17
19
 
18
20
  ## Example #example
19
21
 
20
- Make a scene using a tilemap with border tiles and two tiles in the center. Replace the tiles in the center with the ones used for the border.
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.
21
23
 
22
24
  ```blocks
23
- let image = img`
24
- a a a a a a a a a a a a a a a a
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
- `;
41
- // TODO tiles.setTilemap(tiles.createTilemap(null, 0, 8 ** 8, 9));
42
- pause(1000)
43
- tiles.setTileAt(tiles.getTileLocation(4, 3), image)
44
- pause(1000)
45
- tiles.setTileAt(tiles.getTileLocation(5, 3), image)
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
+ })
46
49
  ```
47
50
 
48
51
  ## See also #seealso
49
52
 
50
- [get tiles by type](/reference/tiles/get-tiles-by-type),
51
- [set tile at](/reference/tiles/set-tile-at)
53
+ [set tile at](/reference/tiles/set-tile-at),
54
+ [place on tile](/reference/tiles/place-on-tile)
55
+
56
+ ```jres
57
+ {
58
+ "transparency16": {
59
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
60
+ "mimeType": "image/x-mkcd-f4",
61
+ "tilemapTile": true
62
+ },
63
+ "tile1": {
64
+ "data": "hwQQABAAAADd3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3Q==",
65
+ "mimeType": "image/x-mkcd-f4",
66
+ "tilemapTile": true,
67
+ "displayName": "myTile"
68
+ },
69
+ "tile2": {
70
+ "data": "hwQQABAAAABVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVQ==",
71
+ "mimeType": "image/x-mkcd-f4",
72
+ "tilemapTile": true,
73
+ "displayName": "myTile0"
74
+ },
75
+ "level1": {
76
+ "id": "level1",
77
+ "mimeType": "application/mkcd-tilemap",
78
+ "data": "MTAwYTAwMDgwMDAxMDIwMTAyMDEwMjAxMDIwMTAyMDIwMTAyMDEwMjAxMDIwMTAyMDEwMTAyMDEwMjAxMDIwMTAyMDEwMjAyMDEwMjAxMDIwMTAyMDEwMjAxMDEwMjAxMDIwMTAyMDEwMjAxMDIwMjAxMDIwMTAyMDEwMjAxMDIwMTAxMDIwMTAyMDEwMjAxMDIwMTAyMDIwMTAyMDEwMjAxMDIwMTAyMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
79
+ "tileset": [
80
+ "myTiles.transparency16",
81
+ "myTiles.tile1",
82
+ "myTiles.tile2"
83
+ ],
84
+ "displayName": "level1"
85
+ },
86
+ "*": {
87
+ "mimeType": "image/x-mkcd-f4",
88
+ "dataEncoding": "base64",
89
+ "namespace": "myTiles"
90
+ }
91
+ }
92
+ ```
@@ -1,52 +1,86 @@
1
1
  # get Tiles By Type
2
2
 
3
- Get a list of locations in the tilemap that have the same tile image.
3
+ Return an array of tile locations from the tilemap that contain the specified tile.
4
4
 
5
5
  ```sig
6
- tiles.getTilesByType(0)
6
+ tiles.getTilesByType(null)
7
7
  ```
8
8
 
9
- All the locations in the tilemap with the chosen **image** 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
- * **image**: the chosen tile image. This function returns all locations with this image
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 **image**.
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
- let image = 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
- // TODO tiles.setTilemap(tiles.createTilemap(null, 0, 8 ** 8, 9));
43
- for (let tile of tiles.getTilesByType(image)) {
44
- tiles.setTileAt(tile, image)
45
- pause(500)
46
- }
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
+ })
47
51
  ```
48
52
 
49
53
  ## See also #seealso
50
54
 
51
- [get tile location](/reference/tiles/get-tile-location),
52
- [set tile at](/reference/tiles/set-tile-at)
55
+ [get tile location](/reference/tiles/get-tile-location)
56
+
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
+ }
86
+ ```
@@ -0,0 +1,246 @@
1
+ # Location
2
+
3
+ The Location object contains the postition information of a game element on the tilemap.
4
+
5
+ ## column (property)
6
+
7
+ Get a tile column position of an object on the tilemap.
8
+
9
+ ```block
10
+ let location: tiles.Location = null
11
+
12
+ let col = location.column
13
+ ```
14
+
15
+ ```typescript-ignore
16
+ let col = location.column
17
+ ```
18
+
19
+ ### Returns
20
+
21
+ * a [number](/types/number) that is the tile column position of object on the tilemap.
22
+
23
+ ## row (property)
24
+
25
+ Get a tile row position of an object on the tilemap.
26
+
27
+ ```block
28
+ let location: tiles.Location = null
29
+
30
+ let row = location.row
31
+ ```
32
+
33
+ ```typescript-ignore
34
+ let row = location.row
35
+ ```
36
+
37
+ ### Returns
38
+
39
+ * a [number](/types/number) that is the tile row position of object on the tilemap.
40
+
41
+ ## x (property)
42
+
43
+ Get the horizontal center position of an object on the tilemap.
44
+
45
+ ```block
46
+ let location: tiles.Location = null
47
+
48
+ let horz = location.x
49
+ ```
50
+
51
+ ```typescript-ignore
52
+ let horz = location.x
53
+ ```
54
+
55
+ ### Returns
56
+
57
+ * a [number](/types/number) that is the current horizontal center position, in pixels, of the object on the tilemap.
58
+
59
+ ## y (property)
60
+
61
+ Get the vertical center position of an object on the tilemap.
62
+
63
+ ```block
64
+ let location: tiles.Location = null
65
+
66
+ let vert = location.y
67
+ ```
68
+
69
+ ```typescript-ignore
70
+ let vert = location.y
71
+ ```
72
+
73
+ ### Returns
74
+
75
+ * a [number](/types/number) that is the vertical center position, in pixels, of object on the tilemap.
76
+
77
+ ## left (property)
78
+
79
+ Get the of position of left side an object on the tilemap.
80
+
81
+ ```block
82
+ let location: tiles.Location = null
83
+
84
+ let left = location.left
85
+ ```
86
+
87
+ ```typescript-ignore
88
+ let left = location.left
89
+ ```
90
+
91
+ ### Returns
92
+
93
+ * a [number](/types/number) that is the left side, in pixels, of object on the tilemap.
94
+
95
+ ## right (property)
96
+
97
+ Get the of position of right side an object on the tilemap.
98
+
99
+ ```block
100
+ let location: tiles.Location = null
101
+
102
+ let right = location.right
103
+ ```
104
+
105
+ ```typescript-ignore
106
+ let right = location.right
107
+ ```
108
+
109
+ ### Returns
110
+
111
+ * a [number](/types/number) that is the right side, in pixels, of object on the tilemap.
112
+
113
+ ## top (property)
114
+
115
+ Get the of position of top side an object on the tilemap.
116
+
117
+ ```block
118
+ let location: tiles.Location = null
119
+
120
+ let top = location.top
121
+ ```
122
+
123
+ ```typescript-ignore
124
+ let top = location.top
125
+ ```
126
+
127
+ ### Returns
128
+
129
+ * a [number](/types/number) that is the right side, in pixels, of object on the tilemap.
130
+
131
+ ## bottom (property)
132
+
133
+ Get the of position of bottom side an object on the tilemap.
134
+
135
+ ```block
136
+ let location: tiles.Location = null
137
+
138
+ let bottom = location.bottom
139
+ ```
140
+
141
+ ```typescript-ignore
142
+ let bottom = location.bottom
143
+ ```
144
+
145
+ ### Returns
146
+
147
+ * a [number](/types/number) that is the right side, in pixels, of object on the tilemap.
148
+
149
+ ## Example #example
150
+
151
+ Make checkered table cloth with tiles on a tilemap. Create a hamburger sprite and randomly locate it on the table cloth. Find out where the hamburger is and display its location.
152
+
153
+ ```blocks
154
+ tiles.setCurrentTilemap(tilemap`level1`)
155
+ let mySprite = sprites.create(img`
156
+ ...........ccccc66666...........
157
+ ........ccc4444444444666........
158
+ ......cc444444444bb4444466......
159
+ .....cb4444bb4444b5b444444b.....
160
+ ....eb4444b5b44444b44444444b....
161
+ ...ebb44444b4444444444b444446...
162
+ ..eb6bb444444444bb444b5b444446..
163
+ ..e6bb5b44444444b5b444b44bb44e..
164
+ .e66b4b4444444444b4444444b5b44e.
165
+ .e6bb444444444444444444444bb44e.
166
+ eb66b44444bb444444444444444444be
167
+ eb66bb444b5b44444444bb44444444be
168
+ fb666b444bb444444444b5b4444444bf
169
+ fcb666b44444444444444bb444444bcf
170
+ .fbb6666b44444444444444444444bf.
171
+ .efbb66666bb4444444444444444bfe.
172
+ .86fcbb66666bbb44444444444bcc688
173
+ 8772effcbbbbbbbbbbbbbbbbcfc22778
174
+ 87722222cccccccccccccccc22226678
175
+ f866622222222222222222222276686f
176
+ fef866677766667777776667777fffef
177
+ fbff877768f86777777666776fffffbf
178
+ fbeffeefffeff7766688effeeeefeb6f
179
+ f6bfffeffeeeeeeeeeeeeefeeeeebb6e
180
+ f66ddfffffeeeffeffeeeeeffeedb46e
181
+ .c66ddd4effffffeeeeeffff4ddb46e.
182
+ .fc6b4dddddddddddddddddddb444ee.
183
+ ..ff6bb444444444444444444444ee..
184
+ ....ffbbbb4444444444444444ee....
185
+ ......ffebbbbbb44444444eee......
186
+ .........fffffffcccccee.........
187
+ ................................
188
+ `, SpriteKind.Player)
189
+ mySprite.setPosition(randint(16, 144), randint(16, 104))
190
+ let location = mySprite.tilemapLocation()
191
+ let displayString = "My hamburger is at "
192
+ displayString = "" + displayString + "x = "
193
+ displayString = "" + displayString + location.x + ", y = " + location.y
194
+ displayString = "" + displayString + " and over the tile at column = "
195
+ displayString = "" + displayString + location.column + ", row = " + location.row
196
+ game.showLongText(displayString, DialogLayout.Bottom)
197
+ ```
198
+
199
+ ## See also #seealso
200
+
201
+ [get neighboring location](/reference/tiles/get-neighboring-location)
202
+
203
+ ```jres
204
+ {
205
+ "transparency16": {
206
+ "data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
207
+ "mimeType": "image/x-mkcd-f4",
208
+ "tilemapTile": true
209
+ },
210
+ "tile3": {
211
+ "data": "hwQQABAAAABERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==",
212
+ "mimeType": "image/x-mkcd-f4",
213
+ "tilemapTile": true,
214
+ "displayName": "myTile1"
215
+ },
216
+ "tile4": {
217
+ "data": "hwQQABAAAAB3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3dw==",
218
+ "mimeType": "image/x-mkcd-f4",
219
+ "tilemapTile": true,
220
+ "displayName": "myTile2"
221
+ },
222
+ "tile5": {
223
+ "data": "hwQQABAAAACqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==",
224
+ "mimeType": "image/x-mkcd-f4",
225
+ "tilemapTile": true,
226
+ "displayName": "myTile3"
227
+ },
228
+ "level1": {
229
+ "id": "level1",
230
+ "mimeType": "application/mkcd-tilemap",
231
+ "data": "MTAwYTAwMDgwMDAzMDEwMzAxMDMwMTAzMDEwMzAxMDEwMzAyMDMwMjAzMDIwMzAyMDMwMzAyMDMwMjAzMDIwMzAyMDMwMTAxMDMwMjAzMDIwMzAyMDMwMjAzMDMwMjAzMDIwMzAyMDMwMjAzMDEwMTAzMDIwMzAyMDMwMjAzMDIwMzAzMDIwMzAyMDMwMjAzMDIwMzAxMDEwMzAxMDMwMTAzMDEwMzAxMDMwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
232
+ "tileset": [
233
+ "myTiles.transparency16",
234
+ "myTiles.tile3",
235
+ "myTiles.tile4",
236
+ "myTiles.tile5"
237
+ ],
238
+ "displayName": "level1"
239
+ },
240
+ "*": {
241
+ "mimeType": "image/x-mkcd-f4",
242
+ "dataEncoding": "base64",
243
+ "namespace": "myTiles"
244
+ }
245
+ }
246
+ ```
@@ -3,22 +3,22 @@
3
3
  Move a sprite's position to the center of a random tile in the scene.
4
4
 
5
5
  ```sig
6
- tiles.placeOnRandomTile(null, 0)
6
+ tiles.placeOnRandomTile(null, null)
7
7
  ```
8
8
 
9
- You a can place a sprite on top of a random tile in the tile map. Use the tile image to select which group of tiles the sprite can be placed on.
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.
10
10
 
11
11
  ## Parameters
12
12
 
13
13
  * **sprite**: the sprite to move onto the tile.
14
- * **image**: the tile [image](/types/image). The sprite will be randomly placed on a tile that matches this image
14
+ * **tile**: the tile type to randomly select in the tilemap.
15
15
 
16
16
  ## Example #example
17
17
 
18
- Make a tilemap with two solid color tiles. Create a circle sprite and randomly place the sprite on only the brown tiles.
18
+ Make a tilemap with several different tiles. Create a round shaped sprite. Ramdomly place the sprite on a blue tile.
19
19
 
20
20
  ```blocks
21
- tiles.setTilemap(tilemap`level`)
21
+ tiles.setTilemap(tilemap`level1`)
22
22
  let mySprite = sprites.create(img`
23
23
  . . . . . . . . . . . . . . . .
24
24
  . . . . . . . . . . . . . . . .
@@ -37,15 +37,13 @@ let mySprite = sprites.create(img`
37
37
  . . . . . . . . . . . . . . . .
38
38
  . . . . . . . . . . . . . . . .
39
39
  `, SpriteKind.Player)
40
- forever(function () {
41
- tiles.placeOnRandomTile(mySprite, assets.tile`brownTile`)
42
- pause(1000)
43
- })
40
+ pause(1000)
41
+ tiles.placeOnRandomTile(mySprite, assets.tile`myTile`)
44
42
  ```
45
43
 
46
44
  ## See also #seealso
47
45
 
48
- [get tile location](/reference/tiles/get-tile-location)
46
+ [place on tile](/reference/tiles/place-on-tile)
49
47
 
50
48
  ```jres
51
49
  {
@@ -54,28 +52,63 @@ forever(function () {
54
52
  "mimeType": "image/x-mkcd-f4",
55
53
  "tilemapTile": true
56
54
  },
57
- "redTile": {
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": {
58
68
  "data": "hwQQABAAAAAiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIg==",
59
69
  "mimeType": "image/x-mkcd-f4",
60
70
  "tilemapTile": true,
61
- "displayName": "redTile"
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"
62
90
  },
63
- "brownTile": {
64
- "data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
91
+ "tile6": {
92
+ "data": "hwQQABAAAACZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmQ==",
65
93
  "mimeType": "image/x-mkcd-f4",
66
94
  "tilemapTile": true,
67
- "displayName": "brownTile"
95
+ "displayName": "myTile4"
68
96
  },
69
- "level": {
70
- "id": "level",
97
+ "level1": {
98
+ "id": "level1",
71
99
  "mimeType": "application/mkcd-tilemap",
72
- "data": "MTAwNjAwMDUwMDAyMDAwMTAwMDIwMDAwMDIwMDAxMDAwMjAxMDAwMjAwMDEwMDAwMDEwMDAyMDAwMTAyMDAwMTAwMDIwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
100
+ "data": "MTAwYTAwMDgwMDAwMDAwMDAwMDAwMDAzMDAwMDAwMDAwMDA2MDAwMDAwMDAwMDAyMDAwMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDMwMDAwMDAwMDAwMDAwMDA1MDAwMDAwMDAwMTAwMDAwMDAwMDAwMDA0MDAwMDAwMDAwMDAwMDYwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
73
101
  "tileset": [
74
102
  "myTiles.transparency16",
75
- "myTiles.redTile",
76
- "myTiles.brownTile"
103
+ "myTiles.tile1",
104
+ "myTiles.tile2",
105
+ "myTiles.tile3",
106
+ "myTiles.tile4",
107
+ "myTiles.tile5",
108
+ "myTiles.tile6",
109
+ "myTiles.tile7"
77
110
  ],
78
- "displayName": "level"
111
+ "displayName": "level1"
79
112
  },
80
113
  "*": {
81
114
  "mimeType": "image/x-mkcd-f4",