pxt-common-packages 9.5.1 → 9.5.2
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/azureiot/built/debug/binary.js +485 -485
- package/libs/color/built/debug/binary.js +8 -8
- package/libs/color-sensor/built/debug/binary.js +8 -8
- package/libs/controller/built/debug/binary.js +8384 -7819
- package/libs/controller---none/built/debug/binary.js +8363 -7798
- package/libs/datalogger/built/debug/binary.js +63 -63
- package/libs/edge-connector/built/debug/binary.js +8 -8
- package/libs/esp32/built/debug/binary.js +486 -486
- package/libs/game/_locales/game-jsdoc-strings.json +6 -0
- package/libs/game/built/debug/binary.js +8276 -7711
- package/libs/game/controllerbutton.ts +98 -1
- package/libs/game/docs/reference/scene/get-neighboring-location.md +123 -0
- package/libs/game/docs/reference/scene/get-tile-location.md +1 -5
- package/libs/game/docs/reference/scene/location.md +246 -0
- package/libs/game/docs/reference/scene/tile-at-location-equals.md +1 -1
- package/libs/game/docs/reference/scene/tile-at-location-is-wall.md +98 -0
- package/libs/game/docs/reference/scene/tile-image-at-location.md +65 -0
- package/libs/game/docs/reference/scene/tilemap-location.md +83 -0
- package/libs/game/docs/reference/sprites/destroy-all-sprites-of-kind.md +74 -0
- package/libs/game/docs/reference/sprites/sprite/change-scale.md +65 -0
- package/libs/game/docs/reference/sprites/sprite/fx.md +25 -25
- package/libs/game/docs/reference/sprites/sprite/fy.md +24 -24
- package/libs/game/docs/reference/sprites/sprite/scale.md +80 -0
- package/libs/game/docs/reference/sprites/sprite/set-scale.md +79 -0
- package/libs/game/docs/reference/sprites/sprite/sx.md +80 -0
- package/libs/game/docs/reference/sprites/sprite/sy.md +80 -0
- package/libs/game/docs/reference/sprites.md +12 -2
- package/libs/game/scene.ts +2 -0
- package/libs/game/sprite.ts +2 -2
- package/libs/game/sprites.ts +1 -1
- package/libs/game/tilemap.ts +88 -4
- package/libs/lcd/built/debug/binary.js +8 -8
- package/libs/light-spectrum-sensor/built/debug/binary.js +8 -8
- package/libs/lora/built/debug/binary.js +8 -8
- package/libs/matrix-keypad/built/debug/binary.js +8 -8
- package/libs/mqtt/built/debug/binary.js +200 -200
- package/libs/net/built/debug/binary.js +200 -200
- package/libs/net-game/built/debug/binary.js +10081 -9516
- package/libs/palette/built/debug/binary.js +8275 -7710
- package/libs/pixel/built/debug/binary.js +8 -8
- package/libs/power/built/debug/binary.js +8 -8
- package/libs/proximity/built/debug/binary.js +8 -8
- package/libs/radio/built/debug/binary.js +8 -8
- package/libs/radio-broadcast/built/debug/binary.js +8 -8
- package/libs/rotary-encoder/built/debug/binary.js +8 -8
- package/libs/screen/built/debug/binary.js +50 -50
- package/libs/servo/built/debug/binary.js +8 -8
- package/libs/sprite-scaling/built/debug/binary.js +8275 -7710
- package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-by-percent.md +77 -0
- package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-by-pixels.md +144 -0
- package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-to-percent.md +83 -0
- package/libs/sprite-scaling/docs/reference/sprites/scaling/scale-to-pixels.md +140 -0
- package/libs/sprite-scaling/scaling.ts +5 -5
- package/libs/storyboard/built/debug/binary.js +8275 -7710
- package/package.json +1 -1
|
@@ -41,6 +41,17 @@ namespace controller {
|
|
|
41
41
|
return // missing in sim
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export class ButtonHandler {
|
|
45
|
+
constructor(public event: number, public callback: () => void) { }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class ButtonEventHandlerState {
|
|
49
|
+
constructor(public id: number) {};
|
|
50
|
+
|
|
51
|
+
public user: ButtonHandler[];
|
|
52
|
+
public system: ButtonHandler[];
|
|
53
|
+
}
|
|
54
|
+
|
|
44
55
|
//% fixedInstances
|
|
45
56
|
export class Button {
|
|
46
57
|
_owner: Controller;
|
|
@@ -53,6 +64,13 @@ namespace controller {
|
|
|
53
64
|
private _pressedElasped: number;
|
|
54
65
|
private _repeatCount: number;
|
|
55
66
|
|
|
67
|
+
protected get handlerState(): ButtonEventHandlerState {
|
|
68
|
+
for (const state of game.currentScene().buttonEventHandlers) {
|
|
69
|
+
if (state.id === this.id) return state;
|
|
70
|
+
}
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
56
74
|
toString(): string {
|
|
57
75
|
return `btn ${this.id} ${this._pressed ? "down" : "up"}`;
|
|
58
76
|
}
|
|
@@ -63,6 +81,7 @@ namespace controller {
|
|
|
63
81
|
this.repeatDelay = undefined;
|
|
64
82
|
this.repeatInterval = undefined;
|
|
65
83
|
this._repeatCount = 0;
|
|
84
|
+
|
|
66
85
|
if (id > 0) {
|
|
67
86
|
// this is to deal with the "anyButton" hack, which creates a button that is not visible
|
|
68
87
|
// in the UI, but used in event-handler to simulate the wildcard ANY for matching. As
|
|
@@ -103,7 +122,49 @@ namespace controller {
|
|
|
103
122
|
//% blockId=keyonevent block="on %button **button** %event"
|
|
104
123
|
//% group="Single Player"
|
|
105
124
|
onEvent(event: ControllerButtonEvent, handler: () => void) {
|
|
106
|
-
|
|
125
|
+
const eventHandler = this.getOrCreateHandlerForEvent(event);
|
|
126
|
+
eventHandler.callback = handler;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Adds an event handler that will fire whenever the specified event
|
|
131
|
+
* is triggered on this button. Handlers added using this method will
|
|
132
|
+
* not conflict with events added via onEvent. The same handler can
|
|
133
|
+
* not be added for the same event more than once.
|
|
134
|
+
*
|
|
135
|
+
* @param event The event to subscribe to for this button
|
|
136
|
+
* @param handler The code to run when the event triggers
|
|
137
|
+
*/
|
|
138
|
+
addEventListener(event: ControllerButtonEvent, handler: () => void) {
|
|
139
|
+
this.getOrCreateHandlerForEvent(event);
|
|
140
|
+
|
|
141
|
+
const handlerState = this.handlerState;
|
|
142
|
+
|
|
143
|
+
if (!handlerState.system) handlerState.system = [];
|
|
144
|
+
|
|
145
|
+
for (const eventHandler of handlerState.system) {
|
|
146
|
+
if (eventHandler.event === event && eventHandler.callback === handler) return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
handlerState.system.push(new ButtonHandler(event, handler));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Removes an event handler registered with addEventListener.
|
|
154
|
+
*
|
|
155
|
+
* @param event The event that the handler was registered for
|
|
156
|
+
* @param handler The handler to remove
|
|
157
|
+
*/
|
|
158
|
+
removeEventListener(event: ControllerButtonEvent, handler: () => void) {
|
|
159
|
+
const handlerState = this.handlerState;
|
|
160
|
+
if (!handlerState || !handlerState.system) return;
|
|
161
|
+
|
|
162
|
+
for (let i = 0; i < handlerState.system.length; i++) {
|
|
163
|
+
if (handlerState.system[i].event === event && handlerState.system[i].callback === handler) {
|
|
164
|
+
handlerState.system.splice(i, 1)
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
107
168
|
}
|
|
108
169
|
|
|
109
170
|
/**
|
|
@@ -172,6 +233,42 @@ namespace controller {
|
|
|
172
233
|
this._repeatCount = count;
|
|
173
234
|
}
|
|
174
235
|
}
|
|
236
|
+
|
|
237
|
+
protected runButtonEvents(event: ControllerButtonEvent) {
|
|
238
|
+
const handlerState = this.handlerState;
|
|
239
|
+
if (!handlerState) return;
|
|
240
|
+
|
|
241
|
+
const userHandler = this.getOrCreateHandlerForEvent(event);
|
|
242
|
+
if (userHandler.callback) userHandler.callback();
|
|
243
|
+
|
|
244
|
+
if (handlerState.system) {
|
|
245
|
+
for (const eventHandler of handlerState.system) {
|
|
246
|
+
if (eventHandler.event === event && eventHandler.callback) eventHandler.callback();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
protected getOrCreateHandlerForEvent(event: ControllerButtonEvent) {
|
|
252
|
+
if (!this.handlerState) {
|
|
253
|
+
game.currentScene().buttonEventHandlers.push(new ButtonEventHandlerState(this.id));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const handlerState = this.handlerState;
|
|
257
|
+
if (!handlerState.user) handlerState.user = [];
|
|
258
|
+
|
|
259
|
+
for (const eventHandler of handlerState.user) {
|
|
260
|
+
if (eventHandler.event === event) {
|
|
261
|
+
return eventHandler;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Register actual handler if this hasn't been used before
|
|
266
|
+
control.onEvent(event, this.id, () => this.runButtonEvents(event));
|
|
267
|
+
|
|
268
|
+
const newHandler = new ButtonHandler(event, undefined);
|
|
269
|
+
handlerState.user.push(newHandler);
|
|
270
|
+
return newHandler;
|
|
271
|
+
}
|
|
175
272
|
}
|
|
176
273
|
|
|
177
274
|
/**
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# get Neighboring Location
|
|
2
|
+
|
|
3
|
+
Get the location of a tile next to this one.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
tiles.getTileLocation(0, 0).getNeighboringLocation(CollisionDirection.Top)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
A neighboring tile is one that is immediately to the `left`, `right`, `top`, or `bottom` side of the current tile. You can specify the side of the neighboring tile you want the location for.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **direction**: the direction side for the neighbor tile from this tile. The directions to choose from are `left`, `right`, `top`, or `bottom`.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* a [location](/reference/scene/location) object for the neighbor tile.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Rotate a donut sprite around adjacent tiles in a tilemap.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
let nextSpot: tiles.Location = null
|
|
25
|
+
let rotation = 0
|
|
26
|
+
tiles.setCurrentTilemap(tilemap`level1`)
|
|
27
|
+
let mySprite = sprites.create(img`
|
|
28
|
+
. . . . . . b b b b a a . . . .
|
|
29
|
+
. . . . b b d d d 3 3 3 a a . .
|
|
30
|
+
. . . b d d d 3 3 3 3 3 3 a a .
|
|
31
|
+
. . b d d 3 3 3 3 3 3 3 3 3 a .
|
|
32
|
+
. b 3 d 3 3 3 3 3 b 3 3 3 3 a b
|
|
33
|
+
. b 3 3 3 3 3 a a 3 3 3 3 3 a b
|
|
34
|
+
b 3 3 3 3 3 a a 3 3 3 3 d a 4 b
|
|
35
|
+
b 3 3 3 3 b a 3 3 3 3 3 d a 4 b
|
|
36
|
+
b 3 3 3 3 3 3 3 3 3 3 d a 4 4 e
|
|
37
|
+
a 3 3 3 3 3 3 3 3 3 d a 4 4 4 e
|
|
38
|
+
a 3 3 3 3 3 3 3 d d a 4 4 4 e .
|
|
39
|
+
a a 3 3 3 d d d a a 4 4 4 e e .
|
|
40
|
+
. e a a a a a a 4 4 4 4 e e . .
|
|
41
|
+
. . e e b b 4 4 4 4 b e e . . .
|
|
42
|
+
. . . e e e e e e e e . . . . .
|
|
43
|
+
. . . . . . . . . . . . . . . .
|
|
44
|
+
`, SpriteKind.Player)
|
|
45
|
+
mySprite.x = mySprite.x - mySprite.width
|
|
46
|
+
game.onUpdateInterval(1000, function () {
|
|
47
|
+
if (rotation == 0) {
|
|
48
|
+
nextSpot = mySprite.tilemapLocation().getNeighboringLocation(CollisionDirection.Right)
|
|
49
|
+
} else if (rotation == 1) {
|
|
50
|
+
nextSpot = mySprite.tilemapLocation().getNeighboringLocation(CollisionDirection.Bottom)
|
|
51
|
+
} else if (rotation == 2) {
|
|
52
|
+
nextSpot = mySprite.tilemapLocation().getNeighboringLocation(CollisionDirection.Left)
|
|
53
|
+
} else {
|
|
54
|
+
nextSpot = mySprite.tilemapLocation().getNeighboringLocation(CollisionDirection.Top)
|
|
55
|
+
}
|
|
56
|
+
mySprite.setPosition(nextSpot.x, nextSpot.y)
|
|
57
|
+
rotation += 1
|
|
58
|
+
if (rotation > 3) {
|
|
59
|
+
rotation = 0
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## See also #seealso
|
|
65
|
+
|
|
66
|
+
[get tile location](/reference/scene/get-tile-location)
|
|
67
|
+
|
|
68
|
+
```jres
|
|
69
|
+
{
|
|
70
|
+
"transparency16": {
|
|
71
|
+
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
|
72
|
+
"mimeType": "image/x-mkcd-f4",
|
|
73
|
+
"tilemapTile": true
|
|
74
|
+
},
|
|
75
|
+
"tile1": {
|
|
76
|
+
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
|
77
|
+
"mimeType": "image/x-mkcd-f4",
|
|
78
|
+
"tilemapTile": true,
|
|
79
|
+
"displayName": "myTile"
|
|
80
|
+
},
|
|
81
|
+
"tile2": {
|
|
82
|
+
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
|
83
|
+
"mimeType": "image/x-mkcd-f4",
|
|
84
|
+
"tilemapTile": true,
|
|
85
|
+
"displayName": "myTile0"
|
|
86
|
+
},
|
|
87
|
+
"tile3": {
|
|
88
|
+
"data": "hwQQABAAAABERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERERA==",
|
|
89
|
+
"mimeType": "image/x-mkcd-f4",
|
|
90
|
+
"tilemapTile": true,
|
|
91
|
+
"displayName": "myTile1"
|
|
92
|
+
},
|
|
93
|
+
"tile4": {
|
|
94
|
+
"data": "hwQQABAAAAB3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3d3dw==",
|
|
95
|
+
"mimeType": "image/x-mkcd-f4",
|
|
96
|
+
"tilemapTile": true,
|
|
97
|
+
"displayName": "myTile2"
|
|
98
|
+
},
|
|
99
|
+
"tile5": {
|
|
100
|
+
"data": "hwQQABAAAACqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqg==",
|
|
101
|
+
"mimeType": "image/x-mkcd-f4",
|
|
102
|
+
"tilemapTile": true,
|
|
103
|
+
"displayName": "myTile3"
|
|
104
|
+
},
|
|
105
|
+
"level1": {
|
|
106
|
+
"id": "level1",
|
|
107
|
+
"mimeType": "application/mkcd-tilemap",
|
|
108
|
+
"data": "MTAwYTAwMDgwMDAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMzAyMDMwMjAzMDIwMzAyMDEwMTAyMDMwMjAzMDIwMzAyMDMwMTAxMDMwMjAzMDIwMzAyMDMwMjAxMDEwMjAzMDIwMzAyMDMwMjAzMDEwMTAzMDIwMzAyMDMwMjAzMDIwMTAxMDIwMzAyMDMwMjAzMDIwMzAxMDEwMTAxMDEwMTAxMDEwMTAxMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
|
|
109
|
+
"tileset": [
|
|
110
|
+
"myTiles.transparency16",
|
|
111
|
+
"myTiles.tile3",
|
|
112
|
+
"myTiles.tile4",
|
|
113
|
+
"myTiles.tile5"
|
|
114
|
+
],
|
|
115
|
+
"displayName": "level1"
|
|
116
|
+
},
|
|
117
|
+
"*": {
|
|
118
|
+
"mimeType": "image/x-mkcd-f4",
|
|
119
|
+
"dataEncoding": "base64",
|
|
120
|
+
"namespace": "myTiles"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
@@ -15,7 +15,7 @@ A tile location object represents a column and a row position in the tilemap. Lo
|
|
|
15
15
|
|
|
16
16
|
## Returns
|
|
17
17
|
|
|
18
|
-
* a tile location object for a given column and row in the tilemap.
|
|
18
|
+
* a tile [location](/reference/scene/location) object for a given column and row in the tilemap.
|
|
19
19
|
|
|
20
20
|
## Example #example
|
|
21
21
|
|
|
@@ -48,10 +48,6 @@ forever(function () {
|
|
|
48
48
|
})
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
## Returns
|
|
52
|
-
|
|
53
|
-
* a tile location for the column and row specifed.
|
|
54
|
-
|
|
55
51
|
## See also #seealso
|
|
56
52
|
|
|
57
53
|
[set tile at](/reference/scene/set-tile-at),
|
|
@@ -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/scene/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
|
+
```
|
|
@@ -8,7 +8,7 @@ tiles.tileAtLocationEquals(tiles.getTileLocation(0, 0), null)
|
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
11
|
-
* **location**: a location in the tilemap.
|
|
11
|
+
* **location**: a [location](/reference/scene/location) in the tilemap.
|
|
12
12
|
* **tile**: an [image](/types/image) that matches the tile you're looking for.
|
|
13
13
|
|
|
14
14
|
## Returns
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# tile At Location Is Wall
|
|
2
|
+
|
|
3
|
+
Check if a tile at a location in the tilemap is also a wall tile.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
tiles.tileAtLocationIsWall(null)
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The tile in the tilemap at the location selected is checked to see if it is set as a wall. After they are placed in the tilemap with the Tilemap Editor, tiles can be set as _wall_ tiles.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
* **location**: the [location](/reference/scene/location) object for the tile to check if it's a wall.
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
* a [boolean](/types/boolean) value that is `true` if the tile at **location** is a wall. The value is `false` if the tile is not a wall.
|
|
18
|
+
|
|
19
|
+
## Example #example
|
|
20
|
+
|
|
21
|
+
Set a tilemap with two columns of the same tile. Make one of the columns be all wall tiles. Send a ghost sprite across both colunms so it can detect which one is the wall.
|
|
22
|
+
|
|
23
|
+
```blocks
|
|
24
|
+
scene.onOverlapTile(SpriteKind.Player, assets.tile`myTile0`, function (sprite, location) {
|
|
25
|
+
if (tiles.tileAtLocationIsWall(location)) {
|
|
26
|
+
mySprite.sayText("That's a wall!")
|
|
27
|
+
} else {
|
|
28
|
+
mySprite.sayText("Not a wall.")
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
let mySprite: Sprite = null
|
|
32
|
+
scene.setBackgroundColor(11)
|
|
33
|
+
tiles.setCurrentTilemap(tilemap`level1`)
|
|
34
|
+
mySprite = sprites.create(img`
|
|
35
|
+
........................
|
|
36
|
+
........................
|
|
37
|
+
........................
|
|
38
|
+
........................
|
|
39
|
+
..........ffff..........
|
|
40
|
+
........ff1111ff........
|
|
41
|
+
.......fb111111bf.......
|
|
42
|
+
.......f11111111f.......
|
|
43
|
+
......fd11111111df......
|
|
44
|
+
......fd11111111df......
|
|
45
|
+
......fddd1111dddf......
|
|
46
|
+
......fbdbfddfbdbf......
|
|
47
|
+
......fcdcf11fcdcf......
|
|
48
|
+
.......fb111111bf.......
|
|
49
|
+
......fffcdb1bdffff.....
|
|
50
|
+
....fc111cbfbfc111cf....
|
|
51
|
+
....f1b1b1ffff1b1b1f....
|
|
52
|
+
....fbfbffffffbfbfbf....
|
|
53
|
+
.........ffffff.........
|
|
54
|
+
...........fff..........
|
|
55
|
+
........................
|
|
56
|
+
........................
|
|
57
|
+
........................
|
|
58
|
+
........................
|
|
59
|
+
`, SpriteKind.Player)
|
|
60
|
+
mySprite.left = 0
|
|
61
|
+
mySprite.setFlag(SpriteFlag.GhostThroughWalls, true)
|
|
62
|
+
mySprite.vx = 30
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## See also #seealso
|
|
66
|
+
|
|
67
|
+
[get tile location](/reference/scene/get-tile-location)
|
|
68
|
+
|
|
69
|
+
```jres
|
|
70
|
+
{
|
|
71
|
+
"transparency16": {
|
|
72
|
+
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
|
73
|
+
"mimeType": "image/x-mkcd-f4",
|
|
74
|
+
"tilemapTile": true
|
|
75
|
+
},
|
|
76
|
+
"tile1": {
|
|
77
|
+
"data": "hwQQABAAAABmZmZmZmZmZmZvZmZmb2ZmZmZm9mZm9mZmZm9mb2ZmZvZmZmZmZm9mZmZmZmZmZmZmZmZmZmZmZmb2ZvZmb2Zm9mZmZmZm9mZmZmZmZmZmZmb2b2b2ZmZmZmZmZmZmZm9mZmb2ZmZmZmb2ZmZm9mZvZmZmZvZmZvZmZmZmZmZmZg==",
|
|
78
|
+
"mimeType": "image/x-mkcd-f4",
|
|
79
|
+
"tilemapTile": true,
|
|
80
|
+
"displayName": "myTile0"
|
|
81
|
+
},
|
|
82
|
+
"level1": {
|
|
83
|
+
"id": "level1",
|
|
84
|
+
"mimeType": "application/mkcd-tilemap",
|
|
85
|
+
"data": "MTAwYTAwMDgwMDAwMDAwMDAxMDAwMDAxMDAwMDAwMDAwMDAwMDEwMDAwMDEwMDAwMDAwMDAwMDAwMTAwMDAwMTAwMDAwMDAwMDAwMDAxMDAwMDAxMDAwMDAwMDAwMDAwMDEwMDAwMDEwMDAwMDAwMDAwMDAwMTAwMDAwMTAwMDAwMDAwMDAwMDAxMDAwMDAxMDAwMDAwMDAwMDAwMDEwMDAwMDEwMDAwMDAwMDAwMDAwMjAwMDAwMDAwMDIwMDAwMDAwMDAyMDAwMDAwMDAwMjAwMDAwMDAwMDIwMDAwMDAwMDAyMDAwMDAwMDAwMjAwMDAwMDAwMDIwMA==",
|
|
86
|
+
"tileset": [
|
|
87
|
+
"myTiles.transparency16",
|
|
88
|
+
"myTiles.tile1"
|
|
89
|
+
],
|
|
90
|
+
"displayName": "level1"
|
|
91
|
+
},
|
|
92
|
+
"*": {
|
|
93
|
+
"mimeType": "image/x-mkcd-f4",
|
|
94
|
+
"dataEncoding": "base64",
|
|
95
|
+
"namespace": "myTiles"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# tile Image At Location
|
|
2
|
+
|
|
3
|
+
Get the image of the tile at a location in the tilemap.
|
|
4
|
+
|
|
5
|
+
```sig
|
|
6
|
+
tiles.tileImageAtLocation(tiles.getTileAtLocation(0, 0))
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
* **location**: the [location](/reference/scene/location) object for the tile to return it's image.
|
|
12
|
+
|
|
13
|
+
## Returns
|
|
14
|
+
|
|
15
|
+
* the [image](/types/image) of the tile at the **location** in the tilemap.
|
|
16
|
+
|
|
17
|
+
## Example #example
|
|
18
|
+
|
|
19
|
+
Make a tilemap with some smiley face tiles. Create a new sprite using the image from one of the smiley face tiles. Have the new sprite move across the screen and back.
|
|
20
|
+
|
|
21
|
+
```blocks
|
|
22
|
+
scene.onHitWall(SpriteKind.Player, function (sprite, location) {
|
|
23
|
+
sprite.startEffect(effects.bubbles, 500)
|
|
24
|
+
})
|
|
25
|
+
tiles.setCurrentTilemap(tilemap`level1`)
|
|
26
|
+
let tileImage = tiles.tileImageAtLocation(tiles.getTileLocation(0, 0))
|
|
27
|
+
let mySprite = sprites.create(tileImage, SpriteKind.Player)
|
|
28
|
+
mySprite.setBounceOnWall(true)
|
|
29
|
+
mySprite.vx = 50
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## See also #seealso
|
|
33
|
+
|
|
34
|
+
[location](/reference/scene/location)
|
|
35
|
+
|
|
36
|
+
```jres
|
|
37
|
+
{
|
|
38
|
+
"transparency16": {
|
|
39
|
+
"data": "hwQQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
|
|
40
|
+
"mimeType": "image/x-mkcd-f4",
|
|
41
|
+
"tilemapTile": true
|
|
42
|
+
},
|
|
43
|
+
"tile1": {
|
|
44
|
+
"data": "hwQQABAAAABERERERERERERERERERERERPT/RET/RERE9PRERERPRET0/0RERPRERERERERE9ERERERERET0RERERPRPRPRERERE9E9E9ERERERERET0RERERERERPRERPT/RERE9ERE9PRERERPRET0/0RE/0RERERERERERERERERERERERA==",
|
|
45
|
+
"mimeType": "image/x-mkcd-f4",
|
|
46
|
+
"tilemapTile": true,
|
|
47
|
+
"displayName": "myTile"
|
|
48
|
+
},
|
|
49
|
+
"level1": {
|
|
50
|
+
"id": "level1",
|
|
51
|
+
"mimeType": "application/mkcd-tilemap",
|
|
52
|
+
"data": "MTAwYTAwMDgwMDAxMDAwMTAwMDEwMDAxMDAwMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDAwMTAwMDEwMDAxMDAwMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMA==",
|
|
53
|
+
"tileset": [
|
|
54
|
+
"myTiles.transparency16",
|
|
55
|
+
"myTiles.tile1"
|
|
56
|
+
],
|
|
57
|
+
"displayName": "level1"
|
|
58
|
+
},
|
|
59
|
+
"*": {
|
|
60
|
+
"mimeType": "image/x-mkcd-f4",
|
|
61
|
+
"dataEncoding": "base64",
|
|
62
|
+
"namespace": "myTiles"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|