q5play 4.1.2 → 4.2.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/package.json +1 -1
- package/py.typed +0 -0
- package/q5play.d.ts +1382 -160
- package/q5play.js +847 -204
- package/q5play.pyi +5007 -0
package/q5play.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/** @module q5play */
|
|
2
|
+
|
|
1
3
|
import 'q5';
|
|
2
4
|
|
|
5
|
+
// only used to build the q5play.org/docs
|
|
6
|
+
// import type { b2BodyId, b2WorldId, b2JointId } from './Box2D.deluxe.d.ts';
|
|
7
|
+
|
|
3
8
|
declare global {
|
|
4
9
|
class Q5Play {
|
|
5
10
|
/**
|
|
@@ -13,6 +18,7 @@ declare global {
|
|
|
13
18
|
sprites: {
|
|
14
19
|
[key: number]: Sprite;
|
|
15
20
|
};
|
|
21
|
+
|
|
16
22
|
/**
|
|
17
23
|
* Contains all the groups in the sketch.
|
|
18
24
|
*
|
|
@@ -21,14 +27,17 @@ declare global {
|
|
|
21
27
|
groups: {
|
|
22
28
|
[key: number]: Group;
|
|
23
29
|
};
|
|
30
|
+
|
|
24
31
|
groupsCreated: number;
|
|
25
32
|
spritesCreated: number;
|
|
26
33
|
spritesDrawn: number;
|
|
34
|
+
|
|
27
35
|
/**
|
|
28
36
|
* The default color palette, at index 0 of this array,
|
|
29
37
|
* has all the letters of the English alphabet mapped to colors.
|
|
30
38
|
*/
|
|
31
39
|
palettes: any[];
|
|
40
|
+
|
|
32
41
|
/**
|
|
33
42
|
* Friendly rounding makes some Sprite getters return nice rounded numbers
|
|
34
43
|
* if a decimal value is within linear slop range (+/-0.005) or
|
|
@@ -41,13 +50,16 @@ declare global {
|
|
|
41
50
|
* @default true
|
|
42
51
|
*/
|
|
43
52
|
friendlyRounding: boolean;
|
|
53
|
+
|
|
44
54
|
/**
|
|
45
55
|
* Information about the operating system being used.
|
|
46
56
|
*/
|
|
47
57
|
os: {};
|
|
58
|
+
|
|
48
59
|
context: string;
|
|
49
60
|
hasMouse: boolean;
|
|
50
61
|
standardizeKeyboard: boolean;
|
|
62
|
+
|
|
51
63
|
/**
|
|
52
64
|
* Displays the version of q5play being used,
|
|
53
65
|
* the number of sprites being drawn
|
|
@@ -70,25 +82,28 @@ declare global {
|
|
|
70
82
|
* @default false
|
|
71
83
|
*/
|
|
72
84
|
renderStats: boolean;
|
|
85
|
+
|
|
73
86
|
/**
|
|
74
|
-
* "Made with q5play" [splash screen](https://en.wikipedia.org/wiki/Splash_screen)
|
|
75
|
-
* initial page load by default.
|
|
87
|
+
* "Made with q5play" [splash screen](https://en.wikipedia.org/wiki/Splash_screen)
|
|
88
|
+
* displayed during initial page load by default.
|
|
76
89
|
*/
|
|
77
90
|
splashScreen(): Promise<void>;
|
|
91
|
+
|
|
78
92
|
/**
|
|
79
|
-
* Runs automatically before each draw function call.
|
|
93
|
+
* Runs automatically before each q5.draw function call.
|
|
80
94
|
*/
|
|
81
95
|
update(): void;
|
|
96
|
+
|
|
82
97
|
/**
|
|
83
|
-
* Runs automatically after each draw function call.
|
|
98
|
+
* Runs automatically after each q5.draw function call.
|
|
84
99
|
*/
|
|
85
|
-
|
|
100
|
+
draw(): void;
|
|
86
101
|
}
|
|
87
102
|
const q5play: Q5Play;
|
|
88
103
|
|
|
89
104
|
/**
|
|
90
|
-
* Box2D v3 ported to WASM is
|
|
91
|
-
* q5play
|
|
105
|
+
* Box2D v3 ported to WASM is used by
|
|
106
|
+
* q5play to simulate physics.
|
|
92
107
|
*
|
|
93
108
|
* This variable enables direct access to the Box2D API for
|
|
94
109
|
* advanced users who want to do things that aren't wrapped
|
|
@@ -120,6 +135,10 @@ declare global {
|
|
|
120
135
|
friction: number;
|
|
121
136
|
bounciness: number;
|
|
122
137
|
density: number;
|
|
138
|
+
get rollingResistance(): number;
|
|
139
|
+
set rollingResistance(val: number);
|
|
140
|
+
get surfaceSpeed(): number;
|
|
141
|
+
set surfaceSpeed(val: number);
|
|
123
142
|
}
|
|
124
143
|
|
|
125
144
|
/**
|
|
@@ -136,45 +155,53 @@ declare global {
|
|
|
136
155
|
}
|
|
137
156
|
|
|
138
157
|
/**
|
|
139
|
-
* Visual
|
|
140
|
-
* with respect to the camera.
|
|
158
|
+
* A Visual object stores an image or animation(s)
|
|
159
|
+
* which can be displayed with respect to the camera.
|
|
141
160
|
*/
|
|
142
161
|
class Visual {
|
|
143
162
|
/**
|
|
144
163
|
* Horizontal position of the visual.
|
|
145
164
|
*/
|
|
146
165
|
x: number;
|
|
166
|
+
|
|
147
167
|
/**
|
|
148
168
|
* Vertical position of the visual.
|
|
149
169
|
*/
|
|
150
170
|
y: number;
|
|
171
|
+
|
|
151
172
|
/**
|
|
152
173
|
* Horizontal velocity of the visual.
|
|
153
174
|
*/
|
|
154
175
|
vx: number;
|
|
176
|
+
|
|
155
177
|
/**
|
|
156
178
|
* Vertical velocity of the visual.
|
|
157
179
|
*/
|
|
158
180
|
vy: number;
|
|
181
|
+
|
|
159
182
|
/**
|
|
160
183
|
* Draws the visual on the canvas.
|
|
161
184
|
*/
|
|
162
185
|
draw(): void;
|
|
186
|
+
|
|
163
187
|
/**
|
|
164
188
|
* Current image or frame of animation being displayed.
|
|
165
189
|
*/
|
|
166
190
|
get img(): Q5.Image;
|
|
167
|
-
set img(image: Q5.Image);
|
|
191
|
+
set img(image: string | Q5.Image);
|
|
192
|
+
|
|
168
193
|
/**
|
|
169
194
|
* Current animation.
|
|
170
195
|
*/
|
|
171
196
|
get ani(): Ani;
|
|
172
197
|
set ani(val: Ani);
|
|
198
|
+
|
|
173
199
|
/**
|
|
174
200
|
* Stores animations.
|
|
175
201
|
* Keys are the animation label, values are Ani objects
|
|
176
202
|
*/
|
|
177
203
|
get anis(): Anis;
|
|
204
|
+
|
|
178
205
|
/**
|
|
179
206
|
* Adds an animation to the Sprite or Visual.
|
|
180
207
|
*
|
|
@@ -183,6 +210,26 @@ declare global {
|
|
|
183
210
|
* @returns A promise that fulfills when the animation is loaded
|
|
184
211
|
*/
|
|
185
212
|
addAni(spriteSheetURL: string, frameCount: number): Promise<void>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Add multiple animations to the Sprite or Visual.
|
|
216
|
+
*
|
|
217
|
+
* @param atlases an object with animation names as keys and
|
|
218
|
+
* an animation or animation atlas as values
|
|
219
|
+
* @returns A promise that fulfills when the animations are loaded
|
|
220
|
+
*/
|
|
221
|
+
addAnis(atlases: {}): Promise<void>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Add multiple animations to the Sprite or Visual.
|
|
225
|
+
*
|
|
226
|
+
* @param spriteSheetURL the URL of the sprite sheet image
|
|
227
|
+
* @param atlases an object with animation names as keys and
|
|
228
|
+
* an animation or animation atlas as values
|
|
229
|
+
* @returns A promise that fulfills when the animations are loaded
|
|
230
|
+
*/
|
|
231
|
+
addAnis(spriteSheetURL: string, atlases: {}): Promise<void>;
|
|
232
|
+
|
|
186
233
|
/**
|
|
187
234
|
* Add multiple animations to the Sprite or Visual.
|
|
188
235
|
*
|
|
@@ -192,7 +239,8 @@ declare global {
|
|
|
192
239
|
* an animation or animation atlas as values
|
|
193
240
|
* @returns A promise that fulfills when the animations are loaded
|
|
194
241
|
*/
|
|
195
|
-
addAnis(spriteSheetURL
|
|
242
|
+
addAnis(spriteSheetURL: string, frameSize: string, atlases: {}): Promise<void>;
|
|
243
|
+
|
|
196
244
|
/**
|
|
197
245
|
* Changes the sprite's animation. Use `addAni` to define the
|
|
198
246
|
* animation(s) first.
|
|
@@ -200,6 +248,7 @@ declare global {
|
|
|
200
248
|
* @param name the name of the animation to switch to
|
|
201
249
|
*/
|
|
202
250
|
changeAni(name: string): void;
|
|
251
|
+
|
|
203
252
|
/**
|
|
204
253
|
* Plays an animation.
|
|
205
254
|
*
|
|
@@ -212,6 +261,7 @@ declare global {
|
|
|
212
261
|
* @returns A promise that fulfills when the animation completes
|
|
213
262
|
*/
|
|
214
263
|
playAni(name: string): Promise<void>;
|
|
264
|
+
|
|
215
265
|
/**
|
|
216
266
|
* Plays a sequence of animations.
|
|
217
267
|
*
|
|
@@ -237,6 +287,9 @@ declare global {
|
|
|
237
287
|
const KINEMATIC: 'kinematic';
|
|
238
288
|
const KIN: 'kinematic';
|
|
239
289
|
|
|
290
|
+
/**
|
|
291
|
+
* A Sprite has a Box2D physics body with a collider (by default), which can interact with other sprites in the physics simulation.
|
|
292
|
+
*/
|
|
240
293
|
class Sprite extends Visual {
|
|
241
294
|
/**
|
|
242
295
|
* Creates a new sprite.
|
|
@@ -252,9 +305,131 @@ declare global {
|
|
|
252
305
|
* STATIC or KINEMATIC
|
|
253
306
|
*/
|
|
254
307
|
constructor(x?: number, y?: number, w?: number, h?: number, physicsType?: string);
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Creates a new sprite.
|
|
311
|
+
* @param x horizontal position
|
|
312
|
+
* @param y vertical position
|
|
313
|
+
* @param w width of the collider
|
|
314
|
+
* @param h height of the collider
|
|
315
|
+
* @param roundedRadius corner radius for a rounded box collider
|
|
316
|
+
* @param physicsType physics type is DYNAMIC by default, can be
|
|
317
|
+
* STATIC or KINEMATIC
|
|
318
|
+
*/
|
|
319
|
+
constructor(x?: number, y?: number, w?: number, h?: number, roundedRadius?: number, physicsType?: string);
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Creates a new sprite with a circle collider.
|
|
323
|
+
* @param x horizontal position
|
|
324
|
+
* @param y vertical position
|
|
325
|
+
* @param d diameter of the circle collider
|
|
326
|
+
* @param physicsType physics type is DYNAMIC by default, can be
|
|
327
|
+
* STATIC or KINEMATIC
|
|
328
|
+
*/
|
|
329
|
+
constructor(x: number, y: number, d: number, physicsType?: string);
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Creates a new sprite with a capsule collider.
|
|
333
|
+
* @param points array of two [x, y] points defining the capsule's endpoints
|
|
334
|
+
* @param roundedRadius the radius of the capsule's rounded ends
|
|
335
|
+
* @param physicsType physics type is DYNAMIC by default, can be
|
|
336
|
+
* STATIC or KINEMATIC
|
|
337
|
+
*/
|
|
338
|
+
constructor(points: [number, number][], roundedRadius: number, physicsType?: string);
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Creates a new sprite with a chain or polygon collider defined by absolute vertex positions.
|
|
342
|
+
* If the first and last vertex are the same and the shape is convex, it becomes a polygon.
|
|
343
|
+
* @param vertices array of [x, y] vertex positions
|
|
344
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
345
|
+
*/
|
|
346
|
+
constructor(vertices: [number, number][], physicsType?: string);
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Creates a new sprite with a chain collider defined by relative vertex offsets from the sprite's position.
|
|
350
|
+
* @param x horizontal position
|
|
351
|
+
* @param y vertical position
|
|
352
|
+
* @param vertices array of relative [x, y] vertex offsets
|
|
353
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
354
|
+
*/
|
|
355
|
+
constructor(x: number, y: number, vertices: [number, number][], physicsType?: string);
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Creates a new sprite with a chain collider defined by alternating segment lengths and angles.
|
|
359
|
+
* Each angle is relative to the previous segment's angle.
|
|
360
|
+
* If the last value is 5, the chain is closed into a loop.
|
|
361
|
+
* @param x horizontal position
|
|
362
|
+
* @param y vertical position
|
|
363
|
+
* @param distAngles alternating segment lengths and relative angles; append 5 to close the chain
|
|
364
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
365
|
+
*/
|
|
366
|
+
constructor(x: number, y: number, distAngles: number[], physicsType?: string);
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Creates a new sprite with a rounded chain collider defined by alternating segment lengths and angles.
|
|
370
|
+
* Each angle is relative to the previous segment's angle.
|
|
371
|
+
* If the last value is 5, the chain is closed into a loop.
|
|
372
|
+
* @param x horizontal position
|
|
373
|
+
* @param y vertical position
|
|
374
|
+
* @param distAngles alternating segment lengths and relative angles; append 5 to close the chain
|
|
375
|
+
* @param roundedRadius the rounded radius of the chain's segments
|
|
376
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
377
|
+
*/
|
|
378
|
+
constructor(x: number, y: number, distAngles: number[], roundedRadius: number, physicsType?: string);
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Creates a new sprite with a regular polygon collider.
|
|
382
|
+
* @param x horizontal position
|
|
383
|
+
* @param y vertical position
|
|
384
|
+
* @param sideLength the length of each side of the polygon
|
|
385
|
+
* @param polygonName 'triangle', 'square', 'pentagon', 'hexagon', 'septagon', or 'octagon'
|
|
386
|
+
* @param roundedRadius corner radius for a rounded polygon
|
|
387
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
388
|
+
*/
|
|
389
|
+
constructor(
|
|
390
|
+
x: number,
|
|
391
|
+
y: number,
|
|
392
|
+
sideLength: number,
|
|
393
|
+
polygonName: string,
|
|
394
|
+
roundedRadius?: number,
|
|
395
|
+
physicsType?: string
|
|
396
|
+
);
|
|
397
|
+
|
|
398
|
+
constructor(ani: string | Ani | Q5.Image, x?: number, y?: number, w?: number, h?: number, physicsType?: string);
|
|
399
|
+
constructor(
|
|
400
|
+
ani: string | Ani | Q5.Image,
|
|
401
|
+
x?: number,
|
|
402
|
+
y?: number,
|
|
403
|
+
w?: number,
|
|
404
|
+
h?: number,
|
|
405
|
+
roundedRadius?: number,
|
|
406
|
+
physicsType?: string
|
|
407
|
+
);
|
|
408
|
+
constructor(ani: string | Ani | Q5.Image, x: number, y: number, d: number, physicsType?: string);
|
|
409
|
+
constructor(ani: string | Ani | Q5.Image, points: [number, number][], roundedRadius: number, physicsType?: string);
|
|
410
|
+
constructor(ani: string | Ani | Q5.Image, vertices: [number, number][], physicsType?: string);
|
|
411
|
+
constructor(ani: string | Ani | Q5.Image, x: number, y: number, vertices: [number, number][], physicsType?: string);
|
|
412
|
+
constructor(ani: string | Ani | Q5.Image, x: number, y: number, distAngles: number[], physicsType?: string);
|
|
413
|
+
constructor(
|
|
414
|
+
ani: string | Ani | Q5.Image,
|
|
415
|
+
x: number,
|
|
416
|
+
y: number,
|
|
417
|
+
distAngles: number[],
|
|
418
|
+
roundedRadius: number,
|
|
419
|
+
physicsType?: string
|
|
420
|
+
);
|
|
421
|
+
constructor(
|
|
422
|
+
ani: string | Ani | Q5.Image,
|
|
423
|
+
x: number,
|
|
424
|
+
y: number,
|
|
425
|
+
sideLength: number,
|
|
426
|
+
polygonName: string,
|
|
427
|
+
roundedRadius?: number,
|
|
428
|
+
physicsType?: string
|
|
429
|
+
);
|
|
430
|
+
|
|
255
431
|
/**
|
|
256
432
|
* Creates a new sprite with an overlap sensor instead of a collider.
|
|
257
|
-
*
|
|
258
433
|
* @param x horizontal position
|
|
259
434
|
* @param y vertical position
|
|
260
435
|
* @param w width of the sensor
|
|
@@ -263,6 +438,160 @@ declare global {
|
|
|
263
438
|
* STATIC or KINEMATIC
|
|
264
439
|
*/
|
|
265
440
|
static withSensor(x?: number, y?: number, w?: number, h?: number, physicsType?: string): Sprite;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Creates a new sprite with an overlap sensor instead of a collider.
|
|
444
|
+
* @param x horizontal position
|
|
445
|
+
* @param y vertical position
|
|
446
|
+
* @param w width of the sensor
|
|
447
|
+
* @param h height of the sensor
|
|
448
|
+
* @param roundedRadius corner radius for a rounded box sensor
|
|
449
|
+
* @param physicsType physics type is DYNAMIC by default, can be
|
|
450
|
+
* STATIC or KINEMATIC
|
|
451
|
+
*/
|
|
452
|
+
static withSensor(
|
|
453
|
+
x?: number,
|
|
454
|
+
y?: number,
|
|
455
|
+
w?: number,
|
|
456
|
+
h?: number,
|
|
457
|
+
roundedRadius?: number,
|
|
458
|
+
physicsType?: string
|
|
459
|
+
): Sprite;
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Creates a new sprite with a circle overlap sensor.
|
|
463
|
+
* @param x horizontal position
|
|
464
|
+
* @param y vertical position
|
|
465
|
+
* @param d diameter of the circle sensor
|
|
466
|
+
* @param physicsType physics type is DYNAMIC by default, can be
|
|
467
|
+
* STATIC or KINEMATIC
|
|
468
|
+
*/
|
|
469
|
+
static withSensor(x: number, y: number, d: number, physicsType?: string): Sprite;
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Creates a new sprite with a capsule overlap sensor.
|
|
473
|
+
* @param points array of two [x, y] points defining the capsule's endpoints
|
|
474
|
+
* @param roundedRadius the radius of the capsule's rounded ends
|
|
475
|
+
* @param physicsType physics type is DYNAMIC by default, can be
|
|
476
|
+
* STATIC or KINEMATIC
|
|
477
|
+
*/
|
|
478
|
+
static withSensor(points: [number, number][], roundedRadius: number, physicsType?: string): Sprite;
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Creates a new sprite with a chain overlap sensor defined by absolute vertex positions.
|
|
482
|
+
* If the first and last vertex are the same and the shape is convex, it becomes a polygon sensor.
|
|
483
|
+
* @param vertices array of [x, y] vertex positions
|
|
484
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
485
|
+
*/
|
|
486
|
+
static withSensor(vertices: [number, number][], physicsType?: string): Sprite;
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Creates a new sprite with a chain overlap sensor defined by relative vertex offsets from the sprite's position.
|
|
490
|
+
* @param x horizontal position
|
|
491
|
+
* @param y vertical position
|
|
492
|
+
* @param vertices array of relative [x, y] vertex offsets
|
|
493
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
494
|
+
*/
|
|
495
|
+
static withSensor(x: number, y: number, vertices: [number, number][], physicsType?: string): Sprite;
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Creates a new sprite with a chain overlap sensor defined by alternating segment lengths and angles.
|
|
499
|
+
* Each angle is relative to the previous segment's angle.
|
|
500
|
+
* If the last value is 5, the chain is closed into a loop.
|
|
501
|
+
* @param x horizontal position
|
|
502
|
+
* @param y vertical position
|
|
503
|
+
* @param distAngles alternating segment lengths and relative angles; append 5 to close the chain
|
|
504
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
505
|
+
*/
|
|
506
|
+
static withSensor(x: number, y: number, distAngles: number[], physicsType?: string): Sprite;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Creates a new sprite with a rounded chain overlap sensor defined by alternating segment lengths and angles.
|
|
510
|
+
* Each angle is relative to the previous segment's angle.
|
|
511
|
+
* If the last value is 5, the chain is closed into a loop.
|
|
512
|
+
* @param x horizontal position
|
|
513
|
+
* @param y vertical position
|
|
514
|
+
* @param distAngles alternating segment lengths and relative angles; append 5 to close the chain
|
|
515
|
+
* @param roundedRadius the rounded radius of the chain's segments
|
|
516
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
517
|
+
*/
|
|
518
|
+
static withSensor(x: number, y: number, distAngles: number[], roundedRadius: number, physicsType?: string): Sprite;
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Creates a new sprite with a regular polygon overlap sensor.
|
|
522
|
+
* @param x horizontal position
|
|
523
|
+
* @param y vertical position
|
|
524
|
+
* @param sideLength the length of each side of the polygon
|
|
525
|
+
* @param polygonName 'triangle', 'square', 'pentagon', 'hexagon', 'septagon', or 'octagon'
|
|
526
|
+
* @param roundedRadius corner radius for a rounded polygon
|
|
527
|
+
* @param physicsType physics type is DYNAMIC by default, can be STATIC or KINEMATIC
|
|
528
|
+
*/
|
|
529
|
+
static withSensor(
|
|
530
|
+
x: number,
|
|
531
|
+
y: number,
|
|
532
|
+
sideLength: number,
|
|
533
|
+
polygonName: string,
|
|
534
|
+
roundedRadius?: number,
|
|
535
|
+
physicsType?: string
|
|
536
|
+
): Sprite;
|
|
537
|
+
|
|
538
|
+
static withSensor(
|
|
539
|
+
ani: string | Ani | Q5.Image,
|
|
540
|
+
x?: number,
|
|
541
|
+
y?: number,
|
|
542
|
+
w?: number,
|
|
543
|
+
h?: number,
|
|
544
|
+
physicsType?: string
|
|
545
|
+
): Sprite;
|
|
546
|
+
static withSensor(
|
|
547
|
+
ani: string | Ani | Q5.Image,
|
|
548
|
+
x?: number,
|
|
549
|
+
y?: number,
|
|
550
|
+
w?: number,
|
|
551
|
+
h?: number,
|
|
552
|
+
roundedRadius?: number,
|
|
553
|
+
physicsType?: string
|
|
554
|
+
): Sprite;
|
|
555
|
+
static withSensor(ani: string | Ani | Q5.Image, x: number, y: number, d: number, physicsType?: string): Sprite;
|
|
556
|
+
static withSensor(
|
|
557
|
+
ani: string | Ani | Q5.Image,
|
|
558
|
+
points: [number, number][],
|
|
559
|
+
roundedRadius: number,
|
|
560
|
+
physicsType?: string
|
|
561
|
+
): Sprite;
|
|
562
|
+
static withSensor(ani: string | Ani | Q5.Image, vertices: [number, number][], physicsType?: string): Sprite;
|
|
563
|
+
static withSensor(
|
|
564
|
+
ani: string | Ani | Q5.Image,
|
|
565
|
+
x: number,
|
|
566
|
+
y: number,
|
|
567
|
+
vertices: [number, number][],
|
|
568
|
+
physicsType?: string
|
|
569
|
+
): Sprite;
|
|
570
|
+
static withSensor(
|
|
571
|
+
ani: string | Ani | Q5.Image,
|
|
572
|
+
x: number,
|
|
573
|
+
y: number,
|
|
574
|
+
distAngles: number[],
|
|
575
|
+
physicsType?: string
|
|
576
|
+
): Sprite;
|
|
577
|
+
static withSensor(
|
|
578
|
+
ani: string | Ani | Q5.Image,
|
|
579
|
+
x: number,
|
|
580
|
+
y: number,
|
|
581
|
+
distAngles: number[],
|
|
582
|
+
roundedRadius: number,
|
|
583
|
+
physicsType?: string
|
|
584
|
+
): Sprite;
|
|
585
|
+
static withSensor(
|
|
586
|
+
ani: string | Ani | Q5.Image,
|
|
587
|
+
x: number,
|
|
588
|
+
y: number,
|
|
589
|
+
sideLength: number,
|
|
590
|
+
polygonName: string,
|
|
591
|
+
roundedRadius?: number,
|
|
592
|
+
physicsType?: string
|
|
593
|
+
): Sprite;
|
|
594
|
+
|
|
266
595
|
/**
|
|
267
596
|
* The physics type of the sprite, which determines how it interacts with
|
|
268
597
|
* other sprites in the physics simulation.
|
|
@@ -272,6 +601,7 @@ declare global {
|
|
|
272
601
|
*/
|
|
273
602
|
get physics(): string;
|
|
274
603
|
set physics(val: string);
|
|
604
|
+
|
|
275
605
|
/**
|
|
276
606
|
* The physics type of the sprite, which determines how it interacts with
|
|
277
607
|
* other sprites in the physics simulation.
|
|
@@ -281,40 +611,53 @@ declare global {
|
|
|
281
611
|
*/
|
|
282
612
|
get physicsType(): string;
|
|
283
613
|
set physicsType(val: string);
|
|
614
|
+
|
|
284
615
|
/**
|
|
285
616
|
* If true, the sprite's physics body is included in the physics simulation.
|
|
286
617
|
* @default true
|
|
287
618
|
*/
|
|
288
619
|
get physicsEnabled(): boolean;
|
|
289
620
|
set physicsEnabled(val: boolean);
|
|
621
|
+
|
|
290
622
|
/**
|
|
291
623
|
* Each sprite has a unique id number. Don't change it!
|
|
292
624
|
* They are useful for debugging.
|
|
293
625
|
*/
|
|
294
626
|
idNum: number;
|
|
627
|
+
|
|
628
|
+
/**
|
|
629
|
+
* The Box2D body id for the sprite's physics body. Don't change it!
|
|
630
|
+
*/
|
|
631
|
+
bdID: b2BodyId;
|
|
632
|
+
|
|
295
633
|
/**
|
|
296
634
|
* Groups the sprite belongs to.
|
|
297
635
|
* @default [allSprites]
|
|
298
636
|
*/
|
|
299
637
|
groups: Group[];
|
|
638
|
+
|
|
300
639
|
/**
|
|
301
640
|
* Keys are the animation label, values are Ani objects.
|
|
302
641
|
*/
|
|
303
642
|
animations: Anis;
|
|
643
|
+
|
|
304
644
|
/**
|
|
305
645
|
* Array of colliders that are part of the sprite's physics body.
|
|
306
646
|
*/
|
|
307
647
|
colliders: Collider[];
|
|
648
|
+
|
|
308
649
|
/**
|
|
309
650
|
* Array of sensors that are part of the sprite's physics body.
|
|
310
651
|
* Sensors are used to detect overlaps without causing physical collisions.
|
|
311
652
|
*/
|
|
312
653
|
sensors: Sensor[];
|
|
654
|
+
|
|
313
655
|
/**
|
|
314
656
|
* Joints that the sprite is attached to.
|
|
315
657
|
* @default []
|
|
316
658
|
*/
|
|
317
659
|
joints: Joint[];
|
|
660
|
+
|
|
318
661
|
/**
|
|
319
662
|
* If set to true, q5play will record all changes to the sprite's
|
|
320
663
|
* properties in its `mod` array. Intended to be used to enable
|
|
@@ -322,6 +665,7 @@ declare global {
|
|
|
322
665
|
* @default undefined
|
|
323
666
|
*/
|
|
324
667
|
watch: boolean;
|
|
668
|
+
|
|
325
669
|
/**
|
|
326
670
|
* Modification tracking object.
|
|
327
671
|
*
|
|
@@ -334,39 +678,52 @@ declare global {
|
|
|
334
678
|
* to only the sprite properties that have been modified.
|
|
335
679
|
*/
|
|
336
680
|
mod: {};
|
|
681
|
+
|
|
337
682
|
/**
|
|
338
683
|
* The horizontal position of the sprite.
|
|
339
684
|
*/
|
|
340
685
|
get x(): number;
|
|
341
686
|
set x(val: number);
|
|
687
|
+
|
|
342
688
|
/**
|
|
343
689
|
* The vertical position of the sprite.
|
|
344
690
|
*/
|
|
345
691
|
get y(): number;
|
|
346
692
|
set y(val: number);
|
|
693
|
+
|
|
347
694
|
/**
|
|
348
695
|
* The width of the sprite.
|
|
349
696
|
*/
|
|
350
697
|
get w(): number;
|
|
351
698
|
set w(val: number);
|
|
699
|
+
|
|
352
700
|
/**
|
|
353
701
|
* The height of the sprite.
|
|
354
702
|
*/
|
|
355
703
|
get h(): number;
|
|
356
704
|
set h(val: number);
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* The sprite's x position on the previous frame.
|
|
708
|
+
*/
|
|
709
|
+
prevX: number;
|
|
710
|
+
|
|
357
711
|
/**
|
|
358
|
-
* The sprite's position on the previous frame.
|
|
712
|
+
* The sprite's y position on the previous frame.
|
|
359
713
|
*/
|
|
360
|
-
|
|
714
|
+
prevY: number;
|
|
715
|
+
|
|
361
716
|
/**
|
|
362
717
|
* The sprite's rotation on the previous frame.
|
|
363
718
|
*/
|
|
364
719
|
prevRotation: number;
|
|
720
|
+
|
|
365
721
|
/**
|
|
366
722
|
* Text displayed at the center of the sprite.
|
|
367
723
|
* @default undefined
|
|
368
724
|
*/
|
|
369
725
|
text: string;
|
|
726
|
+
|
|
370
727
|
/**
|
|
371
728
|
* Adds a collider to the sprite's physics body.
|
|
372
729
|
*
|
|
@@ -383,8 +740,10 @@ declare global {
|
|
|
383
740
|
* @param offsetY distance from the center of the sprite
|
|
384
741
|
* @param w width of the collider
|
|
385
742
|
* @param h height of the collider
|
|
743
|
+
* @param roundedRadius corner radius for a rounded box collider
|
|
386
744
|
*/
|
|
387
|
-
addCollider(offsetX: number, offsetY: number, w?: number, h?: number): void;
|
|
745
|
+
addCollider(offsetX: number, offsetY: number, w?: number, h?: number, roundedRadius?: number): void;
|
|
746
|
+
|
|
388
747
|
/**
|
|
389
748
|
* Adds an overlap sensor to the sprite's physics body.
|
|
390
749
|
*
|
|
@@ -401,13 +760,16 @@ declare global {
|
|
|
401
760
|
* @param offsetY distance from the center of the sprite
|
|
402
761
|
* @param w width of the collider
|
|
403
762
|
* @param h height of the collider
|
|
763
|
+
* @param roundedRadius corner radius for a rounded box sensor
|
|
404
764
|
*/
|
|
405
|
-
addSensor(offsetX: number, offsetY: number, w?: number, h?: number): void;
|
|
765
|
+
addSensor(offsetX: number, offsetY: number, w?: number, h?: number, roundedRadius?: number): void;
|
|
766
|
+
|
|
406
767
|
/**
|
|
407
768
|
* The mass of the sprite's physics body.
|
|
408
769
|
*/
|
|
409
770
|
get mass(): number;
|
|
410
771
|
set mass(val: number);
|
|
772
|
+
|
|
411
773
|
/**
|
|
412
774
|
* The center of mass of the sprite's physics body, the point at which
|
|
413
775
|
* the physics body is balanced and rotates around. By default it's the
|
|
@@ -415,6 +777,7 @@ declare global {
|
|
|
415
777
|
*/
|
|
416
778
|
get centerOfMass(): { x: number; y: number };
|
|
417
779
|
set centerOfMass(val: { x: number; y: number });
|
|
780
|
+
|
|
418
781
|
/**
|
|
419
782
|
* If true, the center of mass of the sprite's physics body is fixed to
|
|
420
783
|
* the sprite's [x, y] position.
|
|
@@ -426,11 +789,13 @@ declare global {
|
|
|
426
789
|
*/
|
|
427
790
|
get fixedCenterOfMass(): boolean;
|
|
428
791
|
set fixedCenterOfMass(val: boolean);
|
|
792
|
+
|
|
429
793
|
/**
|
|
430
794
|
* Recalculates the sprite's mass based on its current
|
|
431
795
|
* density and size.
|
|
432
796
|
*/
|
|
433
797
|
resetMass(): void;
|
|
798
|
+
|
|
434
799
|
/**
|
|
435
800
|
* The angle of the sprite's rotation, not the direction it's moving.
|
|
436
801
|
*
|
|
@@ -440,26 +805,31 @@ declare global {
|
|
|
440
805
|
*/
|
|
441
806
|
get rotation(): number;
|
|
442
807
|
set rotation(val: number);
|
|
808
|
+
|
|
443
809
|
/**
|
|
444
810
|
* Removes colliders from the sprite's physics body.
|
|
445
811
|
*/
|
|
446
|
-
|
|
812
|
+
deleteColliders(): void;
|
|
813
|
+
|
|
447
814
|
/**
|
|
448
815
|
* Removes overlap sensors from the sprite's physics body.
|
|
449
816
|
*/
|
|
450
|
-
|
|
817
|
+
deleteSensors(): void;
|
|
818
|
+
|
|
451
819
|
/**
|
|
452
820
|
* If true, a sprite is updated by q5play before each physics update.
|
|
453
821
|
* @default true
|
|
454
822
|
*/
|
|
455
823
|
get autoUpdate(): boolean;
|
|
456
824
|
set autoUpdate(val: boolean);
|
|
825
|
+
|
|
457
826
|
/**
|
|
458
827
|
* If true, a sprite is drawn by q5play after each physics update.
|
|
459
828
|
* @default true
|
|
460
829
|
*/
|
|
461
830
|
get autoDraw(): boolean;
|
|
462
831
|
set autoDraw(val: boolean);
|
|
832
|
+
|
|
463
833
|
/**
|
|
464
834
|
* Controls the ability for a sprite to "sleep".
|
|
465
835
|
*
|
|
@@ -470,18 +840,21 @@ declare global {
|
|
|
470
840
|
*/
|
|
471
841
|
get allowSleeping(): boolean;
|
|
472
842
|
set allowSleeping(val: boolean);
|
|
843
|
+
|
|
473
844
|
/**
|
|
474
845
|
* The bounciness of the sprite's physics body.
|
|
475
846
|
* @default 0.2
|
|
476
847
|
*/
|
|
477
848
|
get bounciness(): number;
|
|
478
849
|
set bounciness(val: number);
|
|
850
|
+
|
|
479
851
|
/**
|
|
480
852
|
* The speed of the sprite's rotation in angles per frame.
|
|
481
853
|
* @default 0
|
|
482
854
|
*/
|
|
483
855
|
get rotationSpeed(): number;
|
|
484
856
|
set rotationSpeed(val: number);
|
|
857
|
+
|
|
485
858
|
/**
|
|
486
859
|
* The sprite's current fill color.
|
|
487
860
|
*
|
|
@@ -489,6 +862,7 @@ declare global {
|
|
|
489
862
|
*/
|
|
490
863
|
get color(): Q5.Color;
|
|
491
864
|
set color(val: Q5.Color);
|
|
865
|
+
|
|
492
866
|
/**
|
|
493
867
|
* The sprite's current fill colour.
|
|
494
868
|
*
|
|
@@ -496,6 +870,7 @@ declare global {
|
|
|
496
870
|
*/
|
|
497
871
|
get colour(): Q5.Color;
|
|
498
872
|
set colour(val: Q5.Color);
|
|
873
|
+
|
|
499
874
|
/**
|
|
500
875
|
* The sprite's current fill color.
|
|
501
876
|
*
|
|
@@ -503,27 +878,32 @@ declare global {
|
|
|
503
878
|
*/
|
|
504
879
|
get fill(): Q5.Color;
|
|
505
880
|
set fill(val: Q5.Color);
|
|
881
|
+
|
|
506
882
|
/**
|
|
507
883
|
* The sprite's stroke color.
|
|
508
884
|
*/
|
|
509
885
|
get stroke(): Q5.Color;
|
|
510
886
|
set stroke(val: Q5.Color);
|
|
887
|
+
|
|
511
888
|
/**
|
|
512
889
|
* The sprite's stroke weight, the thickness of its outline.
|
|
513
890
|
*/
|
|
514
891
|
get strokeWeight(): number;
|
|
515
892
|
set strokeWeight(val: number);
|
|
893
|
+
|
|
516
894
|
/**
|
|
517
895
|
* The sprite's text fill color. Black by default.
|
|
518
896
|
* @default black (#000000)
|
|
519
897
|
*/
|
|
520
898
|
get textFill(): Q5.Color;
|
|
521
899
|
set textFill(val: Q5.Color);
|
|
900
|
+
|
|
522
901
|
/**
|
|
523
902
|
* The sprite's text size, the sketch's current textSize by default.
|
|
524
903
|
*/
|
|
525
904
|
get textSize(): number;
|
|
526
905
|
set textSize(val: number);
|
|
906
|
+
|
|
527
907
|
/**
|
|
528
908
|
* The sprite's text stroke color.
|
|
529
909
|
* No stroke by default, does not inherit from the sketch's stroke color.
|
|
@@ -531,6 +911,7 @@ declare global {
|
|
|
531
911
|
*/
|
|
532
912
|
get textStroke(): Q5.Color;
|
|
533
913
|
set textStroke(val: Q5.Color);
|
|
914
|
+
|
|
534
915
|
/**
|
|
535
916
|
* The sprite's text stroke weight, the thickness of its outline.
|
|
536
917
|
* No stroke by default, does not inherit from the sketch's stroke weight.
|
|
@@ -538,11 +919,13 @@ declare global {
|
|
|
538
919
|
*/
|
|
539
920
|
get textStrokeWeight(): number;
|
|
540
921
|
set textStrokeWeight(val: number);
|
|
922
|
+
|
|
541
923
|
/**
|
|
542
924
|
* The tile character that represents the sprite in a tile map.
|
|
543
925
|
*/
|
|
544
926
|
get tile(): string;
|
|
545
927
|
set tile(val: string);
|
|
928
|
+
|
|
546
929
|
/**
|
|
547
930
|
* A bearing indicates the direction that needs to be followed to
|
|
548
931
|
* reach a destination.
|
|
@@ -553,30 +936,39 @@ declare global {
|
|
|
553
936
|
*/
|
|
554
937
|
get bearing(): number;
|
|
555
938
|
set bearing(val: number);
|
|
939
|
+
|
|
556
940
|
/**
|
|
557
941
|
* If true, outlines of the sprite's colliders and sensors will be drawn.
|
|
558
942
|
* @default false
|
|
559
943
|
*/
|
|
560
944
|
get debug(): boolean;
|
|
561
945
|
set debug(val: boolean);
|
|
946
|
+
|
|
562
947
|
/**
|
|
563
948
|
* The density of the sprite's physics body.
|
|
564
949
|
* @default 1
|
|
565
950
|
*/
|
|
566
951
|
get density(): number;
|
|
567
952
|
set density(val: number);
|
|
953
|
+
|
|
568
954
|
/**
|
|
569
955
|
* The angle of the sprite's movement.
|
|
956
|
+
*
|
|
957
|
+
* Can be set with directional strings like "up", "down", "left", "right",
|
|
958
|
+
* "upRight", "upLeft", "downRight", and "downLeft". The setter's input parser ignores
|
|
959
|
+
* capitalization, spaces, underscores, dashes, and cardinal direction word order.
|
|
570
960
|
* @default 0 ("right")
|
|
571
961
|
*/
|
|
572
962
|
get direction(): number;
|
|
573
|
-
set direction(val: number);
|
|
963
|
+
set direction(val: number | string);
|
|
964
|
+
|
|
574
965
|
/**
|
|
575
966
|
* The amount of resistance a sprite has to being moved.
|
|
576
967
|
* @default 0
|
|
577
968
|
*/
|
|
578
969
|
get drag(): number;
|
|
579
970
|
set drag(val: number);
|
|
971
|
+
|
|
580
972
|
/**
|
|
581
973
|
* Displays the sprite.
|
|
582
974
|
*
|
|
@@ -592,6 +984,7 @@ declare global {
|
|
|
592
984
|
*/
|
|
593
985
|
get draw(): Function;
|
|
594
986
|
set draw(val: Function);
|
|
987
|
+
|
|
595
988
|
/**
|
|
596
989
|
* The amount the sprite's colliders resist moving
|
|
597
990
|
* when rubbing against other colliders.
|
|
@@ -599,6 +992,7 @@ declare global {
|
|
|
599
992
|
*/
|
|
600
993
|
get friction(): number;
|
|
601
994
|
set friction(val: number);
|
|
995
|
+
|
|
602
996
|
/**
|
|
603
997
|
* The sprite's heading. This is a string that can be set to
|
|
604
998
|
* "up", "down", "left", "right", "upRight", "upLeft", "downRight"
|
|
@@ -609,6 +1003,7 @@ declare global {
|
|
|
609
1003
|
*/
|
|
610
1004
|
get heading(): string;
|
|
611
1005
|
set heading(val: string);
|
|
1006
|
+
|
|
612
1007
|
/**
|
|
613
1008
|
* Set this to true if the sprite goes really fast to prevent
|
|
614
1009
|
* inaccurate physics simulation.
|
|
@@ -616,6 +1011,7 @@ declare global {
|
|
|
616
1011
|
*/
|
|
617
1012
|
get isSuperFast(): boolean;
|
|
618
1013
|
set isSuperFast(val: boolean);
|
|
1014
|
+
|
|
619
1015
|
/**
|
|
620
1016
|
* Sprites with the highest layer value get drawn first.
|
|
621
1017
|
*
|
|
@@ -623,6 +1019,7 @@ declare global {
|
|
|
623
1019
|
*/
|
|
624
1020
|
get layer(): number;
|
|
625
1021
|
set layer(val: number);
|
|
1022
|
+
|
|
626
1023
|
/**
|
|
627
1024
|
* When the physics simulation is progressed in `world.physicsUpdate`,
|
|
628
1025
|
* each sprite's life is decreased by `world.timeScale`.
|
|
@@ -633,22 +1030,32 @@ declare global {
|
|
|
633
1030
|
*/
|
|
634
1031
|
get life(): number;
|
|
635
1032
|
set life(val: number);
|
|
1033
|
+
|
|
636
1034
|
/**
|
|
637
1035
|
* The sprite's opacity. 0 is transparent, 1 is opaque.
|
|
638
1036
|
* @default 1
|
|
639
1037
|
*/
|
|
640
1038
|
get opacity(): number;
|
|
641
1039
|
set opacity(val: number);
|
|
1040
|
+
|
|
642
1041
|
/**
|
|
643
|
-
*
|
|
1042
|
+
* The sprite's x position on the previous frame.
|
|
1043
|
+
* Alias for sprite.prevX.
|
|
644
1044
|
*/
|
|
645
|
-
get
|
|
646
|
-
|
|
1045
|
+
get previousX(): number;
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* The sprite's y position on the previous frame.
|
|
1049
|
+
* Alias for sprite.prevY.
|
|
1050
|
+
*/
|
|
1051
|
+
get previousY(): number;
|
|
1052
|
+
|
|
647
1053
|
/**
|
|
648
|
-
*
|
|
1054
|
+
* The sprite's rotation on the previous frame.
|
|
1055
|
+
* Alias for sprite.prevRotation.
|
|
649
1056
|
*/
|
|
650
1057
|
get previousRotation(): number;
|
|
651
|
-
|
|
1058
|
+
|
|
652
1059
|
/**
|
|
653
1060
|
* If true, q5play will draw sprites at integer pixel precision.
|
|
654
1061
|
*
|
|
@@ -659,12 +1066,14 @@ declare global {
|
|
|
659
1066
|
*/
|
|
660
1067
|
get pixelPerfect(): boolean;
|
|
661
1068
|
set pixelPerfect(val: boolean);
|
|
1069
|
+
|
|
662
1070
|
/**
|
|
663
|
-
* If the sprite has been
|
|
1071
|
+
* If the sprite has been deleted from the world.
|
|
664
1072
|
* @default false
|
|
665
1073
|
*/
|
|
666
|
-
get
|
|
667
|
-
set
|
|
1074
|
+
get deleted(): boolean;
|
|
1075
|
+
set deleted(val: boolean);
|
|
1076
|
+
|
|
668
1077
|
/**
|
|
669
1078
|
* Simulates friction that slows down a sprite rolling on another sprite,
|
|
670
1079
|
* like a soccer ball rolling to a stop on high grass.
|
|
@@ -672,18 +1081,21 @@ declare global {
|
|
|
672
1081
|
*/
|
|
673
1082
|
get rollingResistance(): number;
|
|
674
1083
|
set rollingResistance(val: number);
|
|
1084
|
+
|
|
675
1085
|
/**
|
|
676
1086
|
* The amount the sprite resists rotating.
|
|
677
1087
|
* @default 0
|
|
678
1088
|
*/
|
|
679
1089
|
get rotationDrag(): number;
|
|
680
1090
|
set rotationDrag(val: number);
|
|
1091
|
+
|
|
681
1092
|
/**
|
|
682
1093
|
* If true, the sprite can not rotate.
|
|
683
1094
|
* @default false
|
|
684
1095
|
*/
|
|
685
1096
|
get rotationLock(): boolean;
|
|
686
1097
|
set rotationLock(val: boolean);
|
|
1098
|
+
|
|
687
1099
|
/**
|
|
688
1100
|
* Horizontal and vertical scale of the sprite.
|
|
689
1101
|
*
|
|
@@ -696,12 +1108,17 @@ declare global {
|
|
|
696
1108
|
*/
|
|
697
1109
|
get scale(): number | { x: number; y: number };
|
|
698
1110
|
set scale(val: number | [] | { x: number; y: number });
|
|
1111
|
+
|
|
699
1112
|
/**
|
|
700
1113
|
* Scales the the sprite.
|
|
701
|
-
*
|
|
702
|
-
*
|
|
1114
|
+
*
|
|
1115
|
+
* Components can be negative to flip/mirror the sprite on an axis.
|
|
1116
|
+
*
|
|
1117
|
+
* @param x horizontal scale factor or uniform scale factor for both axes
|
|
1118
|
+
* @param y vertical scale factor
|
|
703
1119
|
*/
|
|
704
1120
|
scaleBy(x: number, y?: number): void;
|
|
1121
|
+
|
|
705
1122
|
/**
|
|
706
1123
|
* Wake a sprite up or put it to sleep.
|
|
707
1124
|
*
|
|
@@ -712,6 +1129,14 @@ declare global {
|
|
|
712
1129
|
*/
|
|
713
1130
|
get sleeping(): boolean;
|
|
714
1131
|
set sleeping(val: boolean);
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* The minimum speed (in m/s) at which the sprite must be moving
|
|
1135
|
+
* before it is considered awake.
|
|
1136
|
+
*/
|
|
1137
|
+
get sleepThreshold(): number;
|
|
1138
|
+
set sleepThreshold(val: number);
|
|
1139
|
+
|
|
715
1140
|
/**
|
|
716
1141
|
* The sprite's speed.
|
|
717
1142
|
*
|
|
@@ -721,19 +1146,23 @@ declare global {
|
|
|
721
1146
|
*/
|
|
722
1147
|
get speed(): number;
|
|
723
1148
|
set speed(val: number);
|
|
1149
|
+
|
|
724
1150
|
/**
|
|
725
1151
|
* Efficiently sets the sprite's speed and direction at the same time.
|
|
726
1152
|
* @param speed
|
|
727
1153
|
* @param direction
|
|
728
1154
|
*/
|
|
729
1155
|
setSpeedAndDirection(speed: number, direction: number): void;
|
|
1156
|
+
|
|
730
1157
|
/**
|
|
731
1158
|
* The sprite's speed along the surface of its collider(s),
|
|
732
1159
|
* like a conveyor belt.
|
|
1160
|
+
* Requires friction to be greater than 1 to have an effect.
|
|
733
1161
|
* @default 0
|
|
734
1162
|
*/
|
|
735
1163
|
get surfaceSpeed(): number;
|
|
736
1164
|
set surfaceSpeed(val: number);
|
|
1165
|
+
|
|
737
1166
|
/**
|
|
738
1167
|
* Tint color applied to the sprite when drawn.
|
|
739
1168
|
*
|
|
@@ -743,6 +1172,7 @@ declare global {
|
|
|
743
1172
|
*/
|
|
744
1173
|
get tint(): Q5.Color;
|
|
745
1174
|
set tint(val: Q5.Color);
|
|
1175
|
+
|
|
746
1176
|
/**
|
|
747
1177
|
* If true the sprite is shown, if set to false the sprite is hidden.
|
|
748
1178
|
*
|
|
@@ -752,71 +1182,91 @@ declare global {
|
|
|
752
1182
|
*/
|
|
753
1183
|
get visible(): boolean;
|
|
754
1184
|
set visible(val: boolean);
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* Gets the sprite's position as a readonly object {x, y} which
|
|
1188
|
+
* won't be updated if the sprite moves. Useful for saving
|
|
1189
|
+
* the sprite's position at a specific moment in time.
|
|
1190
|
+
*/
|
|
1191
|
+
get pos(): { x: number; y: number };
|
|
1192
|
+
|
|
755
1193
|
/**
|
|
756
|
-
* The position vector
|
|
1194
|
+
* The sprite's position vector.
|
|
757
1195
|
*/
|
|
758
|
-
|
|
759
|
-
|
|
1196
|
+
set pos(val: number[] | { x: number; y: number });
|
|
1197
|
+
|
|
760
1198
|
/**
|
|
761
|
-
* The position vector
|
|
1199
|
+
* The sprite's position vector.
|
|
762
1200
|
*/
|
|
763
1201
|
get position(): Q5.Vector;
|
|
764
|
-
set position(val: [] | { x: number; y: number }
|
|
1202
|
+
set position(val: number[] | { x: number; y: number });
|
|
1203
|
+
|
|
765
1204
|
/**
|
|
766
1205
|
* The sprite's absolute position on the canvas.
|
|
767
1206
|
* @readonly
|
|
768
1207
|
*/
|
|
769
1208
|
get canvasPos(): any;
|
|
1209
|
+
|
|
770
1210
|
/**
|
|
771
1211
|
* Half the width of the sprite.
|
|
772
1212
|
*/
|
|
773
1213
|
get hw(): number;
|
|
774
1214
|
set hw(val: number);
|
|
1215
|
+
|
|
775
1216
|
/**
|
|
776
1217
|
* The width of the sprite.
|
|
777
1218
|
*/
|
|
778
1219
|
get width(): number;
|
|
779
1220
|
set width(val: number);
|
|
1221
|
+
|
|
780
1222
|
/**
|
|
781
1223
|
* Half the width of the sprite.
|
|
782
1224
|
*/
|
|
783
1225
|
get halfWidth(): number;
|
|
784
1226
|
set halfWidth(val: number);
|
|
1227
|
+
|
|
785
1228
|
/**
|
|
786
1229
|
* Half the height of the sprite.
|
|
787
1230
|
*/
|
|
788
1231
|
get hh(): number;
|
|
789
1232
|
set hh(val: number);
|
|
1233
|
+
|
|
790
1234
|
/**
|
|
791
1235
|
* The height of the sprite.
|
|
792
1236
|
*/
|
|
793
1237
|
get height(): number;
|
|
794
1238
|
set height(val: number);
|
|
1239
|
+
|
|
795
1240
|
/**
|
|
796
1241
|
* Half the height of the sprite.
|
|
797
1242
|
*/
|
|
798
1243
|
get halfHeight(): number;
|
|
799
1244
|
set halfHeight(val: number);
|
|
1245
|
+
|
|
800
1246
|
/**
|
|
801
1247
|
* The diameter of a circular sprite.
|
|
802
1248
|
*/
|
|
803
1249
|
get d(): number;
|
|
804
1250
|
set d(val: number);
|
|
1251
|
+
|
|
805
1252
|
/**
|
|
806
1253
|
* The diameter of a circular sprite.
|
|
807
1254
|
*/
|
|
808
1255
|
get diameter(): number;
|
|
809
1256
|
set diameter(val: number);
|
|
1257
|
+
|
|
810
1258
|
/**
|
|
811
1259
|
* The radius of a circular sprite.
|
|
812
1260
|
*/
|
|
813
1261
|
get r(): number;
|
|
814
1262
|
set r(val: number);
|
|
1263
|
+
|
|
815
1264
|
/**
|
|
816
1265
|
* The radius of a circular sprite.
|
|
817
1266
|
*/
|
|
818
1267
|
get radius(): number;
|
|
819
1268
|
set radius(val: number);
|
|
1269
|
+
|
|
820
1270
|
/**
|
|
821
1271
|
* Runs before each physics update by default.
|
|
822
1272
|
*
|
|
@@ -828,45 +1278,93 @@ declare global {
|
|
|
828
1278
|
*/
|
|
829
1279
|
get update(): Function;
|
|
830
1280
|
set update(val: Function);
|
|
1281
|
+
|
|
831
1282
|
/**
|
|
832
1283
|
* The sprite's velocity vector {x, y}
|
|
833
1284
|
* @default {x: 0, y: 0}
|
|
834
1285
|
*/
|
|
835
1286
|
get vel(): Q5.Vector;
|
|
836
1287
|
set vel(val: [] | { x: number; y: number } | Q5.Vector);
|
|
1288
|
+
|
|
837
1289
|
/**
|
|
838
1290
|
* The sprite's velocity vector {x, y}
|
|
839
1291
|
* @default {x: 0, y: 0}
|
|
840
1292
|
*/
|
|
841
1293
|
get velocity(): Q5.Vector;
|
|
842
1294
|
set velocity(val: [] | { x: number; y: number } | Q5.Vector);
|
|
1295
|
+
|
|
843
1296
|
/**
|
|
844
1297
|
* Whether the sprite can be grabbed by a pointer.
|
|
845
1298
|
*/
|
|
846
1299
|
get grabbable(): boolean;
|
|
847
1300
|
set grabbable(val: boolean);
|
|
1301
|
+
|
|
848
1302
|
/**
|
|
849
1303
|
* A ratio that defines how much the sprite is affected by gravity.
|
|
850
1304
|
* @default 1
|
|
851
1305
|
*/
|
|
852
1306
|
get gravityScale(): number;
|
|
853
1307
|
set gravityScale(val: number);
|
|
1308
|
+
|
|
854
1309
|
/**
|
|
855
1310
|
* If this function is given a force amount, the force is applied
|
|
856
1311
|
* at the angle of the sprite's current bearing. Force can
|
|
857
1312
|
* also be given as a vector.
|
|
858
1313
|
*
|
|
859
1314
|
* @param amount
|
|
860
|
-
* @param origin The point the force is applied from, relative to the sprite's center of mass. Accepts
|
|
1315
|
+
* @param origin The point the force is applied from, relative to the sprite's center of mass. Accepts an object with `x` and `y` properties. If not given, the force is applied at the center of mass.
|
|
861
1316
|
*/
|
|
862
|
-
|
|
1317
|
+
/**
|
|
1318
|
+
* Applies a force to the sprite.
|
|
1319
|
+
*
|
|
1320
|
+
* - If the first argument is a number, it is treated as a force magnitude
|
|
1321
|
+
* applied at the sprite's current bearing.
|
|
1322
|
+
* - If the first argument is an object, it is treated
|
|
1323
|
+
* as a force vector `{x, y}`.
|
|
1324
|
+
*
|
|
1325
|
+
* The optional `origin` is the point (relative to the sprite's center)
|
|
1326
|
+
* where the force is applied. `origin` accepts an object with `x` and
|
|
1327
|
+
* `y` properties. Arrays are not accepted for input args.
|
|
1328
|
+
*/
|
|
1329
|
+
/**
|
|
1330
|
+
* Applies a force magnitude at the sprite's current bearing.
|
|
1331
|
+
* @param amount force magnitude
|
|
1332
|
+
* @param origin point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1333
|
+
*/
|
|
1334
|
+
applyForce(amount: number, origin?: { x: number; y: number }): void;
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* Applies a force vector to the sprite.
|
|
1338
|
+
* @param force force vector as an object with `x` and `y` properties or array of [x, y]
|
|
1339
|
+
* @param origin point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1340
|
+
*/
|
|
1341
|
+
applyForce(force: { x: number; y: number } | number[], origin?: { x: number; y: number }): void;
|
|
1342
|
+
|
|
863
1343
|
/**
|
|
864
1344
|
* Applies a force that's scaled to the sprite's mass.
|
|
865
1345
|
*
|
|
866
1346
|
* @param amount
|
|
867
|
-
* @param n The point the force is applied from, relative to the sprite's center of mass. Accepts
|
|
1347
|
+
* @param n The point the force is applied from, relative to the sprite's center of mass. Accepts an object with `x` and `y` properties. If not given, the force is applied at the center of mass.
|
|
1348
|
+
*/
|
|
1349
|
+
/**
|
|
1350
|
+
* Applies a force scaled to the sprite's mass.
|
|
1351
|
+
*
|
|
1352
|
+
* See `applyForce` for argument forms. Arrays are not accepted for input args.
|
|
868
1353
|
*/
|
|
869
|
-
|
|
1354
|
+
/**
|
|
1355
|
+
* Applies a force scaled to the sprite's mass using a magnitude.
|
|
1356
|
+
* @param amount force magnitude
|
|
1357
|
+
* @param origin point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1358
|
+
*/
|
|
1359
|
+
applyForceScaled(amount: number, origin?: { x: number; y: number }): void;
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Applies a force scaled to the sprite's mass using a vector.
|
|
1363
|
+
* @param force force vector as an object with `x` and `y` properties
|
|
1364
|
+
* @param origin point (relative to the sprite) where the force is applied. Accepts an object with `x` and `y` properties.
|
|
1365
|
+
*/
|
|
1366
|
+
applyForceScaled(force: { x: number; y: number }, origin?: { x: number; y: number }): void;
|
|
1367
|
+
|
|
870
1368
|
/**
|
|
871
1369
|
* Applies wind force to the sprite.
|
|
872
1370
|
* @param strength the strength of the wind
|
|
@@ -875,22 +1373,41 @@ declare global {
|
|
|
875
1373
|
* @param lift the force that is perpendicular to the relative velocity
|
|
876
1374
|
*/
|
|
877
1375
|
applyWind(strength: number, angle: number, drag?: number, lift?: number): void;
|
|
1376
|
+
|
|
878
1377
|
/**
|
|
879
1378
|
* Applies a force to the sprite's center of mass attracting it to
|
|
880
1379
|
* the given position.
|
|
881
|
-
* @param x x coordinate
|
|
882
|
-
* @param y
|
|
1380
|
+
* @param x x coordinate
|
|
1381
|
+
* @param y y coordinate
|
|
883
1382
|
* @param force
|
|
884
1383
|
*/
|
|
885
|
-
attractTo(x: number
|
|
1384
|
+
attractTo(x: number, y: number, force?: number): void;
|
|
1385
|
+
|
|
886
1386
|
/**
|
|
887
|
-
* Applies a force to the sprite's center of mass
|
|
1387
|
+
* Applies a force to the sprite's center of mass attracting it to
|
|
888
1388
|
* the given position.
|
|
889
|
-
* @param
|
|
890
|
-
* @param
|
|
1389
|
+
* @param pos object with x and y properties
|
|
1390
|
+
* @param force
|
|
1391
|
+
*/
|
|
1392
|
+
attractTo(pos: { x: number; y: number }, force?: number): void;
|
|
1393
|
+
|
|
1394
|
+
/**
|
|
1395
|
+
* Applies a force to the sprite's center of mass repelling it from
|
|
1396
|
+
* the given position.
|
|
1397
|
+
* @param x x coordinate
|
|
1398
|
+
* @param y y coordinate
|
|
1399
|
+
* @param force
|
|
1400
|
+
*/
|
|
1401
|
+
repelFrom(x: number, y: number, force?: number): void;
|
|
1402
|
+
|
|
1403
|
+
/**
|
|
1404
|
+
* Applies a force to the sprite's center of mass repelling it from
|
|
1405
|
+
* the given position.
|
|
1406
|
+
* @param pos object with x and y properties
|
|
891
1407
|
* @param force
|
|
892
1408
|
*/
|
|
893
|
-
repelFrom(x: number
|
|
1409
|
+
repelFrom(pos: { x: number; y: number }, force?: number): void;
|
|
1410
|
+
|
|
894
1411
|
/**
|
|
895
1412
|
* Apply a torque on the sprite's physics body.
|
|
896
1413
|
* Torque is the force that causes rotation.
|
|
@@ -903,68 +1420,189 @@ declare global {
|
|
|
903
1420
|
* @param torque
|
|
904
1421
|
*/
|
|
905
1422
|
applyTorque(torque: any): void;
|
|
1423
|
+
|
|
1424
|
+
/**
|
|
1425
|
+
* Attempts to move the sprite to a destination at a constant speed
|
|
1426
|
+
* and stops the sprite if it reaches the destination.
|
|
1427
|
+
*
|
|
1428
|
+
* The destination check is deferred until the sprite is estimated to be
|
|
1429
|
+
* at the target position, based on `world.physicsTime`.
|
|
1430
|
+
*
|
|
1431
|
+
* @param x destination x, or `null` to only move on the y-axis
|
|
1432
|
+
* @param y destination y, or `null` to only move on the x-axis
|
|
1433
|
+
* @param speed movement speed in pixels per frame, defaults to the sprite's current speed or 1
|
|
1434
|
+
* @returns a lazy thenable that resolves `true` if the sprite reached the
|
|
1435
|
+
* destination, or `false` if it didn't.
|
|
1436
|
+
*/
|
|
1437
|
+
moveTo(x: number | null, y: number | null, speed?: number): PromiseLike<boolean>;
|
|
1438
|
+
|
|
906
1439
|
/**
|
|
907
|
-
*
|
|
1440
|
+
* Attempts to move the sprite to a destination at a constant speed
|
|
1441
|
+
* and stops the sprite if it reaches the destination.
|
|
1442
|
+
*
|
|
1443
|
+
* @param pos destination object with x and y properties
|
|
1444
|
+
* @param speed movement speed in pixels per frame, defaults to the sprite's current speed or 1
|
|
1445
|
+
* @returns a lazy thenable that resolves `true` if the sprite reached the
|
|
1446
|
+
* destination, or `false` if it didn't.
|
|
1447
|
+
*/
|
|
1448
|
+
moveTo(pos: { x: number | null; y: number | null }, speed?: number): PromiseLike<boolean>;
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Moves the sprite towards a position at a percentage of the distance
|
|
908
1452
|
* between itself and the destination.
|
|
909
1453
|
*
|
|
910
|
-
* @param x destination x or
|
|
911
|
-
* @param y destination y
|
|
1454
|
+
* @param x destination x, or `null` to only move on the y-axis
|
|
1455
|
+
* @param y destination y, or `null` to only move on the x-axis
|
|
912
1456
|
* @param tracking percent of the distance to move towards the destination as a 0-1 value, default is 0.1 (10% tracking)
|
|
913
1457
|
*/
|
|
914
|
-
moveTowards(x: number |
|
|
1458
|
+
moveTowards(x: number | null, y: number | null, tracking?: number): void;
|
|
1459
|
+
|
|
915
1460
|
/**
|
|
916
|
-
* Moves the sprite
|
|
917
|
-
*
|
|
918
|
-
*
|
|
919
|
-
* @param
|
|
920
|
-
* @param
|
|
1461
|
+
* Moves the sprite towards a position at a percentage of the distance
|
|
1462
|
+
* between itself and the destination.
|
|
1463
|
+
*
|
|
1464
|
+
* @param pos destination object with x and y properties
|
|
1465
|
+
* @param tracking percent of the distance to move towards the destination as a 0-1 value, default is 0.1 (10% tracking)
|
|
1466
|
+
*/
|
|
1467
|
+
moveTowards(pos: { x: number | null; y: number | null }, tracking?: number): void;
|
|
1468
|
+
|
|
1469
|
+
/**
|
|
1470
|
+
* Rotates the sprite to a target angle at a constant speed,
|
|
1471
|
+
* stopping if it arrives.
|
|
1472
|
+
*
|
|
1473
|
+
* The destination check is deferred until the sprite is estimated to be
|
|
1474
|
+
* at the target angle, based on `world.physicsTime`.
|
|
1475
|
+
*
|
|
1476
|
+
* @param angle target rotation angle
|
|
1477
|
+
* @param speed rotation speed in degrees (or radians) per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1478
|
+
* @returns a lazy thenable that resolves `true` if the sprite reached the
|
|
1479
|
+
* target angle, or `false` if it didn't.
|
|
921
1480
|
*/
|
|
922
|
-
|
|
1481
|
+
rotateTo(angle: number, speed?: number): PromiseLike<boolean>;
|
|
1482
|
+
|
|
923
1483
|
/**
|
|
924
|
-
* Rotates the sprite
|
|
925
|
-
*
|
|
1484
|
+
* Rotates the sprite to face a position at a constant speed,
|
|
1485
|
+
* stopping if it arrives.
|
|
1486
|
+
*
|
|
1487
|
+
* @param pos object with x and y properties
|
|
1488
|
+
* @param speed rotation speed in degrees (or radians) per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1489
|
+
* @param facing rotation angle the sprite should be at when "facing" the position, default is 0
|
|
1490
|
+
* @returns a lazy thenable that resolves `true` if the sprite reached the
|
|
1491
|
+
* target angle, or `false` if it didn't.
|
|
1492
|
+
*/
|
|
1493
|
+
rotateTo(pos: { x: number; y: number }, speed?: number, facing?: number): PromiseLike<boolean>;
|
|
1494
|
+
|
|
1495
|
+
/**
|
|
1496
|
+
* Rotates the sprite by the smallest angular distance to a target angle
|
|
1497
|
+
* at a constant speed, stopping when it arrives.
|
|
1498
|
+
*
|
|
1499
|
+
* @param angle target rotation angle
|
|
1500
|
+
* @param speed absolute rotation per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1501
|
+
* @returns a lazy thenable that resolves `true` if the sprite reached the
|
|
1502
|
+
* target angle, or `false` if it didn't.
|
|
1503
|
+
*/
|
|
1504
|
+
rotateMinTo(angle: number, speed?: number): PromiseLike<boolean>;
|
|
1505
|
+
|
|
1506
|
+
/**
|
|
1507
|
+
* Rotates the sprite by the smallest angular distance to face a position
|
|
1508
|
+
* at a constant speed, stopping when it arrives.
|
|
1509
|
+
*
|
|
1510
|
+
* @param pos object with x and y properties
|
|
1511
|
+
* @param speed absolute rotation per frame, defaults to the sprite's current rotationSpeed or 1
|
|
1512
|
+
* @param facing rotation angle the sprite should be at when "facing" the position, default is 0
|
|
1513
|
+
* @returns a lazy thenable that resolves `true` if the sprite reached the
|
|
1514
|
+
* target angle, or `false` if it didn't.
|
|
1515
|
+
*/
|
|
1516
|
+
rotateMinTo(pos: { x: number; y: number }, speed?: number, facing?: number): PromiseLike<boolean>;
|
|
1517
|
+
|
|
1518
|
+
/**
|
|
1519
|
+
* Rotates the sprite towards an angle.
|
|
1520
|
+
*
|
|
1521
|
+
* @param angle angle in degrees
|
|
1522
|
+
* @param tracking percent of the distance to rotate on each frame towards the target angle, default is 0.1 (10%)
|
|
1523
|
+
*/
|
|
1524
|
+
rotateTowards(angle: number, tracking?: number): void;
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Rotates the sprite towards a position.
|
|
1528
|
+
*
|
|
1529
|
+
* @param pos object with x and y properties
|
|
1530
|
+
* @param tracking percent of the distance to rotate on each frame towards the target position, default is 0.1 (10%)
|
|
1531
|
+
* @param facing rotation angle the sprite should be at when "facing" the position, default is 0
|
|
1532
|
+
*/
|
|
1533
|
+
rotateTowards(pos: { x: number; y: number }, tracking?: number, facing?: number): void;
|
|
1534
|
+
|
|
1535
|
+
/**
|
|
1536
|
+
* Finds the angle from this sprite to the given position.
|
|
926
1537
|
*
|
|
927
|
-
*
|
|
928
|
-
*
|
|
929
|
-
*
|
|
1538
|
+
* Equivalent to `atan2(y - sprite.y, x - sprite.x) + facing`.
|
|
1539
|
+
* Returns the sprite's current rotation if the position is within 0.01 pixels.
|
|
1540
|
+
*
|
|
1541
|
+
* Can be used to set the direction of a sprite so it moves toward a position.
|
|
1542
|
+
*
|
|
1543
|
+
* @param x x coordinate
|
|
1544
|
+
* @param y y coordinate
|
|
1545
|
+
* @param facing offset angle added to the result, default is 0
|
|
1546
|
+
* @returns angle to the position
|
|
930
1547
|
*/
|
|
931
|
-
|
|
1548
|
+
angleTo(x: number, y: number, facing?: number): number;
|
|
932
1549
|
/**
|
|
933
1550
|
* Finds the angle from this sprite to the given position.
|
|
934
1551
|
*
|
|
935
|
-
*
|
|
936
|
-
*
|
|
1552
|
+
* @param pos object with x and y properties
|
|
1553
|
+
* @param facing offset angle added to the result, default is 0
|
|
1554
|
+
* @returns angle to the position
|
|
1555
|
+
*/
|
|
1556
|
+
angleTo(pos: { x: number; y: number }, facing?: number): number;
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
* Finds the minimum angular distance the sprite would need to rotate
|
|
1560
|
+
* to face a position, taking into account the sprite's current rotation.
|
|
937
1561
|
*
|
|
938
|
-
*
|
|
1562
|
+
* Useful for `rotateTowards`-style logic where you need the signed delta
|
|
1563
|
+
* rather than an absolute target angle.
|
|
939
1564
|
*
|
|
940
|
-
* @param x x coordinate
|
|
941
|
-
* @param y
|
|
942
|
-
* @
|
|
1565
|
+
* @param x x coordinate
|
|
1566
|
+
* @param y y coordinate
|
|
1567
|
+
* @param facing offset angle, default is 0
|
|
1568
|
+
* @returns the minimum angular distance to face the position
|
|
943
1569
|
*/
|
|
944
|
-
|
|
1570
|
+
angleDistTo(x: number, y: number, facing?: number): number;
|
|
1571
|
+
|
|
945
1572
|
/**
|
|
946
|
-
* Finds the
|
|
947
|
-
* a position.
|
|
1573
|
+
* Finds the minimum angular distance the sprite would need to rotate
|
|
1574
|
+
* to face a position, taking into account the sprite's current rotation.
|
|
948
1575
|
*
|
|
949
|
-
* @param
|
|
950
|
-
* @param
|
|
951
|
-
* @
|
|
952
|
-
* @returns the rotation angle the sprite should be at when "facing" the position
|
|
1576
|
+
* @param pos object with x and y properties
|
|
1577
|
+
* @param facing offset angle, default is 0
|
|
1578
|
+
* @returns the minimum angular distance to face the position
|
|
953
1579
|
*/
|
|
954
|
-
|
|
1580
|
+
angleDistTo(pos: { x: number; y: number }, facing?: number): number;
|
|
1581
|
+
|
|
955
1582
|
/**
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
* taking into account the current rotation of the sprite.
|
|
1583
|
+
* Moves and rotates a sprite's physics body towards a target transform
|
|
1584
|
+
* at a percentage of the distance on each frame.
|
|
959
1585
|
*
|
|
960
|
-
*
|
|
1586
|
+
* Uses Box2D's `b2Body_SetTargetTransform` for maximum efficiency
|
|
1587
|
+
* compared to using `moveTowards` and `rotateTowards` separately.
|
|
961
1588
|
*
|
|
962
|
-
* @param x
|
|
963
|
-
* @param y
|
|
964
|
-
* @param
|
|
965
|
-
* @
|
|
1589
|
+
* @param x destination x
|
|
1590
|
+
* @param y destination y
|
|
1591
|
+
* @param rotation target rotation angle
|
|
1592
|
+
* @param tracking percent of the distance to move towards the target as a 0-1 value, default is 0.1 (10% tracking)
|
|
1593
|
+
*/
|
|
1594
|
+
transformTowards(x: number, y: number, rotation?: number, tracking?: number): void;
|
|
1595
|
+
|
|
1596
|
+
/**
|
|
1597
|
+
* Moves and rotates a sprite's physics body towards a target transform
|
|
1598
|
+
* at a percentage of the distance on each frame.
|
|
1599
|
+
*
|
|
1600
|
+
* @param pos destination object with x and y properties
|
|
1601
|
+
* @param rotation target rotation angle
|
|
1602
|
+
* @param tracking percent of the distance to move towards the target as a 0-1 value, default is 0.1 (10% tracking)
|
|
966
1603
|
*/
|
|
967
|
-
|
|
1604
|
+
transformTowards(pos: { x: number; y: number }, rotation?: number, tracking?: number): void;
|
|
1605
|
+
|
|
968
1606
|
/**
|
|
969
1607
|
* Deletes the Sprite from the sketch and all the groups it
|
|
970
1608
|
* belongs to.
|
|
@@ -976,11 +1614,13 @@ declare global {
|
|
|
976
1614
|
* sprite use `sprite.visible = false` instead.
|
|
977
1615
|
*/
|
|
978
1616
|
delete(): void;
|
|
1617
|
+
|
|
979
1618
|
/**
|
|
980
1619
|
* Returns the sprite's unique identifier `sprite.idNum`.
|
|
981
1620
|
* @returns the sprite's id
|
|
982
1621
|
*/
|
|
983
1622
|
toString(): string;
|
|
1623
|
+
|
|
984
1624
|
/**
|
|
985
1625
|
* Returns true on the first frame that the sprite collides with the
|
|
986
1626
|
* target sprite or group.
|
|
@@ -992,6 +1632,7 @@ declare global {
|
|
|
992
1632
|
* @param callback
|
|
993
1633
|
*/
|
|
994
1634
|
collides(target: Sprite | Group, callback?: Function): boolean;
|
|
1635
|
+
|
|
995
1636
|
/**
|
|
996
1637
|
* Returns a truthy value while the sprite is colliding with the
|
|
997
1638
|
* target sprite or group. The value is the number of frames that
|
|
@@ -1002,6 +1643,7 @@ declare global {
|
|
|
1002
1643
|
* @return {Number} frames
|
|
1003
1644
|
*/
|
|
1004
1645
|
colliding(target: Sprite | Group, callback?: Function): number;
|
|
1646
|
+
|
|
1005
1647
|
/**
|
|
1006
1648
|
* Returns true on the first frame that the sprite no longer overlaps
|
|
1007
1649
|
* with the target sprite or group.
|
|
@@ -1011,6 +1653,7 @@ declare global {
|
|
|
1011
1653
|
* @return {Boolean}
|
|
1012
1654
|
*/
|
|
1013
1655
|
collided(target: Sprite | Group, callback?: Function): boolean;
|
|
1656
|
+
|
|
1014
1657
|
/**
|
|
1015
1658
|
* Returns true on the first frame that the sprite overlaps with the
|
|
1016
1659
|
* target sprite or group.
|
|
@@ -1022,6 +1665,7 @@ declare global {
|
|
|
1022
1665
|
* @param callback
|
|
1023
1666
|
*/
|
|
1024
1667
|
overlaps(target: Sprite | Group, callback?: Function): boolean;
|
|
1668
|
+
|
|
1025
1669
|
/**
|
|
1026
1670
|
* Returns a truthy value while the sprite is overlapping with the
|
|
1027
1671
|
* target sprite or group. The value returned is the number of
|
|
@@ -1032,6 +1676,7 @@ declare global {
|
|
|
1032
1676
|
* @return {Number} frames
|
|
1033
1677
|
*/
|
|
1034
1678
|
overlapping(target: Sprite | Group, callback?: Function): number;
|
|
1679
|
+
|
|
1035
1680
|
/**
|
|
1036
1681
|
* Returns true on the first frame that the sprite no longer overlaps
|
|
1037
1682
|
* with the target sprite or group.
|
|
@@ -1041,18 +1686,21 @@ declare global {
|
|
|
1041
1686
|
* @return {Boolean}
|
|
1042
1687
|
*/
|
|
1043
1688
|
overlapped(target: Sprite | Group, callback?: Function): boolean;
|
|
1689
|
+
|
|
1044
1690
|
/**
|
|
1045
1691
|
* Sets a pass through contact relationship between the sprite
|
|
1046
1692
|
* and a target sprite or group.
|
|
1047
1693
|
* @param target
|
|
1048
1694
|
*/
|
|
1049
1695
|
pass(target: Sprite | Group): void;
|
|
1696
|
+
|
|
1050
1697
|
/**
|
|
1051
1698
|
* Sets a pass through contact relationship between the sprite
|
|
1052
1699
|
* and a target sprite or group.
|
|
1053
1700
|
* @param target
|
|
1054
1701
|
*/
|
|
1055
1702
|
passes(target: Sprite | Group): void;
|
|
1703
|
+
|
|
1056
1704
|
/**
|
|
1057
1705
|
* Creates overlap sensors that are the same size as the sprite's
|
|
1058
1706
|
* colliders. If you'd like to add more sensors to a sprite, use the
|
|
@@ -1062,14 +1710,23 @@ declare global {
|
|
|
1062
1710
|
* function is called but the sprite has no overlap sensors.
|
|
1063
1711
|
*/
|
|
1064
1712
|
addDefaultSensors(): void;
|
|
1713
|
+
|
|
1065
1714
|
/**
|
|
1066
|
-
* Returns the distance to another sprite, the mouse, a touch,
|
|
1067
|
-
* or any other object with x and y properties. Uses
|
|
1068
|
-
*
|
|
1069
|
-
* @param
|
|
1715
|
+
* Returns the distance to another sprite, the mouse, a touch pointer,
|
|
1716
|
+
* or any other object with x and y properties. Uses q5's `dist` function.
|
|
1717
|
+
* @param x
|
|
1718
|
+
* @param y
|
|
1719
|
+
* @returns distance
|
|
1720
|
+
*/
|
|
1721
|
+
distanceTo(x: number, y: number): number;
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* Returns the distance to another sprite, the mouse, a touch pointer,
|
|
1725
|
+
* or any other object with x and y properties. Uses q5's `dist` function.
|
|
1726
|
+
* @param pos object with x and y properties
|
|
1070
1727
|
* @returns distance
|
|
1071
1728
|
*/
|
|
1072
|
-
distanceTo(
|
|
1729
|
+
distanceTo(pos: { x: number; y: number }): number;
|
|
1073
1730
|
}
|
|
1074
1731
|
|
|
1075
1732
|
class Ani extends Array<Q5.Image> {
|
|
@@ -1080,11 +1737,13 @@ declare global {
|
|
|
1080
1737
|
* @param args the frames of the animation
|
|
1081
1738
|
*/
|
|
1082
1739
|
constructor(...args: Q5.Image[]);
|
|
1740
|
+
|
|
1083
1741
|
/**
|
|
1084
1742
|
* The name of the animation
|
|
1085
1743
|
*/
|
|
1086
1744
|
name: string;
|
|
1087
1745
|
targetFrame: number;
|
|
1746
|
+
|
|
1088
1747
|
/**
|
|
1089
1748
|
* The distance from the sprite or visual's position
|
|
1090
1749
|
* that the animation is drawn at.
|
|
@@ -1092,21 +1751,25 @@ declare global {
|
|
|
1092
1751
|
* @prop {Number} y vertical offset
|
|
1093
1752
|
*/
|
|
1094
1753
|
offset: { x: number; y: number };
|
|
1754
|
+
|
|
1095
1755
|
/**
|
|
1096
1756
|
* True if the animation is currently playing.
|
|
1097
1757
|
* @default true
|
|
1098
1758
|
*/
|
|
1099
1759
|
playing: boolean;
|
|
1760
|
+
|
|
1100
1761
|
/**
|
|
1101
1762
|
* Animation visibility.
|
|
1102
1763
|
* @default true
|
|
1103
1764
|
*/
|
|
1104
1765
|
visible: boolean;
|
|
1766
|
+
|
|
1105
1767
|
/**
|
|
1106
1768
|
* If set to false the animation will stop after reaching the last frame
|
|
1107
1769
|
* @default true
|
|
1108
1770
|
*/
|
|
1109
1771
|
looping: boolean;
|
|
1772
|
+
|
|
1110
1773
|
/**
|
|
1111
1774
|
* Ends the loop on frame 0 instead of the last frame.
|
|
1112
1775
|
* This is useful for animations that are symmetric.
|
|
@@ -1115,6 +1778,7 @@ declare global {
|
|
|
1115
1778
|
* @default false
|
|
1116
1779
|
*/
|
|
1117
1780
|
endOnFirstFrame: boolean;
|
|
1781
|
+
|
|
1118
1782
|
/**
|
|
1119
1783
|
* True if frame changed during the last draw cycle
|
|
1120
1784
|
*/
|
|
@@ -1123,11 +1787,13 @@ declare global {
|
|
|
1123
1787
|
onChange: any;
|
|
1124
1788
|
rotation: any;
|
|
1125
1789
|
spriteSheet: any;
|
|
1790
|
+
|
|
1126
1791
|
/**
|
|
1127
1792
|
* The index of the current frame that the animation is on.
|
|
1128
1793
|
*/
|
|
1129
1794
|
get frame(): number;
|
|
1130
1795
|
set frame(val: number);
|
|
1796
|
+
|
|
1131
1797
|
/**
|
|
1132
1798
|
* Delay between frames in number of draw cycles.
|
|
1133
1799
|
* If set to 4 the framerate of the animation would be the
|
|
@@ -1136,6 +1802,7 @@ declare global {
|
|
|
1136
1802
|
*/
|
|
1137
1803
|
get frameDelay(): number;
|
|
1138
1804
|
set frameDelay(val: number);
|
|
1805
|
+
|
|
1139
1806
|
/**
|
|
1140
1807
|
* The animation's scale.
|
|
1141
1808
|
*
|
|
@@ -1145,30 +1812,36 @@ declare global {
|
|
|
1145
1812
|
*/
|
|
1146
1813
|
get scale(): number | { x: number; y: number };
|
|
1147
1814
|
set scale(val: number | { x: number; y: number });
|
|
1815
|
+
|
|
1148
1816
|
/**
|
|
1149
1817
|
* Make a copy of the animation, with its own playback state,
|
|
1150
1818
|
* independent of the original animation.
|
|
1151
1819
|
* @return {Ani}
|
|
1152
1820
|
*/
|
|
1153
1821
|
clone(): Ani;
|
|
1822
|
+
|
|
1154
1823
|
/**
|
|
1155
1824
|
* Updates the animation's playback state. This is called automatically
|
|
1156
1825
|
*/
|
|
1157
1826
|
update(): void;
|
|
1827
|
+
|
|
1158
1828
|
/**
|
|
1159
1829
|
* Plays the animation, starting from the specified frame.
|
|
1160
1830
|
*
|
|
1161
1831
|
* @returns [Promise] a promise that resolves when the animation completes
|
|
1162
1832
|
*/
|
|
1163
1833
|
play(frame: any): Promise<any>;
|
|
1834
|
+
|
|
1164
1835
|
/**
|
|
1165
1836
|
* Pauses the animation.
|
|
1166
1837
|
*/
|
|
1167
1838
|
pause(frame: any): void;
|
|
1839
|
+
|
|
1168
1840
|
/**
|
|
1169
1841
|
* Stops the animation. Alt for pause.
|
|
1170
1842
|
*/
|
|
1171
1843
|
stop(frame: any): void;
|
|
1844
|
+
|
|
1172
1845
|
/**
|
|
1173
1846
|
* Plays the animation backwards.
|
|
1174
1847
|
* Equivalent to ani.goToFrame(0)
|
|
@@ -1177,22 +1850,27 @@ declare global {
|
|
|
1177
1850
|
* rewinding
|
|
1178
1851
|
*/
|
|
1179
1852
|
rewind(): Promise<any>;
|
|
1853
|
+
|
|
1180
1854
|
/**
|
|
1181
1855
|
* Plays the animation forwards and loops it.
|
|
1182
1856
|
*/
|
|
1183
1857
|
loop(): void;
|
|
1858
|
+
|
|
1184
1859
|
/**
|
|
1185
1860
|
* Prevents the animation from looping
|
|
1186
1861
|
*/
|
|
1187
1862
|
noLoop(): void;
|
|
1863
|
+
|
|
1188
1864
|
/**
|
|
1189
1865
|
* Goes to the next frame and stops.
|
|
1190
1866
|
*/
|
|
1191
1867
|
nextFrame(): void;
|
|
1868
|
+
|
|
1192
1869
|
/**
|
|
1193
1870
|
* Goes to the previous frame and stops.
|
|
1194
1871
|
*/
|
|
1195
1872
|
previousFrame(): void;
|
|
1873
|
+
|
|
1196
1874
|
/**
|
|
1197
1875
|
* Plays the animation forward or backward toward a target frame.
|
|
1198
1876
|
*
|
|
@@ -1200,33 +1878,40 @@ declare global {
|
|
|
1200
1878
|
* @returns [Promise] a promise that resolves when the animation completes
|
|
1201
1879
|
*/
|
|
1202
1880
|
goToFrame(toFrame: number): Promise<any>;
|
|
1881
|
+
|
|
1203
1882
|
/**
|
|
1204
1883
|
* The index of the last frame. Read only.
|
|
1205
1884
|
*/
|
|
1206
1885
|
get lastFrame(): number;
|
|
1886
|
+
|
|
1207
1887
|
/**
|
|
1208
1888
|
* The current frame as Q5.Image. Read only.
|
|
1209
1889
|
*/
|
|
1210
1890
|
get frameImage(): Q5.Image;
|
|
1891
|
+
|
|
1211
1892
|
/**
|
|
1212
1893
|
* Width of the animation's current frame.
|
|
1213
1894
|
*/
|
|
1214
1895
|
get w(): number;
|
|
1896
|
+
|
|
1215
1897
|
/**
|
|
1216
1898
|
* Width of the animation's current frame.
|
|
1217
1899
|
*/
|
|
1218
1900
|
get width(): number;
|
|
1219
1901
|
get defaultWidth(): any;
|
|
1902
|
+
|
|
1220
1903
|
/**
|
|
1221
1904
|
* Height of the animation's current frame.
|
|
1222
1905
|
*/
|
|
1223
1906
|
get h(): number;
|
|
1907
|
+
|
|
1224
1908
|
/**
|
|
1225
1909
|
* Height of the animation's current frame.
|
|
1226
1910
|
*/
|
|
1227
1911
|
get height(): number;
|
|
1228
1912
|
get defaultHeight(): any;
|
|
1229
1913
|
}
|
|
1914
|
+
|
|
1230
1915
|
/**
|
|
1231
1916
|
* Stores animations.
|
|
1232
1917
|
*
|
|
@@ -1241,6 +1926,7 @@ declare global {
|
|
|
1241
1926
|
scale: number | { x: number; y: number };
|
|
1242
1927
|
looping: boolean;
|
|
1243
1928
|
playing: boolean;
|
|
1929
|
+
|
|
1244
1930
|
/**
|
|
1245
1931
|
* Cuts sprite sheet frames into separate images, instead of rendering
|
|
1246
1932
|
* sections of the sprite sheet.
|
|
@@ -1249,15 +1935,18 @@ declare global {
|
|
|
1249
1935
|
* but uses more memory and may cause longer load times.
|
|
1250
1936
|
*/
|
|
1251
1937
|
cutFrames: boolean;
|
|
1938
|
+
|
|
1252
1939
|
endOnFirstFrame: boolean;
|
|
1253
1940
|
w: number;
|
|
1254
1941
|
width: number;
|
|
1255
1942
|
h: number;
|
|
1256
1943
|
height: number;
|
|
1944
|
+
|
|
1257
1945
|
/**
|
|
1258
1946
|
* Frame size of the animations in the collection, in the format "WIDTHxHEIGHT", for example "32x32".
|
|
1259
1947
|
*/
|
|
1260
1948
|
frameSize: string;
|
|
1949
|
+
|
|
1261
1950
|
/**
|
|
1262
1951
|
* The sprite sheet image used by the animations in the collection.
|
|
1263
1952
|
*/
|
|
@@ -1265,27 +1954,32 @@ declare global {
|
|
|
1265
1954
|
}
|
|
1266
1955
|
|
|
1267
1956
|
/**
|
|
1268
|
-
*
|
|
1269
|
-
*
|
|
1270
|
-
|
|
1271
|
-
|
|
1957
|
+
* A collection of and blueprint for Visual objects
|
|
1958
|
+
* that store an image or animation(s)
|
|
1959
|
+
* which can be displayed with respect to the camera.
|
|
1960
|
+
*/
|
|
1961
|
+
class Visuals<T extends Visual = Visual> extends Array<T> {
|
|
1272
1962
|
/**
|
|
1273
1963
|
* Draws the visuals on the canvas.
|
|
1274
1964
|
*/
|
|
1275
1965
|
draw(): void;
|
|
1966
|
+
|
|
1276
1967
|
/**
|
|
1277
1968
|
* Current image.
|
|
1278
1969
|
*/
|
|
1279
1970
|
img: Q5.Image;
|
|
1971
|
+
|
|
1280
1972
|
/**
|
|
1281
1973
|
* Current animation.
|
|
1282
1974
|
*/
|
|
1283
1975
|
ani: Ani;
|
|
1976
|
+
|
|
1284
1977
|
/**
|
|
1285
1978
|
* Stores animations.
|
|
1286
1979
|
* Keys are the animation label, values are Ani objects
|
|
1287
1980
|
*/
|
|
1288
1981
|
get anis(): Anis;
|
|
1982
|
+
|
|
1289
1983
|
/**
|
|
1290
1984
|
* Adds an animation to the Group or Visuals array.
|
|
1291
1985
|
*
|
|
@@ -1294,6 +1988,26 @@ declare global {
|
|
|
1294
1988
|
* @returns A promise that fulfills when the animation is loaded
|
|
1295
1989
|
*/
|
|
1296
1990
|
addAni(spriteSheetURL: string, frameCount: number): Promise<void>;
|
|
1991
|
+
|
|
1992
|
+
/**
|
|
1993
|
+
* Add multiple animations to the Group or Visuals array.
|
|
1994
|
+
*
|
|
1995
|
+
* @param atlases an object with animation names as keys and
|
|
1996
|
+
* an animation or animation atlas as values
|
|
1997
|
+
* @returns A promise that fulfills when the animations are loaded
|
|
1998
|
+
*/
|
|
1999
|
+
addAnis(atlases: {}): Promise<void>;
|
|
2000
|
+
|
|
2001
|
+
/**
|
|
2002
|
+
* Add multiple animations to the Group or Visuals array.
|
|
2003
|
+
*
|
|
2004
|
+
* @param spriteSheetURL the URL of the sprite sheet image
|
|
2005
|
+
* @param atlases an object with animation names as keys and
|
|
2006
|
+
* an animation or animation atlas as values
|
|
2007
|
+
* @returns A promise that fulfills when the animations are loaded
|
|
2008
|
+
*/
|
|
2009
|
+
addAnis(spriteSheetURL: string, atlases: {}): Promise<void>;
|
|
2010
|
+
|
|
1297
2011
|
/**
|
|
1298
2012
|
* Add multiple animations to the Group or Visuals array.
|
|
1299
2013
|
*
|
|
@@ -1304,6 +2018,7 @@ declare global {
|
|
|
1304
2018
|
* @returns A promise that fulfills when the animations are loaded
|
|
1305
2019
|
*/
|
|
1306
2020
|
addAnis(spriteSheetURL: string, frameSize: string, atlases: {}): Promise<void>;
|
|
2021
|
+
|
|
1307
2022
|
/**
|
|
1308
2023
|
* Detects when visuals go outside the given culling boundary,
|
|
1309
2024
|
* relative to the camera.
|
|
@@ -1316,10 +2031,12 @@ declare global {
|
|
|
1316
2031
|
* @return {Number} the number of visuals culled
|
|
1317
2032
|
*/
|
|
1318
2033
|
cull(top?: number, bottom?: number, left?: number, right?: number, cb?: Function): number;
|
|
2034
|
+
|
|
1319
2035
|
/**
|
|
1320
2036
|
* The tile character that represents the Visuals or Group in a tile map.
|
|
1321
2037
|
*/
|
|
1322
2038
|
tile: string;
|
|
2039
|
+
|
|
1323
2040
|
/**
|
|
1324
2041
|
* Adds sprites to the group based on a tile map.
|
|
1325
2042
|
*
|
|
@@ -1332,19 +2049,28 @@ declare global {
|
|
|
1332
2049
|
addTiles(tiles: string | string[], x?: number, y?: number, colWidth?: number, rowHeight?: number): void;
|
|
1333
2050
|
}
|
|
1334
2051
|
|
|
1335
|
-
|
|
2052
|
+
/**
|
|
2053
|
+
* A Group is a collection of and blueprint for
|
|
2054
|
+
* sprites with similar traits and behaviors.
|
|
2055
|
+
*/
|
|
2056
|
+
class Group extends Visuals<Sprite> {
|
|
1336
2057
|
/**
|
|
1337
|
-
*
|
|
2058
|
+
* A Group is a collection of and blueprint for
|
|
2059
|
+
* sprites with similar traits and behaviors.
|
|
1338
2060
|
*
|
|
1339
|
-
* Group extends
|
|
1340
|
-
*
|
|
2061
|
+
* Group extends Visuals which extends Array,
|
|
2062
|
+
* so you can use them in for loops. They've got
|
|
2063
|
+
* all the functions and properties of standard arrays
|
|
1341
2064
|
* such as `group.length` and functions like `group.includes()`.
|
|
1342
2065
|
*
|
|
1343
2066
|
* Changing a group setting changes it for all the sprites in the
|
|
1344
|
-
* group
|
|
1345
|
-
*
|
|
2067
|
+
* group ("dynamic inheritance").
|
|
2068
|
+
*
|
|
2069
|
+
* All groups inherit from the base group `allSprites`.
|
|
2070
|
+
*
|
|
2071
|
+
* Groups can have subgroups, creating a hierarchy of inheritance.
|
|
1346
2072
|
*
|
|
1347
|
-
* @param sprites the sprites to add to the group
|
|
2073
|
+
* @param [sprites] the sprites to add to the group
|
|
1348
2074
|
*/
|
|
1349
2075
|
constructor(...sprites: Sprite[]);
|
|
1350
2076
|
|
|
@@ -1352,18 +2078,22 @@ declare global {
|
|
|
1352
2078
|
* Horizontal position of group sprites.
|
|
1353
2079
|
*/
|
|
1354
2080
|
x: number;
|
|
2081
|
+
|
|
1355
2082
|
/**
|
|
1356
2083
|
* Vertical position of group sprites.
|
|
1357
2084
|
*/
|
|
1358
2085
|
y: number;
|
|
2086
|
+
|
|
1359
2087
|
/**
|
|
1360
2088
|
* Velocity of group sprites.
|
|
1361
2089
|
*/
|
|
1362
2090
|
vel: number;
|
|
2091
|
+
|
|
1363
2092
|
/**
|
|
1364
2093
|
* Velocity of group sprites.
|
|
1365
2094
|
*/
|
|
1366
2095
|
velocity: number;
|
|
2096
|
+
|
|
1367
2097
|
/**
|
|
1368
2098
|
* The angle of the group sprites' rotation, not the direction it's moving.
|
|
1369
2099
|
*
|
|
@@ -1371,6 +2101,7 @@ declare global {
|
|
|
1371
2101
|
* a range of -180 to 180.
|
|
1372
2102
|
*/
|
|
1373
2103
|
rotation: number;
|
|
2104
|
+
|
|
1374
2105
|
/**
|
|
1375
2106
|
* The speed of the group sprites' rotation in angles per frame.
|
|
1376
2107
|
*/
|
|
@@ -1380,6 +2111,7 @@ declare global {
|
|
|
1380
2111
|
* If true, group sprites are drawn by q5play after each physics update.
|
|
1381
2112
|
*/
|
|
1382
2113
|
autoDraw: boolean;
|
|
2114
|
+
|
|
1383
2115
|
/**
|
|
1384
2116
|
* Controls the ability for group sprites to "sleep".
|
|
1385
2117
|
*
|
|
@@ -1388,10 +2120,12 @@ declare global {
|
|
|
1388
2120
|
* with anything that it wasn't already colliding with.
|
|
1389
2121
|
*/
|
|
1390
2122
|
allowSleeping: boolean;
|
|
2123
|
+
|
|
1391
2124
|
/**
|
|
1392
2125
|
* If true, group sprites are updated by q5play before each physics update.
|
|
1393
2126
|
*/
|
|
1394
2127
|
autoUpdate: number;
|
|
2128
|
+
|
|
1395
2129
|
/**
|
|
1396
2130
|
* A bearing indicates the direction that needs to be followed to
|
|
1397
2131
|
* reach a destination.
|
|
@@ -1401,38 +2135,46 @@ declare global {
|
|
|
1401
2135
|
* using the `applyForce` function.
|
|
1402
2136
|
*/
|
|
1403
2137
|
bearing: number;
|
|
2138
|
+
|
|
1404
2139
|
/**
|
|
1405
2140
|
* The bounciness of the group sprites' physics body.
|
|
1406
2141
|
*/
|
|
1407
2142
|
bounciness: number;
|
|
2143
|
+
|
|
1408
2144
|
/**
|
|
1409
2145
|
* The group sprites' current fill color.
|
|
1410
2146
|
*
|
|
1411
2147
|
* By default sprites get a random color.
|
|
1412
2148
|
*/
|
|
1413
2149
|
color: Q5.Color;
|
|
2150
|
+
|
|
1414
2151
|
/**
|
|
1415
2152
|
* The diameter of a circular sprite.
|
|
1416
2153
|
*/
|
|
1417
2154
|
d: number;
|
|
2155
|
+
|
|
1418
2156
|
/**
|
|
1419
2157
|
* The diameter of a circular sprite.
|
|
1420
2158
|
*/
|
|
1421
2159
|
diameter: number;
|
|
2160
|
+
|
|
1422
2161
|
/**
|
|
1423
2162
|
* If true, outlines of the group sprites' colliders and sensors will be drawn.
|
|
1424
2163
|
*
|
|
1425
2164
|
* Use the keyboard shortcut Command+B to toggle `allSprites.debug`.
|
|
1426
2165
|
*/
|
|
1427
2166
|
debug: boolean;
|
|
2167
|
+
|
|
1428
2168
|
/**
|
|
1429
2169
|
* The density of the group sprites' physics body.
|
|
1430
2170
|
*/
|
|
1431
2171
|
density: number;
|
|
2172
|
+
|
|
1432
2173
|
/**
|
|
1433
2174
|
* The angle of the group sprites' movement.
|
|
1434
2175
|
*/
|
|
1435
2176
|
direction: number;
|
|
2177
|
+
|
|
1436
2178
|
/**
|
|
1437
2179
|
* The amount of resistance group sprites has to being moved.
|
|
1438
2180
|
*/
|
|
@@ -1443,14 +2185,17 @@ declare global {
|
|
|
1443
2185
|
* when rubbing against other colliders.
|
|
1444
2186
|
*/
|
|
1445
2187
|
friction: number;
|
|
2188
|
+
|
|
1446
2189
|
/**
|
|
1447
2190
|
* Whether the group sprites can be grabbed by a pointer.
|
|
1448
2191
|
*/
|
|
1449
2192
|
grabbable: boolean;
|
|
2193
|
+
|
|
1450
2194
|
/**
|
|
1451
2195
|
* A ratio that defines how much the group sprites are affected by gravity.
|
|
1452
2196
|
*/
|
|
1453
2197
|
gravityScale: number;
|
|
2198
|
+
|
|
1454
2199
|
/**
|
|
1455
2200
|
* The group sprites' heading. This is a string that can be set to
|
|
1456
2201
|
* "up", "down", "left", "right", "upRight", "upLeft", "downRight"
|
|
@@ -1459,25 +2204,30 @@ declare global {
|
|
|
1459
2204
|
* underscores, dashes, and cardinal direction word order.
|
|
1460
2205
|
*/
|
|
1461
2206
|
heading: string;
|
|
2207
|
+
|
|
1462
2208
|
/**
|
|
1463
2209
|
* The height of the group sprites.
|
|
1464
2210
|
*/
|
|
1465
2211
|
h: number;
|
|
2212
|
+
|
|
1466
2213
|
/**
|
|
1467
2214
|
* The height of the group sprites.
|
|
1468
2215
|
*/
|
|
1469
2216
|
height: number;
|
|
2217
|
+
|
|
1470
2218
|
/**
|
|
1471
2219
|
* Set this to true if the group sprites goes really fast to prevent
|
|
1472
2220
|
* inaccurate physics simulation.
|
|
1473
2221
|
*/
|
|
1474
2222
|
isSuperFast: boolean;
|
|
2223
|
+
|
|
1475
2224
|
/**
|
|
1476
2225
|
* Sprites with the highest layer value get drawn first.
|
|
1477
2226
|
*
|
|
1478
2227
|
* By default sprites are drawn in the order they were created in.
|
|
1479
2228
|
*/
|
|
1480
2229
|
layer: number;
|
|
2230
|
+
|
|
1481
2231
|
/**
|
|
1482
2232
|
* When the physics simulation is progressed in `world.physicsUpdate`,
|
|
1483
2233
|
* each sprite's life is decreased by `world.timeScale`.
|
|
@@ -1486,10 +2236,12 @@ declare global {
|
|
|
1486
2236
|
* be removed.
|
|
1487
2237
|
*/
|
|
1488
2238
|
life: number;
|
|
2239
|
+
|
|
1489
2240
|
/**
|
|
1490
2241
|
* The mass of the group sprites' physics body.
|
|
1491
2242
|
*/
|
|
1492
2243
|
mass: number;
|
|
2244
|
+
|
|
1493
2245
|
/**
|
|
1494
2246
|
* The physics type of the group sprites, which determines how it interacts with
|
|
1495
2247
|
* other sprites in the physics simulation.
|
|
@@ -1497,6 +2249,7 @@ declare global {
|
|
|
1497
2249
|
* It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
|
|
1498
2250
|
*/
|
|
1499
2251
|
physics: string;
|
|
2252
|
+
|
|
1500
2253
|
/**
|
|
1501
2254
|
* The physics type of the group sprites, which determines how it interacts with
|
|
1502
2255
|
* other sprites in the physics simulation.
|
|
@@ -1504,10 +2257,12 @@ declare global {
|
|
|
1504
2257
|
* It can be set to DYNAMIC/DYN, STATIC/STA, or KINEMATIC/KIN.
|
|
1505
2258
|
*/
|
|
1506
2259
|
physicsType: string;
|
|
2260
|
+
|
|
1507
2261
|
/**
|
|
1508
2262
|
* If true, the group sprites' physics body is included in the physics simulation.
|
|
1509
2263
|
*/
|
|
1510
2264
|
physicsEnabled: boolean;
|
|
2265
|
+
|
|
1511
2266
|
/**
|
|
1512
2267
|
* If true, q5play will draw sprites at integer pixel precision.
|
|
1513
2268
|
*
|
|
@@ -1516,19 +2271,23 @@ declare global {
|
|
|
1516
2271
|
* By default q5play draws sprites with subpixel rendering.
|
|
1517
2272
|
*/
|
|
1518
2273
|
pixelPerfect: boolean;
|
|
2274
|
+
|
|
1519
2275
|
/**
|
|
1520
2276
|
* Simulates friction that slows down group sprites rolling on another sprite,
|
|
1521
2277
|
* like a soccer ball rolling to a stop on high grass.
|
|
1522
2278
|
*/
|
|
1523
2279
|
rollingResistance: number;
|
|
2280
|
+
|
|
1524
2281
|
/**
|
|
1525
2282
|
* The amount the group sprites resists rotating.
|
|
1526
2283
|
*/
|
|
1527
2284
|
rotationDrag: number;
|
|
2285
|
+
|
|
1528
2286
|
/**
|
|
1529
2287
|
* If true, the group sprites can not rotate.
|
|
1530
2288
|
*/
|
|
1531
2289
|
rotationLock: boolean;
|
|
2290
|
+
|
|
1532
2291
|
/**
|
|
1533
2292
|
* Horizontal and vertical scale of the group sprites.
|
|
1534
2293
|
*
|
|
@@ -1538,7 +2297,7 @@ declare global {
|
|
|
1538
2297
|
* number. This enables users to do things like `sprite.scale *= 2`
|
|
1539
2298
|
* to double the group sprites' scale.
|
|
1540
2299
|
*/
|
|
1541
|
-
scale: number |
|
|
2300
|
+
scale: number | [] | { x: number; y: number };
|
|
1542
2301
|
|
|
1543
2302
|
/**
|
|
1544
2303
|
* Wake group sprites up or put it to sleep.
|
|
@@ -1548,14 +2307,17 @@ declare global {
|
|
|
1548
2307
|
* with anything that it wasn't already colliding with.
|
|
1549
2308
|
*/
|
|
1550
2309
|
sleeping: boolean;
|
|
2310
|
+
|
|
1551
2311
|
/**
|
|
1552
2312
|
* The group sprites' stroke color.
|
|
1553
2313
|
*/
|
|
1554
2314
|
stroke: Q5.Color;
|
|
2315
|
+
|
|
1555
2316
|
/**
|
|
1556
2317
|
* The group sprites' stroke weight, the thickness of its outline.
|
|
1557
2318
|
*/
|
|
1558
2319
|
strokeWeight: number;
|
|
2320
|
+
|
|
1559
2321
|
/**
|
|
1560
2322
|
* The group sprites' speed.
|
|
1561
2323
|
*
|
|
@@ -1563,33 +2325,40 @@ declare global {
|
|
|
1563
2325
|
* 180 degrees opposite of its current direction angle.
|
|
1564
2326
|
*/
|
|
1565
2327
|
speed: number;
|
|
2328
|
+
|
|
1566
2329
|
/**
|
|
1567
2330
|
* The group sprites' speed along the surface of its collider(s),
|
|
1568
2331
|
* like a conveyor belt.
|
|
1569
2332
|
*/
|
|
1570
2333
|
surfaceSpeed: number;
|
|
2334
|
+
|
|
1571
2335
|
/**
|
|
1572
2336
|
* Text displayed at the center of the group sprites.
|
|
1573
2337
|
*/
|
|
1574
2338
|
text: number;
|
|
2339
|
+
|
|
1575
2340
|
/**
|
|
1576
2341
|
* The group sprites' text fill color. Black by default.
|
|
1577
2342
|
*/
|
|
1578
2343
|
textFill: Q5.Color;
|
|
2344
|
+
|
|
1579
2345
|
/**
|
|
1580
2346
|
* The group sprites' text stroke color.
|
|
1581
2347
|
* No stroke by default, does not inherit from the sketch's stroke color.
|
|
1582
2348
|
*/
|
|
1583
2349
|
textStroke: Q5.Color;
|
|
2350
|
+
|
|
1584
2351
|
/**
|
|
1585
2352
|
* The group sprites' text stroke weight, the thickness of its outline.
|
|
1586
2353
|
* No stroke by default, does not inherit from the sketch's stroke weight.
|
|
1587
2354
|
*/
|
|
1588
2355
|
textStrokeWeight: number;
|
|
2356
|
+
|
|
1589
2357
|
/**
|
|
1590
2358
|
* The group sprites' text size, the sketch's current textSize by default.
|
|
1591
2359
|
*/
|
|
1592
2360
|
textSize: number;
|
|
2361
|
+
|
|
1593
2362
|
/**
|
|
1594
2363
|
* If true the group sprites are shown, if set to false the group sprites are hidden.
|
|
1595
2364
|
*
|
|
@@ -1597,10 +2366,12 @@ declare global {
|
|
|
1597
2366
|
* set to true again if it goes back on screen.
|
|
1598
2367
|
*/
|
|
1599
2368
|
visible: boolean;
|
|
2369
|
+
|
|
1600
2370
|
/**
|
|
1601
2371
|
* The width of the group sprites.
|
|
1602
2372
|
*/
|
|
1603
2373
|
w: number;
|
|
2374
|
+
|
|
1604
2375
|
/**
|
|
1605
2376
|
* The width of the group sprites.
|
|
1606
2377
|
*/
|
|
@@ -1611,6 +2382,7 @@ declare global {
|
|
|
1611
2382
|
* It's useful for debugging.
|
|
1612
2383
|
*/
|
|
1613
2384
|
idNum: number;
|
|
2385
|
+
|
|
1614
2386
|
/**
|
|
1615
2387
|
* Groups can have subgroups, which inherit the properties
|
|
1616
2388
|
* of their parent groups.
|
|
@@ -1619,18 +2391,22 @@ declare global {
|
|
|
1619
2391
|
subgroups: {
|
|
1620
2392
|
[x: string]: any;
|
|
1621
2393
|
}[];
|
|
2394
|
+
|
|
1622
2395
|
/**
|
|
1623
2396
|
* The direct parent group that this group inherits properties from.
|
|
1624
2397
|
*/
|
|
1625
2398
|
parent: any;
|
|
2399
|
+
|
|
1626
2400
|
/**
|
|
1627
2401
|
* Creates a new sprite with the traits of the group and adds it to the group.
|
|
1628
2402
|
*/
|
|
1629
2403
|
Sprite: typeof Sprite;
|
|
2404
|
+
|
|
1630
2405
|
/**
|
|
1631
2406
|
* Creates a new subgroup that inherits the traits of the group.
|
|
1632
2407
|
*/
|
|
1633
2408
|
Group: typeof Group;
|
|
2409
|
+
|
|
1634
2410
|
/**
|
|
1635
2411
|
* A property of the `allSprites` group only,
|
|
1636
2412
|
* that controls whether sprites are automatically deleted
|
|
@@ -1640,28 +2416,33 @@ declare global {
|
|
|
1640
2416
|
* remain false for the rest of the sketch, unless changed.
|
|
1641
2417
|
*/
|
|
1642
2418
|
autoCull: boolean;
|
|
2419
|
+
|
|
1643
2420
|
/**
|
|
1644
2421
|
* New group sprites will not have physics bodies (can't have colliders).
|
|
1645
2422
|
*/
|
|
1646
2423
|
visualOnly: boolean;
|
|
2424
|
+
|
|
1647
2425
|
/**
|
|
1648
2426
|
* Alias for `group.push`.
|
|
1649
2427
|
*
|
|
1650
2428
|
* Adds a sprite to the end of the group.
|
|
1651
2429
|
*/
|
|
1652
2430
|
add: (...sprites: Sprite[]) => number;
|
|
2431
|
+
|
|
1653
2432
|
/**
|
|
1654
2433
|
* Alias for `group.includes`.
|
|
1655
2434
|
*
|
|
1656
2435
|
* Check if a sprite is in the group.
|
|
1657
2436
|
*/
|
|
1658
2437
|
contains: (searchElement: Sprite, fromIndex?: number) => boolean;
|
|
2438
|
+
|
|
1659
2439
|
/**
|
|
1660
2440
|
* Depending on the value that the amount property is set to, the group will
|
|
1661
2441
|
* either add or delete sprites.
|
|
1662
2442
|
*/
|
|
1663
2443
|
get amount(): number;
|
|
1664
2444
|
set amount(val: number);
|
|
2445
|
+
|
|
1665
2446
|
/**
|
|
1666
2447
|
* Returns true on the first frame that the group collides with the
|
|
1667
2448
|
* target group.
|
|
@@ -1673,6 +2454,7 @@ declare global {
|
|
|
1673
2454
|
* @param callback
|
|
1674
2455
|
*/
|
|
1675
2456
|
collides(target: Group, callback?: Function): boolean;
|
|
2457
|
+
|
|
1676
2458
|
/**
|
|
1677
2459
|
* Returns the amount of frames that the group has been colliding
|
|
1678
2460
|
* with the target group for, which is a truthy value. Returns 0 if
|
|
@@ -1683,6 +2465,7 @@ declare global {
|
|
|
1683
2465
|
* @return {Number} frames
|
|
1684
2466
|
*/
|
|
1685
2467
|
colliding(target: Group, callback?: Function): number;
|
|
2468
|
+
|
|
1686
2469
|
/**
|
|
1687
2470
|
* Returns true on the first frame that the group no longer overlaps
|
|
1688
2471
|
* with the target group.
|
|
@@ -1692,6 +2475,7 @@ declare global {
|
|
|
1692
2475
|
* @return {Boolean}
|
|
1693
2476
|
*/
|
|
1694
2477
|
collided(target: Group, callback?: Function): boolean;
|
|
2478
|
+
|
|
1695
2479
|
/**
|
|
1696
2480
|
* Returns true on the first frame that the group overlaps with the
|
|
1697
2481
|
* target group.
|
|
@@ -1703,6 +2487,7 @@ declare global {
|
|
|
1703
2487
|
* @param callback
|
|
1704
2488
|
*/
|
|
1705
2489
|
overlaps(target: Group, callback?: Function): boolean;
|
|
2490
|
+
|
|
1706
2491
|
/**
|
|
1707
2492
|
* Returns the amount of frames that the group has been overlapping
|
|
1708
2493
|
* with the target group for, which is a truthy value. Returns 0 if
|
|
@@ -1713,6 +2498,7 @@ declare global {
|
|
|
1713
2498
|
* @return {Number} frames
|
|
1714
2499
|
*/
|
|
1715
2500
|
overlapping(target: Group, callback?: Function): number;
|
|
2501
|
+
|
|
1716
2502
|
/**
|
|
1717
2503
|
* Returns true on the first frame that the group no longer overlaps
|
|
1718
2504
|
* with the target group.
|
|
@@ -1722,24 +2508,136 @@ declare global {
|
|
|
1722
2508
|
* @return {Boolean}
|
|
1723
2509
|
*/
|
|
1724
2510
|
overlapped(target: Group, callback?: Function): boolean;
|
|
2511
|
+
|
|
1725
2512
|
/**
|
|
1726
2513
|
* Sets a pass through contact relationship between the group and the target group.
|
|
1727
2514
|
* @param target
|
|
1728
2515
|
*/
|
|
1729
2516
|
pass(target: Group): void;
|
|
2517
|
+
|
|
1730
2518
|
/**
|
|
1731
2519
|
* Sets a pass through contact relationship between the group and the target group.
|
|
1732
2520
|
* @param target
|
|
1733
2521
|
*/
|
|
1734
2522
|
passes(target: Group): void;
|
|
1735
|
-
|
|
1736
|
-
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* Applies a force magnitude to the group at its bearing.
|
|
2526
|
+
*/
|
|
2527
|
+
applyForce(amount: number, origin?: { x: number; y: number }): void;
|
|
2528
|
+
|
|
2529
|
+
/**
|
|
2530
|
+
* Applies a force vector to the group.
|
|
2531
|
+
*/
|
|
2532
|
+
applyForce(force: { x: number; y: number }, origin?: { x: number; y: number }): void;
|
|
2533
|
+
|
|
2534
|
+
/**
|
|
2535
|
+
* Applies a force scaled to member masses using a magnitude.
|
|
2536
|
+
*/
|
|
2537
|
+
applyForceScaled(amount: number, origin?: { x: number; y: number }): void;
|
|
2538
|
+
|
|
2539
|
+
/**
|
|
2540
|
+
* Applies a force scaled to member masses using a vector.
|
|
2541
|
+
*/
|
|
2542
|
+
applyForceScaled(force: { x: number; y: number }, origin?: { x: number; y: number }): void;
|
|
1737
2543
|
applyWind(speed: number, angle: number, drag?: number, lift?: number): void;
|
|
1738
|
-
|
|
2544
|
+
|
|
2545
|
+
/**
|
|
2546
|
+
* Applies a force to the group's center of mass attracting it to
|
|
2547
|
+
* the given position.
|
|
2548
|
+
*/
|
|
2549
|
+
attractTo(x: number, y: number, force?: number): void;
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* Applies a force to the group's center of mass attracting it to
|
|
2553
|
+
* the given position.
|
|
2554
|
+
*/
|
|
2555
|
+
attractTo(pos: { x: number; y: number }, force?: number): void;
|
|
1739
2556
|
applyTorque(torque: any): void;
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
2557
|
+
|
|
2558
|
+
/**
|
|
2559
|
+
* Moves each sprite in the group to a destination at a constant speed,
|
|
2560
|
+
* maintaining their relative offsets from the group's centroid.
|
|
2561
|
+
*/
|
|
2562
|
+
moveTo(x: number | null, y: number | null, speed?: number): PromiseLike<boolean>;
|
|
2563
|
+
|
|
2564
|
+
/**
|
|
2565
|
+
* Moves each sprite in the group to a destination at a constant speed,
|
|
2566
|
+
* maintaining their relative offsets from the group's centroid.
|
|
2567
|
+
*/
|
|
2568
|
+
moveTo(pos: { x: number | null; y: number | null }, speed?: number): PromiseLike<boolean>;
|
|
2569
|
+
|
|
2570
|
+
/**
|
|
2571
|
+
* Moves the group towards a position.
|
|
2572
|
+
*/
|
|
2573
|
+
moveTowards(x: number | null, y: number | null, tracking?: number): void;
|
|
2574
|
+
|
|
2575
|
+
/**
|
|
2576
|
+
* Moves the group towards a position.
|
|
2577
|
+
*/
|
|
2578
|
+
moveTowards(pos: { x: number | null; y: number | null }, tracking?: number): void;
|
|
2579
|
+
|
|
2580
|
+
/**
|
|
2581
|
+
* Rotates each sprite in the group to a target angle. The sign of `speed`
|
|
2582
|
+
* determines direction: positive = CW, negative = CCW.
|
|
2583
|
+
*/
|
|
2584
|
+
rotateTo(angle: number, speed?: number): PromiseLike<boolean>;
|
|
2585
|
+
|
|
2586
|
+
/**
|
|
2587
|
+
* Rotates each sprite in the group to face a position. The sign of `speed`
|
|
2588
|
+
* determines direction: positive = CW, negative = CCW.
|
|
2589
|
+
*/
|
|
2590
|
+
rotateTo(pos: { x: number; y: number }, speed?: number, facing?: number): PromiseLike<boolean>;
|
|
2591
|
+
|
|
2592
|
+
/**
|
|
2593
|
+
* Rotates each sprite in the group by the given angle amount at the given speed.
|
|
2594
|
+
*/
|
|
2595
|
+
rotate(angle: number, speed?: number): PromiseLike<boolean>;
|
|
2596
|
+
|
|
2597
|
+
/**
|
|
2598
|
+
* Rotates each sprite in the group by the smallest angular distance to
|
|
2599
|
+
* a target angle, stopping when they arrive.
|
|
2600
|
+
*/
|
|
2601
|
+
rotateMinTo(angle: number, speed?: number): PromiseLike<boolean>;
|
|
2602
|
+
|
|
2603
|
+
/**
|
|
2604
|
+
* Rotates each sprite in the group by the smallest angular distance to
|
|
2605
|
+
* face a position, stopping when they arrive.
|
|
2606
|
+
*/
|
|
2607
|
+
rotateMinTo(pos: { x: number; y: number }, speed?: number, facing?: number): PromiseLike<boolean>;
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Rotates each sprite in the group towards an angle.
|
|
2611
|
+
*/
|
|
2612
|
+
rotateTowards(angle: number, tracking?: number): void;
|
|
2613
|
+
|
|
2614
|
+
/**
|
|
2615
|
+
* Rotates each sprite in the group towards a position.
|
|
2616
|
+
*/
|
|
2617
|
+
rotateTowards(pos: { x: number; y: number }, tracking?: number, facing?: number): void;
|
|
2618
|
+
|
|
2619
|
+
/**
|
|
2620
|
+
* Moves and rotates each sprite in the group towards a target transform,
|
|
2621
|
+
* maintaining their relative offsets from the group's centroid.
|
|
2622
|
+
*/
|
|
2623
|
+
transformTowards(x: number, y: number, rotation?: number, tracking?: number): void;
|
|
2624
|
+
|
|
2625
|
+
/**
|
|
2626
|
+
* Moves and rotates each sprite in the group towards a target transform,
|
|
2627
|
+
* maintaining their relative offsets from the group's centroid.
|
|
2628
|
+
*/
|
|
2629
|
+
transformTowards(pos: { x: number; y: number }, rotation?: number, tracking?: number): void;
|
|
2630
|
+
|
|
2631
|
+
/**
|
|
2632
|
+
* Applies a repelling force from a position.
|
|
2633
|
+
*/
|
|
2634
|
+
repelFrom(x: number, y: number, force?: number): void;
|
|
2635
|
+
|
|
2636
|
+
/**
|
|
2637
|
+
* Applies a repelling force from a position.
|
|
2638
|
+
*/
|
|
2639
|
+
repelFrom(pos: { x: number; y: number }, force?: number): void;
|
|
2640
|
+
|
|
1743
2641
|
/**
|
|
1744
2642
|
* Detects when sprites go outside the given culling boundary
|
|
1745
2643
|
* relative to the camera.
|
|
@@ -1757,6 +2655,7 @@ declare global {
|
|
|
1757
2655
|
* @return {Number} the number of sprites culled
|
|
1758
2656
|
*/
|
|
1759
2657
|
cull(top?: number, bottom?: number, left?: number, right?: number, cb?: Function): number;
|
|
2658
|
+
|
|
1760
2659
|
/**
|
|
1761
2660
|
* If removalCount is greater than 0, that amount of
|
|
1762
2661
|
* sprites starting from the start index will be removed
|
|
@@ -1772,6 +2671,7 @@ declare global {
|
|
|
1772
2671
|
* @return {Sprite[]} the removed sprites
|
|
1773
2672
|
*/
|
|
1774
2673
|
splice(start: number, removalCount: number, ...sprites: Sprite[]): Sprite[];
|
|
2674
|
+
|
|
1775
2675
|
/**
|
|
1776
2676
|
* Removes a sprite from this group and its sub groups (if any),
|
|
1777
2677
|
* but does not delete it from the world.
|
|
@@ -1780,6 +2680,13 @@ declare global {
|
|
|
1780
2680
|
* @return {Sprite} the deleted sprite or undefined if the specified sprite was not found
|
|
1781
2681
|
*/
|
|
1782
2682
|
remove(item: Sprite | number): Sprite;
|
|
2683
|
+
|
|
2684
|
+
/**
|
|
2685
|
+
* Removes all sprites from this group without deleting them.
|
|
2686
|
+
* @returns the removed sprites
|
|
2687
|
+
*/
|
|
2688
|
+
removeAll(): Sprite[];
|
|
2689
|
+
|
|
1783
2690
|
/**
|
|
1784
2691
|
* Deletes the group and all its sprites
|
|
1785
2692
|
* from the world and every other group they belong to.
|
|
@@ -1787,22 +2694,28 @@ declare global {
|
|
|
1787
2694
|
* Don't attempt to use a group after deleting it.
|
|
1788
2695
|
*/
|
|
1789
2696
|
delete(): void;
|
|
2697
|
+
|
|
1790
2698
|
/**
|
|
1791
2699
|
* Deletes all the sprites in the group.
|
|
1792
2700
|
*
|
|
1793
2701
|
* Does not delete the group itself.
|
|
1794
2702
|
*/
|
|
1795
2703
|
deleteAll(): void;
|
|
2704
|
+
|
|
1796
2705
|
/**
|
|
1797
2706
|
* Updates all the sprites in the group.
|
|
1798
2707
|
*/
|
|
1799
2708
|
update(): void;
|
|
2709
|
+
|
|
1800
2710
|
/**
|
|
1801
2711
|
* Draws all the sprites in the group.
|
|
1802
2712
|
*/
|
|
1803
2713
|
draw(): void;
|
|
1804
2714
|
}
|
|
1805
2715
|
|
|
2716
|
+
/**
|
|
2717
|
+
* The World is the Box2D physics simulation.
|
|
2718
|
+
*/
|
|
1806
2719
|
class World {
|
|
1807
2720
|
/**
|
|
1808
2721
|
* Gravity force vector that affects all dynamic physics colliders.
|
|
@@ -1812,6 +2725,7 @@ declare global {
|
|
|
1812
2725
|
*/
|
|
1813
2726
|
get gravity(): any;
|
|
1814
2727
|
set gravity(val: any);
|
|
2728
|
+
|
|
1815
2729
|
/**
|
|
1816
2730
|
* The lowest velocity an object can have before it is considered
|
|
1817
2731
|
* to be at rest.
|
|
@@ -1824,10 +2738,12 @@ declare global {
|
|
|
1824
2738
|
*/
|
|
1825
2739
|
get bounceThreshold(): number;
|
|
1826
2740
|
set bounceThreshold(val: number);
|
|
2741
|
+
|
|
1827
2742
|
/**
|
|
1828
2743
|
* The time elapsed in the physics simulation in seconds.
|
|
1829
2744
|
*/
|
|
1830
2745
|
physicsTime: number;
|
|
2746
|
+
|
|
1831
2747
|
/**
|
|
1832
2748
|
* Represents the size of a meter in pixels.
|
|
1833
2749
|
*
|
|
@@ -1840,15 +2756,18 @@ declare global {
|
|
|
1840
2756
|
* @default 60
|
|
1841
2757
|
*/
|
|
1842
2758
|
meterSize: number;
|
|
2759
|
+
|
|
1843
2760
|
/**
|
|
1844
2761
|
* @default true
|
|
1845
2762
|
*/
|
|
1846
2763
|
autoStep: boolean;
|
|
2764
|
+
|
|
1847
2765
|
/**
|
|
1848
2766
|
* Performs a physics simulation step that advances all sprites
|
|
1849
2767
|
* forward in time by 1 / updateRate * timeScale if no timeStep is given.
|
|
1850
2768
|
*/
|
|
1851
2769
|
physicsUpdate(timeStep?: number): void;
|
|
2770
|
+
|
|
1852
2771
|
/**
|
|
1853
2772
|
* A time scale of 1.0 represents real time.
|
|
1854
2773
|
* Accepts decimal values between 0 and 2.
|
|
@@ -1856,6 +2775,7 @@ declare global {
|
|
|
1856
2775
|
*/
|
|
1857
2776
|
get timeScale(): number;
|
|
1858
2777
|
set timeScale(val: number);
|
|
2778
|
+
|
|
1859
2779
|
/**
|
|
1860
2780
|
* The fixed update rate of the physics simulation in hertz.
|
|
1861
2781
|
*
|
|
@@ -1868,43 +2788,65 @@ declare global {
|
|
|
1868
2788
|
*/
|
|
1869
2789
|
get updateRate(): number;
|
|
1870
2790
|
set updateRate(val: number);
|
|
2791
|
+
|
|
1871
2792
|
/**
|
|
1872
2793
|
* The real time in seconds since the world was created, including
|
|
1873
2794
|
* time spent paused.
|
|
1874
2795
|
*/
|
|
1875
2796
|
get realTime(): number;
|
|
2797
|
+
|
|
2798
|
+
/**
|
|
2799
|
+
* Returns the sprites at a position, ordered by layer.
|
|
2800
|
+
*
|
|
2801
|
+
* Sprites must have a physics body to be detected.
|
|
2802
|
+
* @param x x coordinate or object with x and y properties
|
|
2803
|
+
* @param y
|
|
2804
|
+
* @param radius the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
2805
|
+
* @param group limit results to a specific group,
|
|
2806
|
+
* allSprites by default
|
|
2807
|
+
* @param cameraActiveWhenDrawn limit results to
|
|
2808
|
+
* sprites drawn when the camera was active, true by default
|
|
2809
|
+
* @returns an array of sprites
|
|
2810
|
+
*/
|
|
2811
|
+
getSpritesAt(x: number, y: number, radius?: number, group?: Group, cameraActiveWhenDrawn?: boolean): Sprite[];
|
|
2812
|
+
|
|
1876
2813
|
/**
|
|
1877
2814
|
* Returns the sprites at a position, ordered by layer.
|
|
1878
2815
|
*
|
|
1879
2816
|
* Sprites must have a physics body to be detected.
|
|
1880
|
-
* @param
|
|
1881
|
-
* @param y
|
|
2817
|
+
* @param pos object with x and y properties
|
|
1882
2818
|
* @param radius the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
1883
|
-
* @param group limit results to a specific group,
|
|
1884
|
-
*
|
|
1885
|
-
* @param cameraActiveWhenDrawn limit results to
|
|
1886
|
-
* sprites drawn when the camera was active, true by default
|
|
2819
|
+
* @param group limit results to a specific group, allSprites by default
|
|
2820
|
+
* @param cameraActiveWhenDrawn limit results to sprites drawn when the camera was active, true by default
|
|
1887
2821
|
* @returns an array of sprites
|
|
1888
2822
|
*/
|
|
1889
|
-
getSpritesAt(
|
|
1890
|
-
|
|
1891
|
-
y?: number,
|
|
1892
|
-
radius?: number,
|
|
1893
|
-
group?: Group,
|
|
1894
|
-
cameraActiveWhenDrawn?: boolean
|
|
1895
|
-
): Sprite[];
|
|
2823
|
+
getSpritesAt(pos: { x: number; y: number }, radius?: number, group?: Group, cameraActiveWhenDrawn?: boolean): Sprite[];
|
|
2824
|
+
|
|
1896
2825
|
/**
|
|
1897
2826
|
* Returns the sprite at the specified position
|
|
1898
2827
|
* on the top most layer, drawn when the camera was on.
|
|
1899
2828
|
*
|
|
1900
2829
|
* The sprite must have a physics body to be detected.
|
|
1901
|
-
* @param x x coordinate or
|
|
2830
|
+
* @param x x coordinate or object with x and y properties
|
|
1902
2831
|
* @param y
|
|
1903
2832
|
* @param radius the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
1904
2833
|
* @param group the group to search
|
|
1905
2834
|
* @returns a sprite
|
|
1906
2835
|
*/
|
|
1907
|
-
getSpriteAt(x: number
|
|
2836
|
+
getSpriteAt(x: number, y: number, radius?: number, group?: Group): Sprite;
|
|
2837
|
+
|
|
2838
|
+
/**
|
|
2839
|
+
* Returns the sprite at the specified position
|
|
2840
|
+
* on the top most layer, drawn when the camera was on.
|
|
2841
|
+
*
|
|
2842
|
+
* The sprite must have a physics body to be detected.
|
|
2843
|
+
* @param pos object with x and y properties
|
|
2844
|
+
* @param radius the distance from the point that sprites can be detected at, default is 0 (only sprites that overlap the point will be detected)
|
|
2845
|
+
* @param group the group to search
|
|
2846
|
+
* @returns a sprite
|
|
2847
|
+
*/
|
|
2848
|
+
getSpriteAt(pos: { x: number; y: number }, radius?: number, group?: Group): Sprite;
|
|
2849
|
+
|
|
1908
2850
|
/**
|
|
1909
2851
|
* "Sleeping" sprites get temporarily ignored during physics
|
|
1910
2852
|
* simulation. A sprite starts "sleeping" when it stops moving and
|
|
@@ -1916,39 +2858,131 @@ declare global {
|
|
|
1916
2858
|
*/
|
|
1917
2859
|
get allowSleeping(): boolean;
|
|
1918
2860
|
set allowSleeping(val: boolean);
|
|
2861
|
+
|
|
1919
2862
|
/**
|
|
1920
2863
|
* Finds the first sprite (with a physics body) that
|
|
1921
2864
|
* intersects a ray (line).
|
|
1922
2865
|
*
|
|
1923
|
-
* @param startPos starting position of the ray cast
|
|
1924
|
-
* @param direction direction of the ray
|
|
1925
|
-
* @param maxDistance max distance the ray should check
|
|
2866
|
+
* @param startPos starting position of the ray cast, object with x and y properties or array [x, y]
|
|
2867
|
+
* @param direction direction angle of the ray
|
|
2868
|
+
* @param maxDistance max distance the ray should check, default 10000
|
|
1926
2869
|
* @returns The first sprite the ray hits or undefined
|
|
1927
2870
|
*/
|
|
1928
|
-
rayCast(startPos:
|
|
2871
|
+
rayCast(startPos: { x: number; y: number } | number[], direction: number, maxDistance?: number): Sprite;
|
|
2872
|
+
|
|
1929
2873
|
/**
|
|
1930
|
-
* Finds
|
|
1931
|
-
* a
|
|
2874
|
+
* Finds the first sprite (with a physics body) that
|
|
2875
|
+
* intersects a ray from startPos to endPos.
|
|
1932
2876
|
*
|
|
1933
2877
|
* @param startPos starting position of the ray cast
|
|
1934
|
-
* @param
|
|
1935
|
-
* @
|
|
1936
|
-
|
|
2878
|
+
* @param endPos end position of the ray cast
|
|
2879
|
+
* @returns The first sprite the ray hits or undefined
|
|
2880
|
+
*/
|
|
2881
|
+
rayCast(startPos: { x: number; y: number } | number[], endPos: { x: number; y: number } | number[]): Sprite;
|
|
2882
|
+
|
|
2883
|
+
/**
|
|
2884
|
+
* Finds all sprites (with physics bodies) that intersect
|
|
2885
|
+
* a ray (line), sorted by distance.
|
|
2886
|
+
*
|
|
2887
|
+
* @param startPos starting position of the ray cast, object with x and y properties or array [x, y]
|
|
2888
|
+
* @param direction direction angle of the ray
|
|
2889
|
+
* @param maxDistance max distance the ray should check, default 10000
|
|
2890
|
+
* @param limiter callback run each time the ray hits a sprite; return true to stop the ray
|
|
1937
2891
|
* @returns An array of sprites that the ray cast hit, sorted by distance. The sprite closest to the starting point will be at index 0. If a limiter is provided, this array includes the sprite that caused the ray to stop.
|
|
1938
2892
|
*/
|
|
1939
|
-
rayCastAll(startPos:
|
|
2893
|
+
rayCastAll(startPos: { x: number; y: number } | number[], direction: number, maxDistance?: number, limiter?: Function): Sprite[];
|
|
2894
|
+
|
|
2895
|
+
/**
|
|
2896
|
+
* Finds all sprites (with physics bodies) that intersect
|
|
2897
|
+
* a ray from startPos to endPos, sorted by distance.
|
|
2898
|
+
*
|
|
2899
|
+
* @param startPos starting position of the ray cast
|
|
2900
|
+
* @param endPos end position of the ray cast
|
|
2901
|
+
* @param limiter callback run each time the ray hits a sprite; return true to stop the ray
|
|
2902
|
+
* @returns An array of sprites that the ray cast hit, sorted by distance.
|
|
2903
|
+
*/
|
|
2904
|
+
rayCastAll(startPos: { x: number; y: number } | number[], endPos: { x: number; y: number } | number[], limiter?: Function): Sprite[];
|
|
2905
|
+
|
|
2906
|
+
/**
|
|
2907
|
+
* Finds the first sprite (with a physics body) that
|
|
2908
|
+
* intersects a swept circle (capsule cast) from startPos to endPos.
|
|
2909
|
+
*
|
|
2910
|
+
* @param startPos starting position of the cast, object with x and y properties or array [x, y]
|
|
2911
|
+
* @param endPos end position of the cast
|
|
2912
|
+
* @param radius radius of the circle
|
|
2913
|
+
* @returns The first sprite hit or undefined
|
|
2914
|
+
*/
|
|
2915
|
+
circleCast(startPos: { x: number; y: number } | number[], endPos: { x: number; y: number } | number[], radius: number): Sprite;
|
|
2916
|
+
|
|
2917
|
+
/**
|
|
2918
|
+
* Finds all sprites (with physics bodies) that intersect
|
|
2919
|
+
* a swept circle (capsule cast) from startPos to endPos, sorted by distance.
|
|
2920
|
+
*
|
|
2921
|
+
* @param startPos starting position of the cast
|
|
2922
|
+
* @param endPos end position of the cast
|
|
2923
|
+
* @param radius radius of the circle
|
|
2924
|
+
* @param limiter callback run each time the cast hits a sprite; return true to stop the cast
|
|
2925
|
+
* @returns An array of sprites hit, sorted by distance.
|
|
2926
|
+
*/
|
|
2927
|
+
circleCastAll(startPos: { x: number; y: number } | number[], endPos: { x: number; y: number } | number[], radius: number, limiter?: Function): Sprite[];
|
|
2928
|
+
|
|
1940
2929
|
/**
|
|
1941
2930
|
* Applies an explosive force to sprites within the radius of the explosion.
|
|
1942
2931
|
*
|
|
1943
|
-
* @param x x coordinate or
|
|
2932
|
+
* @param x x coordinate or object with x and y properties of the center of the explosion
|
|
1944
2933
|
* @param y
|
|
1945
2934
|
* @param radius the distance from the center of the explosion that sprites can be affected by the explosion
|
|
1946
2935
|
* @param magnitude the strength of the explosion force, default is 1
|
|
1947
2936
|
* @param falloff how much the explosion force decreases as sprites are farther from the center of the explosion, default is 0.1 (10% decrease per pixel)
|
|
1948
2937
|
*/
|
|
1949
|
-
explodeAt(x: number
|
|
2938
|
+
explodeAt(x: number, y: number, radius?: number, magnitude?: number, falloff?: number): void;
|
|
2939
|
+
explodeAt(pos: { x: number; y: number }, radius?: number, magnitude?: number, falloff?: number): void;
|
|
2940
|
+
|
|
2941
|
+
/**
|
|
2942
|
+
* The number of physics bodies currently awake in the world.
|
|
2943
|
+
* @readonly
|
|
2944
|
+
*/
|
|
2945
|
+
get awakeBodies(): number;
|
|
2946
|
+
|
|
2947
|
+
/**
|
|
2948
|
+
* The minimum impact velocity needed for a hit event to be fired.
|
|
2949
|
+
*/
|
|
2950
|
+
get hitThreshold(): number;
|
|
2951
|
+
set hitThreshold(val: number);
|
|
2952
|
+
|
|
2953
|
+
/**
|
|
2954
|
+
* Box2D world performance profile data.
|
|
2955
|
+
* @readonly
|
|
2956
|
+
*/
|
|
2957
|
+
get profile(): any;
|
|
2958
|
+
|
|
2959
|
+
/**
|
|
2960
|
+
* Box2D world counter/statistics data.
|
|
2961
|
+
* @readonly
|
|
2962
|
+
*/
|
|
2963
|
+
get debugInfo(): any;
|
|
2964
|
+
|
|
2965
|
+
/**
|
|
2966
|
+
* The number of sub-steps per physics update.
|
|
2967
|
+
* More sub-steps increases accuracy at the cost of performance.
|
|
2968
|
+
* @default 4
|
|
2969
|
+
*/
|
|
2970
|
+
subSteps: number;
|
|
2971
|
+
|
|
2972
|
+
/**
|
|
2973
|
+
* Alias for `physicsUpdate`.
|
|
2974
|
+
*/
|
|
2975
|
+
step(timeStep?: number): void;
|
|
2976
|
+
|
|
2977
|
+
/**
|
|
2978
|
+
* The Box2D world ID. Don't change it!
|
|
2979
|
+
*/
|
|
2980
|
+
wID: b2WorldId;
|
|
1950
2981
|
}
|
|
1951
2982
|
|
|
2983
|
+
/**
|
|
2984
|
+
* The Camera controls the position and zoom of the view of the world that is drawn on the canvas.
|
|
2985
|
+
*/
|
|
1952
2986
|
class Camera {
|
|
1953
2987
|
/**
|
|
1954
2988
|
* Read only. True if the camera is active.
|
|
@@ -1956,26 +2990,37 @@ declare global {
|
|
|
1956
2990
|
* @default false
|
|
1957
2991
|
*/
|
|
1958
2992
|
isActive: boolean;
|
|
1959
|
-
|
|
1960
|
-
* The camera's position. {x, y}
|
|
1961
|
-
*/
|
|
1962
|
-
get pos(): any;
|
|
1963
|
-
set pos(val: any);
|
|
2993
|
+
|
|
1964
2994
|
/**
|
|
1965
2995
|
* The camera's x position.
|
|
1966
2996
|
*/
|
|
1967
2997
|
get x(): number;
|
|
1968
2998
|
set x(val: number);
|
|
2999
|
+
|
|
1969
3000
|
/**
|
|
1970
3001
|
* The camera's y position.
|
|
1971
3002
|
*/
|
|
1972
3003
|
get y(): number;
|
|
1973
3004
|
set y(val: number);
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* Gets the camera's position as a readonly {x, y} object that
|
|
3008
|
+
* won't be updated if the camera moves. Useful for saving the
|
|
3009
|
+
* camera's position at a specific moment in time.
|
|
3010
|
+
*/
|
|
3011
|
+
get pos(): { x: number; y: number };
|
|
3012
|
+
|
|
3013
|
+
/**
|
|
3014
|
+
* The camera's position.
|
|
3015
|
+
*/
|
|
3016
|
+
set pos(val: number[] | { x: number; y: number });
|
|
3017
|
+
|
|
1974
3018
|
/**
|
|
1975
|
-
* The camera's position
|
|
3019
|
+
* The camera's position vector.
|
|
1976
3020
|
*/
|
|
1977
|
-
get position():
|
|
1978
|
-
set position(val:
|
|
3021
|
+
get position(): Q5.Vector;
|
|
3022
|
+
set position(val: number[] | { x: number; y: number });
|
|
3023
|
+
|
|
1979
3024
|
/**
|
|
1980
3025
|
* Moves the camera to a position.
|
|
1981
3026
|
*
|
|
@@ -1985,6 +3030,7 @@ declare global {
|
|
|
1985
3030
|
* @returns resolves true when the camera reaches the target position
|
|
1986
3031
|
*/
|
|
1987
3032
|
moveTo(x: number, y: number, speed: number): Promise<boolean>;
|
|
3033
|
+
|
|
1988
3034
|
/**
|
|
1989
3035
|
* Camera zoom.
|
|
1990
3036
|
*
|
|
@@ -1995,6 +3041,7 @@ declare global {
|
|
|
1995
3041
|
*/
|
|
1996
3042
|
get zoom(): number;
|
|
1997
3043
|
set zoom(val: number);
|
|
3044
|
+
|
|
1998
3045
|
/**
|
|
1999
3046
|
* Zoom the camera at a given speed.
|
|
2000
3047
|
*
|
|
@@ -2003,6 +3050,7 @@ declare global {
|
|
|
2003
3050
|
* @returns resolves true when the camera reaches the target zoom
|
|
2004
3051
|
*/
|
|
2005
3052
|
zoomTo(target: number, speed: number): Promise<boolean>;
|
|
3053
|
+
|
|
2006
3054
|
/**
|
|
2007
3055
|
* Activates the camera.
|
|
2008
3056
|
*
|
|
@@ -2010,6 +3058,7 @@ declare global {
|
|
|
2010
3058
|
* camera.off() is called.
|
|
2011
3059
|
*/
|
|
2012
3060
|
on(): void;
|
|
3061
|
+
|
|
2013
3062
|
/**
|
|
2014
3063
|
* Deactivates the camera.
|
|
2015
3064
|
*
|
|
@@ -2019,11 +3068,12 @@ declare global {
|
|
|
2019
3068
|
off(): void;
|
|
2020
3069
|
}
|
|
2021
3070
|
|
|
3071
|
+
/**
|
|
3072
|
+
* A Joint is used to constrain the movement of two sprites relative
|
|
3073
|
+
* to each other, which can lead to nuanced physics interactions.
|
|
3074
|
+
*/
|
|
2022
3075
|
class Joint {
|
|
2023
3076
|
/**
|
|
2024
|
-
* Joints are used to constrain the movement of two sprites relative
|
|
2025
|
-
* to each other. They can be used to create complex physics objects.
|
|
2026
|
-
*
|
|
2027
3077
|
* Don't use the Joint constructor directly, use one of these
|
|
2028
3078
|
* joint constructors instead:
|
|
2029
3079
|
*
|
|
@@ -2035,14 +3085,17 @@ declare global {
|
|
|
2035
3085
|
* @param type
|
|
2036
3086
|
*/
|
|
2037
3087
|
constructor(spriteA: Sprite, spriteB: Sprite, type?: string);
|
|
3088
|
+
|
|
2038
3089
|
/**
|
|
2039
3090
|
* The first sprite in the joint.
|
|
2040
3091
|
*/
|
|
2041
3092
|
spriteA: Sprite;
|
|
3093
|
+
|
|
2042
3094
|
/**
|
|
2043
3095
|
* The second sprite in the joint.
|
|
2044
3096
|
*/
|
|
2045
3097
|
spriteB: Sprite;
|
|
3098
|
+
|
|
2046
3099
|
/**
|
|
2047
3100
|
* The type of joint. Can be one of:
|
|
2048
3101
|
*
|
|
@@ -2051,12 +3104,14 @@ declare global {
|
|
|
2051
3104
|
* Can't be changed after the joint is created.
|
|
2052
3105
|
*/
|
|
2053
3106
|
type: string;
|
|
3107
|
+
|
|
2054
3108
|
/**
|
|
2055
3109
|
* Determines whether to draw the joint if spriteA
|
|
2056
3110
|
* or spriteB is drawn.
|
|
2057
3111
|
* @default true
|
|
2058
3112
|
*/
|
|
2059
3113
|
visible: boolean;
|
|
3114
|
+
|
|
2060
3115
|
/**
|
|
2061
3116
|
* Offset to the joint's anchorA position from the center of spriteA.
|
|
2062
3117
|
*
|
|
@@ -2064,7 +3119,8 @@ declare global {
|
|
|
2064
3119
|
* @default {x: 0, y: 0}
|
|
2065
3120
|
*/
|
|
2066
3121
|
get offsetA(): Q5.Vector;
|
|
2067
|
-
set offsetA(val: Q5.Vector);
|
|
3122
|
+
set offsetA(val: [] | { x: number; y: number } | Q5.Vector);
|
|
3123
|
+
|
|
2068
3124
|
/**
|
|
2069
3125
|
* Offset to the joint's anchorB position from the center of spriteB.
|
|
2070
3126
|
*
|
|
@@ -2072,12 +3128,14 @@ declare global {
|
|
|
2072
3128
|
* @default {x: 0, y: 0}
|
|
2073
3129
|
*/
|
|
2074
3130
|
get offsetB(): Q5.Vector;
|
|
2075
|
-
set offsetB(val: Q5.Vector);
|
|
3131
|
+
set offsetB(val: [] | { x: number; y: number } | Q5.Vector);
|
|
3132
|
+
|
|
2076
3133
|
/**
|
|
2077
3134
|
* Function that draws the joint. Can be overridden by the user.
|
|
2078
3135
|
*/
|
|
2079
3136
|
get draw(): Function;
|
|
2080
3137
|
set draw(val: Function);
|
|
3138
|
+
|
|
2081
3139
|
/**
|
|
2082
3140
|
* Set to true if you want the joint's sprites to collide with
|
|
2083
3141
|
* each other.
|
|
@@ -2085,16 +3143,19 @@ declare global {
|
|
|
2085
3143
|
*/
|
|
2086
3144
|
get collideConnected(): boolean;
|
|
2087
3145
|
set collideConnected(val: boolean);
|
|
3146
|
+
|
|
2088
3147
|
/**
|
|
2089
3148
|
* How much force the joint is applying to keep the two sprites together.
|
|
2090
3149
|
* @readonly
|
|
2091
3150
|
*/
|
|
2092
3151
|
get reactionForce(): any;
|
|
3152
|
+
|
|
2093
3153
|
/**
|
|
2094
3154
|
* How much torque the joint is applying to keep the two sprites together.
|
|
2095
3155
|
* @readonly
|
|
2096
3156
|
*/
|
|
2097
3157
|
get reactionTorque(): any;
|
|
3158
|
+
|
|
2098
3159
|
/**
|
|
2099
3160
|
* The amount of force that must be applied to the joint before it breaks.
|
|
2100
3161
|
*
|
|
@@ -2104,6 +3165,7 @@ declare global {
|
|
|
2104
3165
|
*/
|
|
2105
3166
|
get forceThreshold(): number;
|
|
2106
3167
|
set forceThreshold(val: number);
|
|
3168
|
+
|
|
2107
3169
|
/**
|
|
2108
3170
|
* The amount of torque that must be applied to the joint before it breaks.
|
|
2109
3171
|
*
|
|
@@ -2113,6 +3175,7 @@ declare global {
|
|
|
2113
3175
|
*/
|
|
2114
3176
|
get torqueThreshold(): number;
|
|
2115
3177
|
set torqueThreshold(val: number);
|
|
3178
|
+
|
|
2116
3179
|
/**
|
|
2117
3180
|
* This function is run when the joint's reaction force exceeds the
|
|
2118
3181
|
* force threshold or its reaction torque exceeds the torque threshold.
|
|
@@ -2121,11 +3184,17 @@ declare global {
|
|
|
2121
3184
|
* and the joint is deleted, simulating a break.
|
|
2122
3185
|
*/
|
|
2123
3186
|
onStrain(): void;
|
|
3187
|
+
|
|
2124
3188
|
/**
|
|
2125
3189
|
* Deletes the joint from the world and from each of the
|
|
2126
3190
|
* associated sprites' joints arrays.
|
|
2127
3191
|
*/
|
|
2128
3192
|
delete(): void;
|
|
3193
|
+
|
|
3194
|
+
/**
|
|
3195
|
+
* The Box2D joint ID. Don't change it!
|
|
3196
|
+
*/
|
|
3197
|
+
jID: b2JointId;
|
|
2129
3198
|
}
|
|
2130
3199
|
|
|
2131
3200
|
class GlueJoint extends Joint {
|
|
@@ -2151,11 +3220,13 @@ declare global {
|
|
|
2151
3220
|
* @param spriteB
|
|
2152
3221
|
*/
|
|
2153
3222
|
constructor(spriteA: Sprite, spriteB: Sprite);
|
|
3223
|
+
|
|
2154
3224
|
/**
|
|
2155
3225
|
* The current distance between the two joint anchors.
|
|
2156
3226
|
* @readonly
|
|
2157
3227
|
*/
|
|
2158
3228
|
get currentLength(): number;
|
|
3229
|
+
|
|
2159
3230
|
/**
|
|
2160
3231
|
* The target length of the joint between the two joint anchors.
|
|
2161
3232
|
*
|
|
@@ -2164,6 +3235,7 @@ declare global {
|
|
|
2164
3235
|
*/
|
|
2165
3236
|
get length(): number;
|
|
2166
3237
|
set length(val: number);
|
|
3238
|
+
|
|
2167
3239
|
/**
|
|
2168
3240
|
* Whether the joint's length limits are enabled.
|
|
2169
3241
|
* When enabled a min/max length range constrains the joint.
|
|
@@ -2171,27 +3243,32 @@ declare global {
|
|
|
2171
3243
|
*/
|
|
2172
3244
|
get limitsEnabled(): boolean;
|
|
2173
3245
|
set limitsEnabled(val: boolean);
|
|
3246
|
+
|
|
2174
3247
|
/**
|
|
2175
3248
|
* The minimum length allowed when limits are enabled.
|
|
2176
3249
|
* @readonly
|
|
2177
3250
|
*/
|
|
2178
3251
|
get minLength(): number;
|
|
3252
|
+
|
|
2179
3253
|
/**
|
|
2180
3254
|
* The maximum length allowed when limits are enabled.
|
|
2181
3255
|
* @readonly
|
|
2182
3256
|
*/
|
|
2183
3257
|
get maxLength(): number;
|
|
3258
|
+
|
|
2184
3259
|
/**
|
|
2185
3260
|
* Accepts a number to set a symmetric range
|
|
2186
3261
|
* or an array with the minimum and maximum length limits.
|
|
2187
3262
|
*/
|
|
2188
3263
|
set range(val: [number, number] | number);
|
|
3264
|
+
|
|
2189
3265
|
/**
|
|
2190
3266
|
* Whether spring behavior is enabled for the joint.
|
|
2191
3267
|
* @default true
|
|
2192
3268
|
*/
|
|
2193
3269
|
get springEnabled(): boolean;
|
|
2194
3270
|
set springEnabled(val: boolean);
|
|
3271
|
+
|
|
2195
3272
|
/**
|
|
2196
3273
|
* The springiness of the joint, a 0-1 ratio.
|
|
2197
3274
|
*
|
|
@@ -2200,6 +3277,7 @@ declare global {
|
|
|
2200
3277
|
*/
|
|
2201
3278
|
get springiness(): number;
|
|
2202
3279
|
set springiness(val: number);
|
|
3280
|
+
|
|
2203
3281
|
/**
|
|
2204
3282
|
* Damping is a 0-1 ratio describing how quickly the joint loses
|
|
2205
3283
|
* vibrational energy.
|
|
@@ -2213,23 +3291,27 @@ declare global {
|
|
|
2213
3291
|
*/
|
|
2214
3292
|
get damping(): number;
|
|
2215
3293
|
set damping(val: number);
|
|
3294
|
+
|
|
2216
3295
|
/**
|
|
2217
3296
|
* Whether the joint's motor is enabled.
|
|
2218
3297
|
* @default false
|
|
2219
3298
|
*/
|
|
2220
3299
|
get motorEnabled(): boolean;
|
|
2221
3300
|
set motorEnabled(val: boolean);
|
|
3301
|
+
|
|
2222
3302
|
/**
|
|
2223
3303
|
* Motor speed.
|
|
2224
3304
|
* @default 0
|
|
2225
3305
|
*/
|
|
2226
3306
|
get speed(): number;
|
|
2227
3307
|
set speed(val: number);
|
|
3308
|
+
|
|
2228
3309
|
/**
|
|
2229
3310
|
* Maximum motor force the motor can apply.
|
|
2230
3311
|
*/
|
|
2231
3312
|
get maxPower(): number;
|
|
2232
3313
|
set maxPower(val: number);
|
|
3314
|
+
|
|
2233
3315
|
/**
|
|
2234
3316
|
* The current motor force being applied by the joint.
|
|
2235
3317
|
* @readonly
|
|
@@ -2248,6 +3330,7 @@ declare global {
|
|
|
2248
3330
|
* @param spriteB the wheel
|
|
2249
3331
|
*/
|
|
2250
3332
|
constructor(spriteA: Sprite, spriteB: Sprite);
|
|
3333
|
+
|
|
2251
3334
|
/**
|
|
2252
3335
|
* The angle at which the wheel is attached to the vehicle body.
|
|
2253
3336
|
*
|
|
@@ -2256,6 +3339,7 @@ declare global {
|
|
|
2256
3339
|
*/
|
|
2257
3340
|
get angle(): number;
|
|
2258
3341
|
set angle(val: number);
|
|
3342
|
+
|
|
2259
3343
|
/**
|
|
2260
3344
|
* Whether the joint's suspension limits are enabled.
|
|
2261
3345
|
* When enabled a min/max distance from resting constrains the joint.
|
|
@@ -2263,6 +3347,7 @@ declare global {
|
|
|
2263
3347
|
*/
|
|
2264
3348
|
get limitsEnabled(): boolean;
|
|
2265
3349
|
set limitsEnabled(val: boolean);
|
|
3350
|
+
|
|
2266
3351
|
/**
|
|
2267
3352
|
* The minimum distance the wheel's suspension can contract
|
|
2268
3353
|
* from 0, which represents the resting position,
|
|
@@ -2270,6 +3355,7 @@ declare global {
|
|
|
2270
3355
|
* @readonly
|
|
2271
3356
|
*/
|
|
2272
3357
|
get lowerLimit(): number;
|
|
3358
|
+
|
|
2273
3359
|
/**
|
|
2274
3360
|
* The maximum distance the wheel's suspension can extend
|
|
2275
3361
|
* from 0, which represents the resting position,
|
|
@@ -2277,6 +3363,7 @@ declare global {
|
|
|
2277
3363
|
* @readonly
|
|
2278
3364
|
*/
|
|
2279
3365
|
get upperLimit(): number;
|
|
3366
|
+
|
|
2280
3367
|
/**
|
|
2281
3368
|
* The distance the wheel's suspension can contract or extend
|
|
2282
3369
|
* from 0, which represents the resting position.
|
|
@@ -2285,6 +3372,7 @@ declare global {
|
|
|
2285
3372
|
* or an array with the minimum and maximum length limits.
|
|
2286
3373
|
*/
|
|
2287
3374
|
set range(val: [number, number] | number);
|
|
3375
|
+
|
|
2288
3376
|
/**
|
|
2289
3377
|
* Whether the wheel joint has suspension,
|
|
2290
3378
|
* which can make it ride smoother over bumps.
|
|
@@ -2292,6 +3380,7 @@ declare global {
|
|
|
2292
3380
|
*/
|
|
2293
3381
|
get springEnabled(): boolean;
|
|
2294
3382
|
set springEnabled(val: boolean);
|
|
3383
|
+
|
|
2295
3384
|
/**
|
|
2296
3385
|
* The springiness of the joint, a 0-1 ratio.
|
|
2297
3386
|
*
|
|
@@ -2300,6 +3389,7 @@ declare global {
|
|
|
2300
3389
|
*/
|
|
2301
3390
|
get springiness(): number;
|
|
2302
3391
|
set springiness(val: number);
|
|
3392
|
+
|
|
2303
3393
|
/**
|
|
2304
3394
|
* Damping is a 0-1 ratio describing how quickly the joint loses
|
|
2305
3395
|
* vibrational energy.
|
|
@@ -2313,23 +3403,27 @@ declare global {
|
|
|
2313
3403
|
*/
|
|
2314
3404
|
get damping(): number;
|
|
2315
3405
|
set damping(val: number);
|
|
3406
|
+
|
|
2316
3407
|
/**
|
|
2317
3408
|
* Whether the joint's motor is enabled.
|
|
2318
3409
|
* @default false
|
|
2319
3410
|
*/
|
|
2320
3411
|
get motorEnabled(): boolean;
|
|
2321
3412
|
set motorEnabled(val: boolean);
|
|
3413
|
+
|
|
2322
3414
|
/**
|
|
2323
3415
|
* Motor speed.
|
|
2324
3416
|
* @default 0
|
|
2325
3417
|
*/
|
|
2326
3418
|
get speed(): number;
|
|
2327
3419
|
set speed(val: number);
|
|
3420
|
+
|
|
2328
3421
|
/**
|
|
2329
3422
|
* Maximum torque the motor can apply.
|
|
2330
3423
|
*/
|
|
2331
3424
|
get maxPower(): number;
|
|
2332
3425
|
set maxPower(val: number);
|
|
3426
|
+
|
|
2333
3427
|
/**
|
|
2334
3428
|
* The current torque being applied by the motor.
|
|
2335
3429
|
* @readonly
|
|
@@ -2348,6 +3442,7 @@ declare global {
|
|
|
2348
3442
|
* @param spriteB
|
|
2349
3443
|
*/
|
|
2350
3444
|
constructor(spriteA: Sprite, spriteB: Sprite);
|
|
3445
|
+
|
|
2351
3446
|
/**
|
|
2352
3447
|
* Whether the joint's angle limits are enabled.
|
|
2353
3448
|
* When enabled a min/max angle range constrains the joint.
|
|
@@ -2355,32 +3450,38 @@ declare global {
|
|
|
2355
3450
|
*/
|
|
2356
3451
|
get limitsEnabled(): boolean;
|
|
2357
3452
|
set limitsEnabled(val: boolean);
|
|
3453
|
+
|
|
2358
3454
|
/**
|
|
2359
3455
|
* The lower limit of rotation.
|
|
2360
3456
|
* @readonly
|
|
2361
3457
|
*/
|
|
2362
3458
|
get minAngle(): number;
|
|
3459
|
+
|
|
2363
3460
|
/**
|
|
2364
3461
|
* The upper limit of rotation.
|
|
2365
3462
|
* @readonly
|
|
2366
3463
|
*/
|
|
2367
3464
|
get maxAngle(): number;
|
|
3465
|
+
|
|
2368
3466
|
/**
|
|
2369
3467
|
* Accepts a number to set a symmetric range
|
|
2370
3468
|
* or an array with the lower and upper limits of rotation.
|
|
2371
3469
|
*/
|
|
2372
3470
|
set range(val: [number, number] | number);
|
|
3471
|
+
|
|
2373
3472
|
/**
|
|
2374
3473
|
* The joint's current angle of rotation.
|
|
2375
3474
|
* @readonly
|
|
2376
3475
|
*/
|
|
2377
3476
|
get angle(): number;
|
|
3477
|
+
|
|
2378
3478
|
/**
|
|
2379
3479
|
* Whether spring behavior is enabled.
|
|
2380
3480
|
* @default false
|
|
2381
3481
|
*/
|
|
2382
3482
|
get springEnabled(): boolean;
|
|
2383
3483
|
set springEnabled(val: boolean);
|
|
3484
|
+
|
|
2384
3485
|
/**
|
|
2385
3486
|
* The springiness of the joint, a 0-1 ratio.
|
|
2386
3487
|
*
|
|
@@ -2389,29 +3490,34 @@ declare global {
|
|
|
2389
3490
|
*/
|
|
2390
3491
|
get springiness(): number;
|
|
2391
3492
|
set springiness(val: number);
|
|
3493
|
+
|
|
2392
3494
|
/**
|
|
2393
3495
|
* Damping ratio, 0-1. Higher values reduce oscillation faster.
|
|
2394
3496
|
* @default 0
|
|
2395
3497
|
*/
|
|
2396
3498
|
get damping(): number;
|
|
2397
3499
|
set damping(val: number);
|
|
3500
|
+
|
|
2398
3501
|
/**
|
|
2399
3502
|
* Whether the joint's motor is enabled.
|
|
2400
3503
|
* @default false
|
|
2401
3504
|
*/
|
|
2402
3505
|
get motorEnabled(): boolean;
|
|
2403
3506
|
set motorEnabled(val: boolean);
|
|
3507
|
+
|
|
2404
3508
|
/**
|
|
2405
3509
|
* Motor speed.
|
|
2406
3510
|
* @default 0
|
|
2407
3511
|
*/
|
|
2408
3512
|
get speed(): number;
|
|
2409
3513
|
set speed(val: number);
|
|
3514
|
+
|
|
2410
3515
|
/**
|
|
2411
3516
|
* Maximum torque the motor can apply.
|
|
2412
3517
|
*/
|
|
2413
3518
|
get maxPower(): number;
|
|
2414
3519
|
set maxPower(val: number);
|
|
3520
|
+
|
|
2415
3521
|
/**
|
|
2416
3522
|
* The current torque being applied by the motor.
|
|
2417
3523
|
* @readonly
|
|
@@ -2430,38 +3536,45 @@ declare global {
|
|
|
2430
3536
|
* @param spriteB
|
|
2431
3537
|
*/
|
|
2432
3538
|
constructor(spriteA: Sprite, spriteB: Sprite);
|
|
3539
|
+
|
|
2433
3540
|
/**
|
|
2434
3541
|
* The current displacement of spriteB along the slide axis.
|
|
2435
3542
|
* @readonly
|
|
2436
3543
|
*/
|
|
2437
3544
|
get translation(): number;
|
|
3545
|
+
|
|
2438
3546
|
/**
|
|
2439
3547
|
* Whether the joint's translation limits are enabled.
|
|
2440
3548
|
* @default false
|
|
2441
3549
|
*/
|
|
2442
3550
|
get limitsEnabled(): boolean;
|
|
2443
3551
|
set limitsEnabled(val: boolean);
|
|
3552
|
+
|
|
2444
3553
|
/**
|
|
2445
3554
|
* The mathematical lower limit of translation.
|
|
2446
3555
|
* @readonly
|
|
2447
3556
|
*/
|
|
2448
3557
|
get lowerLimit(): number;
|
|
3558
|
+
|
|
2449
3559
|
/**
|
|
2450
3560
|
* The mathematical upper limit of translation.
|
|
2451
3561
|
* @readonly
|
|
2452
3562
|
*/
|
|
2453
3563
|
get upperLimit(): number;
|
|
3564
|
+
|
|
2454
3565
|
/**
|
|
2455
3566
|
* Accepts a number to set a symmetric range
|
|
2456
3567
|
* or an array with the lower and upper translation limits.
|
|
2457
3568
|
*/
|
|
2458
3569
|
set range(val: [number, number] | number);
|
|
3570
|
+
|
|
2459
3571
|
/**
|
|
2460
3572
|
* Whether spring behavior is enabled.
|
|
2461
3573
|
* @default false
|
|
2462
3574
|
*/
|
|
2463
3575
|
get springEnabled(): boolean;
|
|
2464
3576
|
set springEnabled(val: boolean);
|
|
3577
|
+
|
|
2465
3578
|
/**
|
|
2466
3579
|
* The springiness of the joint, a 0-1 ratio.
|
|
2467
3580
|
*
|
|
@@ -2470,35 +3583,41 @@ declare global {
|
|
|
2470
3583
|
*/
|
|
2471
3584
|
get springiness(): number;
|
|
2472
3585
|
set springiness(val: number);
|
|
3586
|
+
|
|
2473
3587
|
/**
|
|
2474
3588
|
* Damping ratio, 0-1. Higher values reduce oscillation faster.
|
|
2475
3589
|
* @default 0
|
|
2476
3590
|
*/
|
|
2477
3591
|
get damping(): number;
|
|
2478
3592
|
set damping(val: number);
|
|
3593
|
+
|
|
2479
3594
|
/**
|
|
2480
3595
|
* Whether the joint's motor is enabled.
|
|
2481
3596
|
* @default true
|
|
2482
3597
|
*/
|
|
2483
3598
|
get motorEnabled(): boolean;
|
|
2484
3599
|
set motorEnabled(val: boolean);
|
|
3600
|
+
|
|
2485
3601
|
/**
|
|
2486
3602
|
* Motor speed.
|
|
2487
3603
|
* @default 0
|
|
2488
3604
|
*/
|
|
2489
3605
|
get speed(): number;
|
|
2490
3606
|
set speed(val: number);
|
|
3607
|
+
|
|
2491
3608
|
/**
|
|
2492
3609
|
* Maximum force the motor can apply.
|
|
2493
3610
|
* @default 10
|
|
2494
3611
|
*/
|
|
2495
3612
|
get maxPower(): number;
|
|
2496
3613
|
set maxPower(val: number);
|
|
3614
|
+
|
|
2497
3615
|
/**
|
|
2498
3616
|
* The current motor force being applied.
|
|
2499
3617
|
* @readonly
|
|
2500
3618
|
*/
|
|
2501
3619
|
get power(): number;
|
|
3620
|
+
|
|
2502
3621
|
/**
|
|
2503
3622
|
* The current sliding speed of the joint.
|
|
2504
3623
|
* @readonly
|
|
@@ -2515,16 +3634,19 @@ declare global {
|
|
|
2515
3634
|
* @param sprite the sprite to grab
|
|
2516
3635
|
*/
|
|
2517
3636
|
constructor(pointer: any, sprite: Sprite);
|
|
3637
|
+
|
|
2518
3638
|
/**
|
|
2519
3639
|
* The sprite being grabbed by the joint.
|
|
2520
3640
|
*/
|
|
2521
3641
|
sprite: Sprite;
|
|
3642
|
+
|
|
2522
3643
|
/**
|
|
2523
3644
|
* The target position of the joint that the sprite will be
|
|
2524
3645
|
* moved towards. Can be a coordinate array or object with x and y properties.
|
|
2525
3646
|
*/
|
|
2526
3647
|
get target(): any;
|
|
2527
3648
|
set target(pos: any);
|
|
3649
|
+
|
|
2528
3650
|
/**
|
|
2529
3651
|
* The maximum spring force that the joint can exert on the sprite.
|
|
2530
3652
|
*
|
|
@@ -2532,6 +3654,7 @@ declare global {
|
|
|
2532
3654
|
*/
|
|
2533
3655
|
get maxForce(): number;
|
|
2534
3656
|
set maxForce(val: number);
|
|
3657
|
+
|
|
2535
3658
|
/**
|
|
2536
3659
|
* The maximum torque that the joint can exert on the sprite.
|
|
2537
3660
|
*
|
|
@@ -2542,6 +3665,30 @@ declare global {
|
|
|
2542
3665
|
set maxTorque(val: number);
|
|
2543
3666
|
}
|
|
2544
3667
|
|
|
3668
|
+
class CastInfo {
|
|
3669
|
+
/**
|
|
3670
|
+
* The sprite that was hit by the ray or circle cast.
|
|
3671
|
+
*/
|
|
3672
|
+
sprite: Sprite;
|
|
3673
|
+
|
|
3674
|
+
/**
|
|
3675
|
+
* The distance from the start of the cast to the intersection point.
|
|
3676
|
+
*/
|
|
3677
|
+
distance: number;
|
|
3678
|
+
|
|
3679
|
+
/**
|
|
3680
|
+
* The intersection point of the cast with the sprite's shape.
|
|
3681
|
+
* @readonly
|
|
3682
|
+
*/
|
|
3683
|
+
get intersect(): { x: number; y: number };
|
|
3684
|
+
|
|
3685
|
+
/**
|
|
3686
|
+
* The angle of incidence of the cast at the intersection point.
|
|
3687
|
+
* @readonly
|
|
3688
|
+
*/
|
|
3689
|
+
get incidence(): number;
|
|
3690
|
+
}
|
|
3691
|
+
|
|
2545
3692
|
class Scale {
|
|
2546
3693
|
valueOf(): number;
|
|
2547
3694
|
}
|
|
@@ -2566,16 +3713,19 @@ declare global {
|
|
|
2566
3713
|
* @default 12
|
|
2567
3714
|
*/
|
|
2568
3715
|
holdThreshold: number;
|
|
3716
|
+
|
|
2569
3717
|
/**
|
|
2570
3718
|
* @param inp
|
|
2571
3719
|
* @returns true on the first frame that the user presses the input
|
|
2572
3720
|
*/
|
|
2573
3721
|
presses(inp?: string): boolean;
|
|
3722
|
+
|
|
2574
3723
|
/**
|
|
2575
3724
|
* @param inp
|
|
2576
3725
|
* @returns the amount of frames the user has been pressing the input
|
|
2577
3726
|
*/
|
|
2578
3727
|
pressing(inp?: string): number;
|
|
3728
|
+
|
|
2579
3729
|
/**
|
|
2580
3730
|
* Same as the `released` function, which is preferred.
|
|
2581
3731
|
* @deprecated
|
|
@@ -2583,21 +3733,25 @@ declare global {
|
|
|
2583
3733
|
* @returns true on the first frame that the user released the input
|
|
2584
3734
|
*/
|
|
2585
3735
|
pressed(inp?: string): boolean;
|
|
3736
|
+
|
|
2586
3737
|
/**
|
|
2587
3738
|
* @param inp
|
|
2588
3739
|
* @returns true on the first frame that the user holds the input
|
|
2589
3740
|
*/
|
|
2590
3741
|
holds(inp?: string): boolean;
|
|
3742
|
+
|
|
2591
3743
|
/**
|
|
2592
3744
|
* @param inp
|
|
2593
3745
|
* @returns the amount of frames the user has been holding the input
|
|
2594
3746
|
*/
|
|
2595
3747
|
holding(inp?: string): number;
|
|
3748
|
+
|
|
2596
3749
|
/**
|
|
2597
3750
|
* @param inp
|
|
2598
3751
|
* @returns true on the first frame that the user released a held input
|
|
2599
3752
|
*/
|
|
2600
3753
|
held(inp?: string): boolean;
|
|
3754
|
+
|
|
2601
3755
|
/**
|
|
2602
3756
|
* @param inp
|
|
2603
3757
|
* @returns true on the first frame that the user released the input
|
|
@@ -2611,91 +3765,104 @@ declare global {
|
|
|
2611
3765
|
* The mouse's x position in the world.
|
|
2612
3766
|
*/
|
|
2613
3767
|
x: number;
|
|
3768
|
+
|
|
2614
3769
|
/**
|
|
2615
3770
|
* The mouse's y position in the world.
|
|
2616
3771
|
*/
|
|
2617
3772
|
y: number;
|
|
2618
|
-
|
|
2619
|
-
* The mouse's absolute position on the canvas.
|
|
2620
|
-
* @property {Number} x
|
|
2621
|
-
* @property {Number} y
|
|
2622
|
-
*/
|
|
2623
|
-
canvasPos: { x: number; y: number };
|
|
3773
|
+
|
|
2624
3774
|
/**
|
|
2625
3775
|
* The mouse's left button.
|
|
2626
3776
|
*/
|
|
2627
3777
|
left: number;
|
|
3778
|
+
|
|
2628
3779
|
/**
|
|
2629
3780
|
* The mouse's center button.
|
|
2630
3781
|
*/
|
|
2631
3782
|
center: number;
|
|
3783
|
+
|
|
2632
3784
|
/**
|
|
2633
3785
|
* The mouse's right button.
|
|
2634
3786
|
*/
|
|
2635
3787
|
right: number;
|
|
3788
|
+
|
|
2636
3789
|
/**
|
|
2637
3790
|
* Contains the scroll status of the mouse wheel.
|
|
2638
3791
|
* @property {Number} x the horizontal scroll amount
|
|
2639
3792
|
* @property {Number} y the vertical scroll amount
|
|
2640
3793
|
*/
|
|
2641
3794
|
scrollDelta: { x: number; y: number };
|
|
3795
|
+
|
|
2642
3796
|
/**
|
|
2643
3797
|
* Contains the drag status of each of the mouse's buttons.
|
|
2644
3798
|
*/
|
|
2645
3799
|
drag: {};
|
|
3800
|
+
|
|
2646
3801
|
/**
|
|
2647
3802
|
* True if the mouse is currently on the canvas.
|
|
2648
3803
|
* @default false
|
|
2649
3804
|
*/
|
|
2650
3805
|
isOnCanvas: boolean;
|
|
3806
|
+
|
|
2651
3807
|
/**
|
|
2652
3808
|
* True if the mouse has ever interacted with the canvas.
|
|
2653
3809
|
* @default false
|
|
2654
3810
|
*/
|
|
2655
3811
|
isActive: boolean;
|
|
3812
|
+
|
|
2656
3813
|
/**
|
|
2657
|
-
*
|
|
3814
|
+
* Gets the mouse's current position in the world as a readonly object {x, y}
|
|
3815
|
+
* that won't updated if the mouse moves.
|
|
2658
3816
|
*/
|
|
2659
|
-
get pos(): {};
|
|
3817
|
+
get pos(): { x: number; y: number };
|
|
3818
|
+
|
|
2660
3819
|
/**
|
|
2661
|
-
* The mouse's position.
|
|
3820
|
+
* The mouse's current position.
|
|
2662
3821
|
*/
|
|
2663
|
-
get position(): {};
|
|
3822
|
+
get position(): { x: number; y: number };
|
|
3823
|
+
|
|
2664
3824
|
/**
|
|
2665
3825
|
* The mouse's CSS cursor style.
|
|
2666
3826
|
* @default 'default'
|
|
2667
3827
|
*/
|
|
2668
3828
|
get cursor(): string;
|
|
2669
3829
|
set cursor(val: string);
|
|
3830
|
+
|
|
2670
3831
|
/**
|
|
2671
3832
|
* Controls whether the mouse is visible or not.
|
|
2672
3833
|
* @default true
|
|
2673
3834
|
*/
|
|
2674
3835
|
get visible(): boolean;
|
|
2675
3836
|
set visible(val: boolean);
|
|
3837
|
+
|
|
2676
3838
|
/**
|
|
2677
3839
|
* @param inp
|
|
2678
3840
|
* @returns true on the first frame that the user moves the mouse while pressing the input
|
|
2679
3841
|
*/
|
|
2680
3842
|
drags(inp?: string): boolean;
|
|
3843
|
+
|
|
2681
3844
|
/**
|
|
2682
3845
|
* @param inp
|
|
2683
3846
|
* @returns the amount of frames the user has been moving the mouse while pressing the input
|
|
2684
3847
|
*/
|
|
2685
3848
|
dragging(inp?: string): number;
|
|
3849
|
+
|
|
2686
3850
|
/**
|
|
2687
3851
|
* @param inp
|
|
2688
3852
|
* @returns true on the first frame that the user releases the input after dragging the mouse
|
|
2689
3853
|
*/
|
|
2690
3854
|
dragged(inp?: string): boolean;
|
|
3855
|
+
|
|
2691
3856
|
/**
|
|
2692
3857
|
* @returns true on the first frame that the user scrolls the mouse wheel
|
|
2693
3858
|
*/
|
|
2694
3859
|
scrolls(): boolean;
|
|
3860
|
+
|
|
2695
3861
|
/**
|
|
2696
3862
|
* @returns the amount of frames the user has been scrolling the mouse wheel
|
|
2697
3863
|
*/
|
|
2698
3864
|
scrolling(): number;
|
|
3865
|
+
|
|
2699
3866
|
/**
|
|
2700
3867
|
* @returns true on the first frame that the user stops scrolling the mouse wheel
|
|
2701
3868
|
*/
|
|
@@ -2704,26 +3871,32 @@ declare global {
|
|
|
2704
3871
|
|
|
2705
3872
|
class _Pointer extends InputDevice {
|
|
2706
3873
|
constructor(pointer: any);
|
|
3874
|
+
|
|
2707
3875
|
/**
|
|
2708
3876
|
* The pointer's x position in the physics world.
|
|
2709
3877
|
*/
|
|
2710
3878
|
x: number;
|
|
3879
|
+
|
|
2711
3880
|
/**
|
|
2712
3881
|
* The pointer's y position in the physics world.
|
|
2713
3882
|
*/
|
|
2714
3883
|
y: number;
|
|
3884
|
+
|
|
2715
3885
|
/**
|
|
2716
3886
|
* The pointer's unique identifier.
|
|
2717
3887
|
*/
|
|
2718
3888
|
id: number;
|
|
3889
|
+
|
|
2719
3890
|
/**
|
|
2720
3891
|
* The amount of frames the pointer has been active for.
|
|
2721
3892
|
*/
|
|
2722
3893
|
duration: number;
|
|
3894
|
+
|
|
2723
3895
|
/**
|
|
2724
3896
|
* The pointer's absolute position on the canvas.
|
|
2725
3897
|
*/
|
|
2726
3898
|
canvasPos: { x: number; y: number };
|
|
3899
|
+
|
|
2727
3900
|
/**
|
|
2728
3901
|
* The pointer's pressure level, from 0 to 1.
|
|
2729
3902
|
*
|
|
@@ -2731,33 +3904,40 @@ declare global {
|
|
|
2731
3904
|
* the value is 0.5 when the pointer is pressing.
|
|
2732
3905
|
*/
|
|
2733
3906
|
pressure: number;
|
|
3907
|
+
|
|
2734
3908
|
/**
|
|
2735
3909
|
* The amount of frames the user has been clicking, touching,
|
|
2736
3910
|
* or drawing on the screen with the pointer.
|
|
2737
3911
|
*/
|
|
2738
3912
|
press: number;
|
|
3913
|
+
|
|
2739
3914
|
/**
|
|
2740
3915
|
* @returns true on the first frame that the pointer grabs a sprite
|
|
2741
3916
|
*/
|
|
2742
3917
|
grabs(): boolean;
|
|
3918
|
+
|
|
2743
3919
|
/**
|
|
2744
3920
|
* @returns the amount of frames the pointer has been grabbing a sprite
|
|
2745
3921
|
*/
|
|
2746
3922
|
grabbing(): number;
|
|
3923
|
+
|
|
2747
3924
|
/**
|
|
2748
3925
|
* @returns true on the first frame that the pointer releases a grabbed sprite
|
|
2749
3926
|
*/
|
|
2750
3927
|
grabbed(): boolean;
|
|
3928
|
+
|
|
2751
3929
|
/**
|
|
2752
3930
|
* @param sprite
|
|
2753
3931
|
* @returns true on the first frame that the pointer overlaps the sprite
|
|
2754
3932
|
*/
|
|
2755
3933
|
overlaps(sprite: Sprite): boolean;
|
|
3934
|
+
|
|
2756
3935
|
/**
|
|
2757
3936
|
* @param sprite
|
|
2758
3937
|
* @returns the amount of frames the pointer has been overlapping the sprite
|
|
2759
3938
|
*/
|
|
2760
3939
|
overlapping(sprite: Sprite): number;
|
|
3940
|
+
|
|
2761
3941
|
/**
|
|
2762
3942
|
* @param sprite
|
|
2763
3943
|
* @returns true on the first frame that the pointer stops overlapping the sprite
|
|
@@ -2805,29 +3985,35 @@ declare global {
|
|
|
2805
3985
|
b: number;
|
|
2806
3986
|
x: number;
|
|
2807
3987
|
y: number;
|
|
3988
|
+
|
|
2808
3989
|
/**
|
|
2809
3990
|
* Left shoulder button.
|
|
2810
3991
|
*/
|
|
2811
3992
|
l: number;
|
|
3993
|
+
|
|
2812
3994
|
/**
|
|
2813
3995
|
* Right shoulder button.
|
|
2814
3996
|
*/
|
|
2815
3997
|
r: number;
|
|
3998
|
+
|
|
2816
3999
|
/**
|
|
2817
4000
|
* Digital left trigger.
|
|
2818
4001
|
*/
|
|
2819
4002
|
lt: number;
|
|
4003
|
+
|
|
2820
4004
|
/**
|
|
2821
4005
|
* Digital right trigger.
|
|
2822
4006
|
*/
|
|
2823
4007
|
rt: number;
|
|
2824
4008
|
select: number;
|
|
2825
4009
|
start: number;
|
|
4010
|
+
|
|
2826
4011
|
/**
|
|
2827
4012
|
* Left stick button.
|
|
2828
4013
|
* Activated by pressing down on the left analog stick.
|
|
2829
4014
|
*/
|
|
2830
4015
|
lsb: number;
|
|
4016
|
+
|
|
2831
4017
|
/**
|
|
2832
4018
|
* Right stick button.
|
|
2833
4019
|
* Activated by pressing down on the right analog stick.
|
|
@@ -2837,6 +4023,7 @@ declare global {
|
|
|
2837
4023
|
down: number;
|
|
2838
4024
|
left: number;
|
|
2839
4025
|
right: number;
|
|
4026
|
+
|
|
2840
4027
|
/**
|
|
2841
4028
|
* Has x and y properties with -1 to 1 values which
|
|
2842
4029
|
* represent the position of the left analog stick.
|
|
@@ -2844,6 +4031,7 @@ declare global {
|
|
|
2844
4031
|
* {x: 0, y: 0} is the center position.
|
|
2845
4032
|
*/
|
|
2846
4033
|
leftStick: any;
|
|
4034
|
+
|
|
2847
4035
|
/**
|
|
2848
4036
|
* Has x and y properties with -1 to 1 values which
|
|
2849
4037
|
* represent the position of the right analog stick.
|
|
@@ -2851,30 +4039,36 @@ declare global {
|
|
|
2851
4039
|
* {x: 0, y: 0} is the center position.
|
|
2852
4040
|
*/
|
|
2853
4041
|
rightStick: any;
|
|
4042
|
+
|
|
2854
4043
|
/**
|
|
2855
4044
|
* Analog value 0-1 of the left trigger.
|
|
2856
4045
|
* @default 0
|
|
2857
4046
|
*/
|
|
2858
4047
|
leftTrigger: number;
|
|
4048
|
+
|
|
2859
4049
|
/**
|
|
2860
4050
|
* Analog value 0-1 of the right trigger.
|
|
2861
4051
|
* @default 0
|
|
2862
4052
|
*/
|
|
2863
4053
|
rightTrigger: number;
|
|
4054
|
+
|
|
2864
4055
|
/**
|
|
2865
4056
|
* Button names are mapped to `gamepad.buttons` indices.
|
|
2866
4057
|
*/
|
|
2867
4058
|
buttonMapping: any;
|
|
4059
|
+
|
|
2868
4060
|
/**
|
|
2869
4061
|
* Sticks and triggers are mapped to `gamepad.axes` indices.
|
|
2870
4062
|
*/
|
|
2871
4063
|
axeMapping: any;
|
|
4064
|
+
|
|
2872
4065
|
/**
|
|
2873
4066
|
* If the controller is a mock controller.
|
|
2874
4067
|
*/
|
|
2875
4068
|
isMock: boolean;
|
|
2876
4069
|
gamepad: Gamepad;
|
|
2877
4070
|
id: any;
|
|
4071
|
+
|
|
2878
4072
|
/**
|
|
2879
4073
|
* True if the controller has analog triggers.
|
|
2880
4074
|
* False if the controller has digital (button) triggers.
|
|
@@ -2884,67 +4078,81 @@ declare global {
|
|
|
2884
4078
|
get circle(): number;
|
|
2885
4079
|
get square(): number;
|
|
2886
4080
|
get triangle(): number;
|
|
4081
|
+
|
|
2887
4082
|
/**
|
|
2888
4083
|
* Alias for `leftStick`.
|
|
2889
4084
|
*/
|
|
2890
4085
|
get ls(): any;
|
|
4086
|
+
|
|
2891
4087
|
/**
|
|
2892
4088
|
* Alias for `rightStick`.
|
|
2893
4089
|
*/
|
|
2894
4090
|
get rs(): any;
|
|
4091
|
+
|
|
2895
4092
|
/**
|
|
2896
4093
|
* Alias for `l` (left shoulder button).
|
|
2897
4094
|
* `lb` is what it's called on Xbox controllers.
|
|
2898
4095
|
*/
|
|
2899
4096
|
get lb(): number;
|
|
4097
|
+
|
|
2900
4098
|
/**
|
|
2901
4099
|
* Alias for `r` (right shoulder button).
|
|
2902
4100
|
* `rb` is what it's called on Xbox controllers.
|
|
2903
4101
|
*/
|
|
2904
4102
|
get rb(): number;
|
|
4103
|
+
|
|
2905
4104
|
/**
|
|
2906
4105
|
* Alias for `l` (left shoulder button).
|
|
2907
4106
|
* `l1` is what it's called on PlayStation controllers.
|
|
2908
4107
|
*/
|
|
2909
4108
|
get l1(): number;
|
|
4109
|
+
|
|
2910
4110
|
/**
|
|
2911
4111
|
* Alias for `r` (right shoulder button).
|
|
2912
4112
|
* `r1` is what it's called on PlayStation controllers.
|
|
2913
4113
|
*/
|
|
2914
4114
|
get r1(): number;
|
|
4115
|
+
|
|
2915
4116
|
/**
|
|
2916
4117
|
* Alias for `lt` (digital left trigger).
|
|
2917
4118
|
* `zl` is what it's called on Nintendo controllers.
|
|
2918
4119
|
*/
|
|
2919
4120
|
get zl(): number;
|
|
4121
|
+
|
|
2920
4122
|
/**
|
|
2921
4123
|
* Alias for `rt` (digital right trigger).
|
|
2922
4124
|
* `zr` is what it's called on Nintendo controllers.
|
|
2923
4125
|
*/
|
|
2924
4126
|
get zr(): number;
|
|
4127
|
+
|
|
2925
4128
|
/**
|
|
2926
4129
|
* Alias for `leftTrigger` (analog left trigger).
|
|
2927
4130
|
* `l2` is what it's called on PlayStation controllers.
|
|
2928
4131
|
*/
|
|
2929
4132
|
get l2(): number;
|
|
4133
|
+
|
|
2930
4134
|
/**
|
|
2931
4135
|
* Alias for `rightTrigger` (analog right trigger).
|
|
2932
4136
|
* `r2` is what it's called on PlayStation controllers.
|
|
2933
4137
|
*/
|
|
2934
4138
|
get r2(): number;
|
|
4139
|
+
|
|
2935
4140
|
/**
|
|
2936
4141
|
* Verbose alias for `lsb`.
|
|
2937
4142
|
*/
|
|
2938
4143
|
get leftStickButton(): number;
|
|
4144
|
+
|
|
2939
4145
|
/**
|
|
2940
4146
|
* Verbose alias for `rsb`.
|
|
2941
4147
|
*/
|
|
2942
4148
|
get rightStickButton(): number;
|
|
4149
|
+
|
|
2943
4150
|
/**
|
|
2944
4151
|
* Alias for `lsb` (left stick button).
|
|
2945
4152
|
* `l3` is what it's called on PlayStation controllers.
|
|
2946
4153
|
*/
|
|
2947
4154
|
get l3(): number;
|
|
4155
|
+
|
|
2948
4156
|
/**
|
|
2949
4157
|
* Alias for `rsb` (right stick button).
|
|
2950
4158
|
* `r3` is what it's called on PlayStation controllers.
|
|
@@ -2959,12 +4167,14 @@ declare global {
|
|
|
2959
4167
|
* triggers, and sticks on game controllers.
|
|
2960
4168
|
*/
|
|
2961
4169
|
constructor();
|
|
4170
|
+
|
|
2962
4171
|
/**
|
|
2963
4172
|
* Swap controller positions in this controllers array.
|
|
2964
4173
|
* @param indexA
|
|
2965
4174
|
* @param indexB
|
|
2966
4175
|
*/
|
|
2967
4176
|
swap(indexA: number, indexB: number): void;
|
|
4177
|
+
|
|
2968
4178
|
/**
|
|
2969
4179
|
* Removes a controller from this controllers array
|
|
2970
4180
|
* by setting `contros[index] = null`.
|
|
@@ -2973,6 +4183,7 @@ declare global {
|
|
|
2973
4183
|
* @param index
|
|
2974
4184
|
*/
|
|
2975
4185
|
remove(index: number): void;
|
|
4186
|
+
|
|
2976
4187
|
/**
|
|
2977
4188
|
* Runs when a controller is connected. By default it
|
|
2978
4189
|
* always returns true. Overwrite this function to customize
|
|
@@ -2987,6 +4198,7 @@ declare global {
|
|
|
2987
4198
|
* @returns true if the controller should be added to this q5play controllers array
|
|
2988
4199
|
*/
|
|
2989
4200
|
onConnect(gamepad: Gamepad): boolean;
|
|
4201
|
+
|
|
2990
4202
|
/**
|
|
2991
4203
|
* Runs when a controller is disconnected. by default it
|
|
2992
4204
|
* always returns false. Overwrite this function to customize
|
|
@@ -3002,10 +4214,20 @@ declare global {
|
|
|
3002
4214
|
onDisconnect(gamepad: Gamepad): boolean;
|
|
3003
4215
|
}
|
|
3004
4216
|
|
|
3005
|
-
function colorPal(c: string, palette:
|
|
4217
|
+
function colorPal(c: string, palette: { [key: string]: string } | string[]): string;
|
|
3006
4218
|
function EmojiImage(emoji: string, textSize: number): Q5.Image;
|
|
3007
|
-
function spriteArt(txt: string, scale: number, palette:
|
|
3008
|
-
|
|
4219
|
+
function spriteArt(txt: string, scale: number, palette: { [key: string]: string } | string[]): Q5.Image;
|
|
4220
|
+
|
|
4221
|
+
/**
|
|
4222
|
+
* Draws an animation.
|
|
4223
|
+
* @param ani the animation
|
|
4224
|
+
* @param x x coordinate to draw the animation at
|
|
4225
|
+
* @param y y coordinate to draw the animation at
|
|
4226
|
+
* @param dW display width
|
|
4227
|
+
* @param dH display height
|
|
4228
|
+
*/
|
|
4229
|
+
function animation(ani: Ani, x: number, y: number, dW: number, dH: number): void;
|
|
4230
|
+
|
|
3009
4231
|
/**
|
|
3010
4232
|
* @param milliseconds if not specified, delays until the next frame draw
|
|
3011
4233
|
* @returns resolves after the delay
|