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