pxt-common-packages 9.4.2 → 9.4.3
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.
- package/libs/controller/built/debug/binary.js +1 -1
- package/libs/controller---none/built/debug/binary.js +1 -1
- package/libs/game/built/debug/binary.js +1 -1
- package/libs/game/docs/reference/scene/set-tilemap.md +89 -0
- package/libs/game/docs/reference/scene.md +4 -2
- package/libs/game/tilemap.ts +1 -1
- package/libs/net-game/built/debug/binary.js +1 -1
- package/libs/palette/built/debug/binary.js +1 -1
- package/libs/storyboard/built/debug/binary.js +1 -1
- package/package.json +1 -1
|
@@ -28568,7 +28568,7 @@ switch (step) {
|
|
|
28568
28568
|
return leave(s, r0)
|
|
28569
28569
|
default: oops()
|
|
28570
28570
|
} } }
|
|
28571
|
-
tiles_getTileImage__P65708.info = {"start":
|
|
28571
|
+
tiles_getTileImage__P65708.info = {"start":19984,"length":207,"line":622,"column":4,"endLine":626,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
28572
28572
|
|
|
28573
28573
|
function tiles_getTileImage__P65708_mk(s) {
|
|
28574
28574
|
checkStack(s.depth);
|
|
@@ -28459,7 +28459,7 @@ switch (step) {
|
|
|
28459
28459
|
return leave(s, r0)
|
|
28460
28460
|
default: oops()
|
|
28461
28461
|
} } }
|
|
28462
|
-
tiles_getTileImage__P80726.info = {"start":
|
|
28462
|
+
tiles_getTileImage__P80726.info = {"start":19984,"length":207,"line":622,"column":4,"endLine":626,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
28463
28463
|
|
|
28464
28464
|
function tiles_getTileImage__P80726_mk(s) {
|
|
28465
28465
|
checkStack(s.depth);
|
|
@@ -27954,7 +27954,7 @@ switch (step) {
|
|
|
27954
27954
|
return leave(s, r0)
|
|
27955
27955
|
default: oops()
|
|
27956
27956
|
} } }
|
|
27957
|
-
tiles_getTileImage__P137301.info = {"start":
|
|
27957
|
+
tiles_getTileImage__P137301.info = {"start":19984,"length":207,"line":622,"column":4,"endLine":626,"endColumn":5,"fileName":"tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
27958
27958
|
|
|
27959
27959
|
function tiles_getTileImage__P137301_mk(s) {
|
|
27960
27960
|
checkStack(s.depth);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# set Tilemap
|
|
2
|
+
|
|
3
|
+
Set a tilemap as the current tilemap for the game scene.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
tiles.setTilemap(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
A tilemap is complex data object that contains the dimensions, layers, and tile list for a tile mapping to set as the scene for a game. A game program can have more than one tilemap defined and the game's scene or _level_ can change by setting a different tilemap at certain times during a game.
|
|
10
|
+
|
|
11
|
+
Tilemaps aren't coded by the user but are created using a tilemap editor. Each tilemap in a game project is a named resource and is contained within the project's **assets** collection. A particular tilemap is specified with it's resource name like this:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
tiles.setTilemap(tilemap`level1`)
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
* **tilemap**: the tilemap data containing the tilemap layout and tiles to set for the game scene. The tilemap can be specified by it's resource name, such as: `` tilemap`level1` ``.
|
|
20
|
+
|
|
21
|
+
## Example #example
|
|
22
|
+
|
|
23
|
+
Create a maze tilemap for a sprite to travel through. Set the tilemap as the scene for the game. Create a sprite and start it travelling in the maze.
|
|
24
|
+
|
|
25
|
+
```blocks
|
|
26
|
+
tiles.setTilemap(tilemap`level1`)
|
|
27
|
+
let mySprite = sprites.create(img`
|
|
28
|
+
. . . . . . . . . . . . . . . .
|
|
29
|
+
. . . . . . . . . . . . . . . .
|
|
30
|
+
. . . . . 5 5 5 5 5 5 . . . . .
|
|
31
|
+
. . . 5 5 5 5 5 5 5 5 5 5 . . .
|
|
32
|
+
. . . 5 5 5 5 5 5 5 5 5 5 . . .
|
|
33
|
+
. . 5 5 5 5 5 5 5 5 5 5 5 5 . .
|
|
34
|
+
. . 5 5 5 5 5 5 5 5 5 5 5 5 . .
|
|
35
|
+
. . 5 5 5 5 5 5 5 5 5 5 5 5 . .
|
|
36
|
+
. . 5 5 5 5 5 5 5 5 5 5 5 5 . .
|
|
37
|
+
. . 5 5 5 5 5 5 5 5 5 5 5 5 . .
|
|
38
|
+
. . 5 5 5 5 5 5 5 5 5 5 5 5 . .
|
|
39
|
+
. . . 5 5 5 5 5 5 5 5 5 5 . . .
|
|
40
|
+
. . . 5 5 5 5 5 5 5 5 5 5 . . .
|
|
41
|
+
. . . . . 5 5 5 5 5 5 . . . . .
|
|
42
|
+
. . . . . . . . . . . . . . . .
|
|
43
|
+
. . . . . . . . . . . . . . . .
|
|
44
|
+
`, SpriteKind.Player)
|
|
45
|
+
mySprite.setPosition(0, 104)
|
|
46
|
+
mySprite.vx = 16
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## See also #seealso
|
|
50
|
+
|
|
51
|
+
[set tile at](/reference/scene/set-tile-at)
|
|
52
|
+
|
|
53
|
+
```jres
|
|
54
|
+
{
|
|
55
|
+
"transparency16": {
|
|
56
|
+
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
|
57
|
+
"mimeType": "image/x-mkcd-f4",
|
|
58
|
+
"tilemapTile": true
|
|
59
|
+
},
|
|
60
|
+
"tile1": {
|
|
61
|
+
"data": "hwQQABAAAADu7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7u7g==",
|
|
62
|
+
"mimeType": "image/x-mkcd-f4",
|
|
63
|
+
"tilemapTile": true,
|
|
64
|
+
"displayName": "myTile0"
|
|
65
|
+
},
|
|
66
|
+
"tile2": {
|
|
67
|
+
"data": "hwQQABAAAABERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==",
|
|
68
|
+
"mimeType": "image/x-mkcd-f4",
|
|
69
|
+
"tilemapTile": true,
|
|
70
|
+
"displayName": "myTile1"
|
|
71
|
+
},
|
|
72
|
+
"level1": {
|
|
73
|
+
"id": "level1",
|
|
74
|
+
"mimeType": "application/mkcd-tilemap",
|
|
75
|
+
"data": "MTAwYTAwMDgwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDEwMTAwMDIwMjAyMDAwMjAyMDAwMTAxMDAwMjAwMDIwMDAyMDIwMDAwMDEwMDAyMDAwMjAwMDIwMDAwMDEwMTAwMDIwMDAyMDIwMjAwMDIwMTAwMDAwMDAwMDAwMDAyMDAwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEyMjIyMjIyMjIyMDIwMDAwMDAyMDAyMjIwMjIyMjAwMjAyMDIyMjAwMDIwMjAyMDIyMDAyMDIyMjAyMjIwMDAwMDAwMjIwMjIyMjIyMjIyMg==",
|
|
76
|
+
"tileset": [
|
|
77
|
+
"myTiles.transparency16",
|
|
78
|
+
"myTiles.tile1",
|
|
79
|
+
"myTiles.tile2"
|
|
80
|
+
],
|
|
81
|
+
"displayName": "maze"
|
|
82
|
+
},
|
|
83
|
+
"*": {
|
|
84
|
+
"mimeType": "image/x-mkcd-f4",
|
|
85
|
+
"dataEncoding": "base64",
|
|
86
|
+
"namespace": "myTiles"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
@@ -16,7 +16,8 @@ scene.backgroundImage()
|
|
|
16
16
|
## Tiles and Tilemaps
|
|
17
17
|
|
|
18
18
|
```cards
|
|
19
|
-
tiles.
|
|
19
|
+
tiles.setTilemap(null)
|
|
20
|
+
tiles.setTileAt(tiles.getTileLocation(0, 0), null)
|
|
20
21
|
tiles.setWallAt(tiles.getTileLocation(0, 0), false)
|
|
21
22
|
tiles.getTileLocation(0, 0)
|
|
22
23
|
tiles.getTilesByType(null)
|
|
@@ -24,7 +25,7 @@ tiles.placeOnTile(null, tiles.getTileLocation(0, 0))
|
|
|
24
25
|
tiles.placeOnRandomTile(null, null)
|
|
25
26
|
scene.onOverlapTile(SpriteKind.Player, null, function (sprite, location) {})
|
|
26
27
|
scene.onHitWall(SpriteKind.Player, function (sprite, location) { })
|
|
27
|
-
tiles.tileAtLocationEquals(
|
|
28
|
+
tiles.tileAtLocationEquals(tiles.getTileLocation(0, 0), null)
|
|
28
29
|
sprites.create(null).isHittingTile(CollisionDirection.Right)
|
|
29
30
|
sprites.create(null).tileKindAt(TileDirection.Right, null)
|
|
30
31
|
```
|
|
@@ -52,6 +53,7 @@ scene.cameraShake(4,500)
|
|
|
52
53
|
[set background image](/reference/scene/set-background-image),
|
|
53
54
|
[background color](/reference/scene/background-color),
|
|
54
55
|
[background image](/reference/scene/background-image),
|
|
56
|
+
[set tilemap](/reference/scene/set-tilemap),
|
|
55
57
|
[set tile at](/reference/scene/set-tile-at),
|
|
56
58
|
[set wall at](/reference/scene/set-wall-at),
|
|
57
59
|
[get tile location](/reference/scene/get-tile-location),
|
package/libs/game/tilemap.ts
CHANGED
|
@@ -545,7 +545,7 @@ namespace tiles {
|
|
|
545
545
|
//% tilemap.fieldOptions.filter="tile"
|
|
546
546
|
//% tilemap.fieldOptions.taggedTemplate="tilemap"
|
|
547
547
|
//% blockNamespace="scene" duplicateShadowOnDrag
|
|
548
|
-
//% help=
|
|
548
|
+
//% help=scene/set-tilemap
|
|
549
549
|
//% deprecated=1
|
|
550
550
|
export function setTilemap(tilemap: TileMapData) {
|
|
551
551
|
setCurrentTilemap(tilemap);
|
|
@@ -36777,7 +36777,7 @@ switch (step) {
|
|
|
36777
36777
|
return leave(s, r0)
|
|
36778
36778
|
default: oops()
|
|
36779
36779
|
} } }
|
|
36780
|
-
tiles_getTileImage__P111153.info = {"start":
|
|
36780
|
+
tiles_getTileImage__P111153.info = {"start":19984,"length":207,"line":622,"column":4,"endLine":626,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
36781
36781
|
|
|
36782
36782
|
function tiles_getTileImage__P111153_mk(s) {
|
|
36783
36783
|
checkStack(s.depth);
|
|
@@ -27954,7 +27954,7 @@ switch (step) {
|
|
|
27954
27954
|
return leave(s, r0)
|
|
27955
27955
|
default: oops()
|
|
27956
27956
|
} } }
|
|
27957
|
-
tiles_getTileImage__P168540.info = {"start":
|
|
27957
|
+
tiles_getTileImage__P168540.info = {"start":19984,"length":207,"line":622,"column":4,"endLine":626,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
27958
27958
|
|
|
27959
27959
|
function tiles_getTileImage__P168540_mk(s) {
|
|
27960
27960
|
checkStack(s.depth);
|
|
@@ -27954,7 +27954,7 @@ switch (step) {
|
|
|
27954
27954
|
return leave(s, r0)
|
|
27955
27955
|
default: oops()
|
|
27956
27956
|
} } }
|
|
27957
|
-
tiles_getTileImage__P152413.info = {"start":
|
|
27957
|
+
tiles_getTileImage__P152413.info = {"start":19984,"length":207,"line":622,"column":4,"endLine":626,"endColumn":5,"fileName":"pxt_modules/game/tilemap.ts","functionName":"getTileImage","argumentNames":["loc"]}
|
|
27958
27958
|
|
|
27959
27959
|
function tiles_getTileImage__P152413_mk(s) {
|
|
27960
27960
|
checkStack(s.depth);
|