litecanvas 0.40.0 → 0.41.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/README.md +20 -16
- package/dist/dist.js +168 -160
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +3 -3
- package/package.json +2 -2
- package/src/index.js +197 -218
- package/src/palette.js +1 -1
- package/src/sounds.js +1 -1
- package/src/types.js +4 -11
- package/src/zzfx.js +7 -7
- package/types/index.d.ts +29 -71
- package/types/types.d.ts +25 -90
package/src/types.js
CHANGED
|
@@ -7,12 +7,10 @@
|
|
|
7
7
|
* @property {number} [height]
|
|
8
8
|
* @property {boolean} [autoscale=true]
|
|
9
9
|
* @property {boolean} [pixelart=false]
|
|
10
|
-
* @property {number} [background]
|
|
11
10
|
* @property {boolean} [antialias=true]
|
|
12
11
|
* @property {string} [canvas]
|
|
13
12
|
* @property {boolean} [global=true]
|
|
14
13
|
* @property {boolean} [tapEvents=true]
|
|
15
|
-
* @property {boolean} [useMouse=false]
|
|
16
14
|
* @property {LitecanvasGameLoop} [loop]
|
|
17
15
|
*/
|
|
18
16
|
|
|
@@ -28,15 +26,10 @@
|
|
|
28
26
|
* @property {(dt: number) => void} [update]
|
|
29
27
|
* @property {() => void} [draw]
|
|
30
28
|
* @property {() => void} [resized]
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* @
|
|
35
|
-
* @type {object}
|
|
36
|
-
* @property {Function[]} init
|
|
37
|
-
* @property {Function[]} update
|
|
38
|
-
* @property {Function[]} draw
|
|
39
|
-
* @property {Function[]} resized
|
|
29
|
+
* @property {(x: number, y: number, id: number) => void} [tap]
|
|
30
|
+
* @property {(x: number, y: number, id: number) => void} [untap]
|
|
31
|
+
* @property {(x: number, y: number, id: number) => void} [tapping]
|
|
32
|
+
* @property {(x: number, y: number, id: number) => void} [tapped]
|
|
40
33
|
*/
|
|
41
34
|
|
|
42
35
|
/**
|
package/src/zzfx.js
CHANGED
|
@@ -22,7 +22,7 @@ zzfx = (
|
|
|
22
22
|
w = 1,
|
|
23
23
|
m = 0,
|
|
24
24
|
B = 0,
|
|
25
|
-
N = 0
|
|
25
|
+
N = 0
|
|
26
26
|
) => {
|
|
27
27
|
let M = Math,
|
|
28
28
|
d = 2 * M.PI,
|
|
@@ -80,12 +80,12 @@ zzfx = (
|
|
|
80
80
|
(a < e
|
|
81
81
|
? a / e
|
|
82
82
|
: a < e + m
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
? 1 - ((a - e) / m) * (1 - w)
|
|
84
|
+
: a < e + m + r
|
|
85
|
+
? w
|
|
86
|
+
: a < h - c
|
|
87
|
+
? ((h - a - c) / t) * w
|
|
88
|
+
: 0)),
|
|
89
89
|
(f = c
|
|
90
90
|
? f / 2 +
|
|
91
91
|
(c > a
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The litecanvas constructor
|
|
3
3
|
*/
|
|
4
4
|
export default function litecanvas(
|
|
5
|
-
settings?: LitecanvasOptions
|
|
5
|
+
settings?: LitecanvasOptions
|
|
6
6
|
): LitecanvasInstance
|
|
7
7
|
|
|
8
8
|
declare global {
|
|
@@ -14,20 +14,10 @@ declare global {
|
|
|
14
14
|
var HEIGHT: number
|
|
15
15
|
/** The game canvas HTML element */
|
|
16
16
|
var CANVAS: HTMLCanvasElement
|
|
17
|
-
/** `true` when the game screen is touched/clicked */
|
|
18
|
-
var TAPPED: boolean
|
|
19
|
-
/** `true` while the screen is being touched/clicked (holding) */
|
|
20
|
-
var TAPPING: boolean
|
|
21
|
-
/** the tap/click X position */
|
|
22
|
-
var TAPX: number
|
|
23
|
-
/** the tap/click Y position */
|
|
24
|
-
var TAPY: number
|
|
25
17
|
/** the amount of time (in seconds) since the game started */
|
|
26
18
|
var ELAPSED: number
|
|
27
19
|
/** the FPS meter */
|
|
28
20
|
var FPS: number
|
|
29
|
-
/** the fixed delta time */
|
|
30
|
-
var DT: number
|
|
31
21
|
/** the center X of the game screen */
|
|
32
22
|
var CENTERX: number
|
|
33
23
|
/** the center Y of the game screen */
|
|
@@ -111,7 +101,7 @@ declare global {
|
|
|
111
101
|
max1: number,
|
|
112
102
|
min2: number,
|
|
113
103
|
max2: number,
|
|
114
|
-
withinBounds?: boolean
|
|
104
|
+
withinBounds?: boolean
|
|
115
105
|
): number
|
|
116
106
|
/**
|
|
117
107
|
* Maps a number from one range to a value between 0 and 1.
|
|
@@ -122,13 +112,6 @@ declare global {
|
|
|
122
112
|
* @returns {number} the normalized number.
|
|
123
113
|
*/
|
|
124
114
|
function norm(value: number, min: number, max: number): number
|
|
125
|
-
/**
|
|
126
|
-
* Returns the fractional part of a number
|
|
127
|
-
*
|
|
128
|
-
* @param {number} value The number
|
|
129
|
-
* @returns {number}
|
|
130
|
-
*/
|
|
131
|
-
function fract(value: number): number
|
|
132
115
|
/**
|
|
133
116
|
* Returns the sine of a number in radians
|
|
134
117
|
*/
|
|
@@ -220,13 +203,7 @@ declare global {
|
|
|
220
203
|
* @param {number|null} color The background color (from 0 to 7) or null
|
|
221
204
|
*/
|
|
222
205
|
function cls(color: number | null): void
|
|
223
|
-
|
|
224
|
-
* Clear the game screen
|
|
225
|
-
* alias of `cls()`
|
|
226
|
-
*
|
|
227
|
-
* @param {number|null} color The background color (from 0 to 7) or null
|
|
228
|
-
*/
|
|
229
|
-
function clear(color: number | null): void
|
|
206
|
+
|
|
230
207
|
/**
|
|
231
208
|
* Draw a rectangle outline
|
|
232
209
|
*
|
|
@@ -243,7 +220,7 @@ declare global {
|
|
|
243
220
|
width: number,
|
|
244
221
|
height: number,
|
|
245
222
|
color?: number,
|
|
246
|
-
radii?: number | number[]
|
|
223
|
+
radii?: number | number[]
|
|
247
224
|
): void
|
|
248
225
|
/**
|
|
249
226
|
* Draw a color-filled rectangle
|
|
@@ -261,7 +238,7 @@ declare global {
|
|
|
261
238
|
width: number,
|
|
262
239
|
height: number,
|
|
263
240
|
color?: number,
|
|
264
|
-
radii?: number | number[]
|
|
241
|
+
radii?: number | number[]
|
|
265
242
|
): void
|
|
266
243
|
/**
|
|
267
244
|
* Draw a circle outline
|
|
@@ -284,7 +261,7 @@ declare global {
|
|
|
284
261
|
x: number,
|
|
285
262
|
y: number,
|
|
286
263
|
radius: number,
|
|
287
|
-
color?: number
|
|
264
|
+
color?: number
|
|
288
265
|
): void
|
|
289
266
|
/**
|
|
290
267
|
* Draw a line
|
|
@@ -300,7 +277,7 @@ declare global {
|
|
|
300
277
|
y1: number,
|
|
301
278
|
x2: number,
|
|
302
279
|
y2: number,
|
|
303
|
-
color?: number
|
|
280
|
+
color?: number
|
|
304
281
|
): void
|
|
305
282
|
/**
|
|
306
283
|
* Sets the thickness of lines
|
|
@@ -318,22 +295,7 @@ declare global {
|
|
|
318
295
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
319
296
|
*/
|
|
320
297
|
function linedash(segments: number | number[], offset?: number): void
|
|
321
|
-
|
|
322
|
-
* Determines the shape used to draw the end points of lines
|
|
323
|
-
* Possible values are: "butt", "round" or "square"
|
|
324
|
-
*
|
|
325
|
-
* @param {string} value
|
|
326
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap
|
|
327
|
-
*/
|
|
328
|
-
function linecap(value: string): void
|
|
329
|
-
/**
|
|
330
|
-
* Determines the shape used to join two line segments where they meet
|
|
331
|
-
* Possible values are: "round", "bevel", and "miter"
|
|
332
|
-
*
|
|
333
|
-
* @param {string} value
|
|
334
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
|
|
335
|
-
*/
|
|
336
|
-
function linejoin(value: string): void
|
|
298
|
+
|
|
337
299
|
/** TEXT RENDERING API */
|
|
338
300
|
/**
|
|
339
301
|
* Draw text
|
|
@@ -344,16 +306,6 @@ declare global {
|
|
|
344
306
|
* @param {number} [color=3] the color index (generally from 0 to 7)
|
|
345
307
|
*/
|
|
346
308
|
function text(x: number, y: number, text: string, color?: number): void
|
|
347
|
-
/**
|
|
348
|
-
* Draw text
|
|
349
|
-
* alias of `text()`
|
|
350
|
-
*
|
|
351
|
-
* @param {number} x
|
|
352
|
-
* @param {number} y
|
|
353
|
-
* @param {string} text the text message
|
|
354
|
-
* @param {number} [color=3] the color index (generally from 0 to 7)
|
|
355
|
-
*/
|
|
356
|
-
function print(x: number, y: number, text: string, color?: number): void
|
|
357
309
|
/**
|
|
358
310
|
* Set the font family
|
|
359
311
|
*
|
|
@@ -401,7 +353,7 @@ declare global {
|
|
|
401
353
|
function image(
|
|
402
354
|
x: number,
|
|
403
355
|
y: number,
|
|
404
|
-
image: OffscreenCanvas | HTMLImageElement | HTMLCanvasElement
|
|
356
|
+
image: OffscreenCanvas | HTMLImageElement | HTMLCanvasElement
|
|
405
357
|
): void
|
|
406
358
|
/**
|
|
407
359
|
* Creates a offscreen canvas to draw on it
|
|
@@ -419,7 +371,7 @@ declare global {
|
|
|
419
371
|
draw: string[] | drawCallback,
|
|
420
372
|
options?: {
|
|
421
373
|
scale?: number
|
|
422
|
-
}
|
|
374
|
+
}
|
|
423
375
|
): OffscreenCanvas
|
|
424
376
|
/** ADVANCED GRAPHICS API */
|
|
425
377
|
/**
|
|
@@ -477,7 +429,7 @@ declare global {
|
|
|
477
429
|
d: number,
|
|
478
430
|
e: number,
|
|
479
431
|
f: number,
|
|
480
|
-
resetFirst?: boolean
|
|
432
|
+
resetFirst?: boolean
|
|
481
433
|
): void
|
|
482
434
|
/**
|
|
483
435
|
* Sets the alpha (transparency) value to apply when drawing new shapes and images
|
|
@@ -545,14 +497,6 @@ declare global {
|
|
|
545
497
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
546
498
|
*/
|
|
547
499
|
function blendmode(value: string): void
|
|
548
|
-
/**
|
|
549
|
-
* Provides filter effects such as blurring and grayscaling.
|
|
550
|
-
* It is similar to the CSS filter property and accepts the same values.
|
|
551
|
-
*
|
|
552
|
-
* @param {string} effect
|
|
553
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter
|
|
554
|
-
*/
|
|
555
|
-
function filter(effect: string): void
|
|
556
500
|
/** SOUND API */
|
|
557
501
|
/**
|
|
558
502
|
* Play a defined sound or a ZzFX array of params
|
|
@@ -568,7 +512,7 @@ declare global {
|
|
|
568
512
|
sound?: number | number[],
|
|
569
513
|
volume?: number,
|
|
570
514
|
pitch?: number,
|
|
571
|
-
randomness?: number
|
|
515
|
+
randomness?: number
|
|
572
516
|
): AudioBufferSourceNode
|
|
573
517
|
/** UTILS API */
|
|
574
518
|
/**
|
|
@@ -592,7 +536,7 @@ declare global {
|
|
|
592
536
|
x2: number,
|
|
593
537
|
y2: number,
|
|
594
538
|
w2: number,
|
|
595
|
-
h2: number
|
|
539
|
+
h2: number
|
|
596
540
|
): boolean
|
|
597
541
|
/**
|
|
598
542
|
* Check a collision between two circles
|
|
@@ -611,8 +555,15 @@ declare global {
|
|
|
611
555
|
r1: number,
|
|
612
556
|
x2: number,
|
|
613
557
|
y2: number,
|
|
614
|
-
r2: number
|
|
558
|
+
r2: number
|
|
615
559
|
): boolean
|
|
560
|
+
/**
|
|
561
|
+
* Get the mouse position
|
|
562
|
+
*
|
|
563
|
+
* @returns number[]
|
|
564
|
+
*/
|
|
565
|
+
function mousepos(): number[]
|
|
566
|
+
|
|
616
567
|
/** PLUGINS API */
|
|
617
568
|
/**
|
|
618
569
|
* Prepares a plugin to be loaded
|
|
@@ -631,8 +582,15 @@ declare global {
|
|
|
631
582
|
function listen(
|
|
632
583
|
event: string,
|
|
633
584
|
callback: Function,
|
|
634
|
-
highPriority?: boolean
|
|
585
|
+
highPriority?: boolean
|
|
635
586
|
): Function | null
|
|
587
|
+
/**
|
|
588
|
+
* Call all listeners attached to a game event
|
|
589
|
+
*
|
|
590
|
+
* @param {string} event The game event type
|
|
591
|
+
* @param {...any} args Arguments passed to all listeners
|
|
592
|
+
*/
|
|
593
|
+
function emit(event: string, ...args: any[]): void
|
|
636
594
|
/**
|
|
637
595
|
* Get the color value
|
|
638
596
|
*
|
package/types/types.d.ts
CHANGED
|
@@ -5,20 +5,10 @@ type LitecanvasInstance = {
|
|
|
5
5
|
HEIGHT: number
|
|
6
6
|
/** The game canvas HTML element */
|
|
7
7
|
CANVAS: HTMLCanvasElement
|
|
8
|
-
/** `true` when the game screen is touched/clicked */
|
|
9
|
-
TAPPED: boolean
|
|
10
|
-
/** `true` while the screen is being touched/clicked (holding) */
|
|
11
|
-
TAPPING: boolean
|
|
12
|
-
/** the tap/click X position */
|
|
13
|
-
TAPX: number
|
|
14
|
-
/** the tap/click Y position */
|
|
15
|
-
TAPY: number
|
|
16
8
|
/** the amount of time (in seconds) since the game started */
|
|
17
9
|
ELAPSED: number
|
|
18
10
|
/** the FPS meter */
|
|
19
11
|
FPS: number
|
|
20
|
-
/** the fixed delta time */
|
|
21
|
-
DT: number
|
|
22
12
|
/** the center X of the game screen */
|
|
23
13
|
CENTERX: number
|
|
24
14
|
/** the center Y of the game screen */
|
|
@@ -102,7 +92,7 @@ type LitecanvasInstance = {
|
|
|
102
92
|
max1: number,
|
|
103
93
|
min2: number,
|
|
104
94
|
max2: number,
|
|
105
|
-
withinBounds?: boolean
|
|
95
|
+
withinBounds?: boolean
|
|
106
96
|
): number
|
|
107
97
|
/**
|
|
108
98
|
* Maps a number from one range to a value between 0 and 1.
|
|
@@ -113,13 +103,6 @@ type LitecanvasInstance = {
|
|
|
113
103
|
* @returns {number} the normalized number.
|
|
114
104
|
*/
|
|
115
105
|
norm(value: number, min: number, max: number): number
|
|
116
|
-
/**
|
|
117
|
-
* Returns the fractional part of a number
|
|
118
|
-
*
|
|
119
|
-
* @param {number} value The number
|
|
120
|
-
* @returns {number}
|
|
121
|
-
*/
|
|
122
|
-
fract(value: number): number
|
|
123
106
|
/**
|
|
124
107
|
* Returns the sine of a number in radians
|
|
125
108
|
*/
|
|
@@ -217,13 +200,6 @@ type LitecanvasInstance = {
|
|
|
217
200
|
* @param {number|null} color The background color (from 0 to 7) or null
|
|
218
201
|
*/
|
|
219
202
|
cls(color: number | null): void
|
|
220
|
-
/**
|
|
221
|
-
* Clear the game screen
|
|
222
|
-
* alias of `cls`
|
|
223
|
-
*
|
|
224
|
-
* @param {number|null} color The background color (from 0 to 7) or null
|
|
225
|
-
*/
|
|
226
|
-
clear(color: number | null): void
|
|
227
203
|
/**
|
|
228
204
|
* Draw a rectangle outline
|
|
229
205
|
*
|
|
@@ -240,7 +216,7 @@ type LitecanvasInstance = {
|
|
|
240
216
|
width: number,
|
|
241
217
|
height: number,
|
|
242
218
|
color?: number,
|
|
243
|
-
radii?: number | number[]
|
|
219
|
+
radii?: number | number[]
|
|
244
220
|
): void
|
|
245
221
|
/**
|
|
246
222
|
* Draw a color-filled rectangle
|
|
@@ -258,7 +234,7 @@ type LitecanvasInstance = {
|
|
|
258
234
|
width: number,
|
|
259
235
|
height: number,
|
|
260
236
|
color?: number,
|
|
261
|
-
radii?: number | number[]
|
|
237
|
+
radii?: number | number[]
|
|
262
238
|
): void
|
|
263
239
|
/**
|
|
264
240
|
* Draw a circle outline
|
|
@@ -304,22 +280,6 @@ type LitecanvasInstance = {
|
|
|
304
280
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset
|
|
305
281
|
*/
|
|
306
282
|
linedash(segments: number | number[], offset?: number): void
|
|
307
|
-
/**
|
|
308
|
-
* Determines the shape used to draw the end points of lines
|
|
309
|
-
* Possible values are: "butt", "round" or "square"
|
|
310
|
-
*
|
|
311
|
-
* @param {string} value
|
|
312
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineCap
|
|
313
|
-
*/
|
|
314
|
-
linecap(value: string): void
|
|
315
|
-
/**
|
|
316
|
-
* Determines the shape used to join two line segments where they meet
|
|
317
|
-
* Possible values are: "round", "bevel", and "miter"
|
|
318
|
-
*
|
|
319
|
-
* @param {string} value
|
|
320
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineJoin
|
|
321
|
-
*/
|
|
322
|
-
linejoin(value: string): void
|
|
323
283
|
|
|
324
284
|
/** TEXT RENDERING API */
|
|
325
285
|
/**
|
|
@@ -331,16 +291,6 @@ type LitecanvasInstance = {
|
|
|
331
291
|
* @param {number} [color=3] the color index (generally from 0 to 7)
|
|
332
292
|
*/
|
|
333
293
|
text(x: number, y: number, text: string, color?: number): void
|
|
334
|
-
/**
|
|
335
|
-
* Draw text
|
|
336
|
-
* alias of `text`
|
|
337
|
-
*
|
|
338
|
-
* @param {number} x
|
|
339
|
-
* @param {number} y
|
|
340
|
-
* @param {string} text the text message
|
|
341
|
-
* @param {number} [color=3] the color index (generally from 0 to 7)
|
|
342
|
-
*/
|
|
343
|
-
print(x: number, y: number, text: string, color?: number): void
|
|
344
294
|
/**
|
|
345
295
|
* Set the font family
|
|
346
296
|
*
|
|
@@ -389,7 +339,7 @@ type LitecanvasInstance = {
|
|
|
389
339
|
image(
|
|
390
340
|
x: number,
|
|
391
341
|
y: number,
|
|
392
|
-
image: OffscreenCanvas | HTMLImageElement | HTMLCanvasElement
|
|
342
|
+
image: OffscreenCanvas | HTMLImageElement | HTMLCanvasElement
|
|
393
343
|
): void
|
|
394
344
|
/**
|
|
395
345
|
* Creates a offscreen canvas to draw on it
|
|
@@ -407,7 +357,7 @@ type LitecanvasInstance = {
|
|
|
407
357
|
draw: string[] | drawCallback,
|
|
408
358
|
options?: {
|
|
409
359
|
scale?: number
|
|
410
|
-
}
|
|
360
|
+
}
|
|
411
361
|
): OffscreenCanvas
|
|
412
362
|
|
|
413
363
|
/** ADVANCED GRAPHICS API */
|
|
@@ -466,7 +416,7 @@ type LitecanvasInstance = {
|
|
|
466
416
|
d: number,
|
|
467
417
|
e: number,
|
|
468
418
|
f: number,
|
|
469
|
-
resetFirst?: boolean
|
|
419
|
+
resetFirst?: boolean
|
|
470
420
|
): void
|
|
471
421
|
/**
|
|
472
422
|
* Sets the alpha (transparency) value to apply when drawing new shapes and images
|
|
@@ -534,14 +484,6 @@ type LitecanvasInstance = {
|
|
|
534
484
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
535
485
|
*/
|
|
536
486
|
blendmode(value: string): void
|
|
537
|
-
/**
|
|
538
|
-
* Provides filter effects such as blurring and grayscaling.
|
|
539
|
-
* It is similar to the CSS filter property and accepts the same values.
|
|
540
|
-
*
|
|
541
|
-
* @param {string} effect
|
|
542
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/filter
|
|
543
|
-
*/
|
|
544
|
-
filter(effect: string): void
|
|
545
487
|
|
|
546
488
|
/** SOUND API */
|
|
547
489
|
/**
|
|
@@ -558,7 +500,7 @@ type LitecanvasInstance = {
|
|
|
558
500
|
sound?: number | number[],
|
|
559
501
|
volume?: number,
|
|
560
502
|
pitch?: number,
|
|
561
|
-
randomness?: number
|
|
503
|
+
randomness?: number
|
|
562
504
|
): AudioBufferSourceNode
|
|
563
505
|
|
|
564
506
|
/** UTILS API */
|
|
@@ -583,7 +525,7 @@ type LitecanvasInstance = {
|
|
|
583
525
|
x2: number,
|
|
584
526
|
y2: number,
|
|
585
527
|
w2: number,
|
|
586
|
-
h2: number
|
|
528
|
+
h2: number
|
|
587
529
|
): boolean
|
|
588
530
|
/**
|
|
589
531
|
* Check a collision between two circles
|
|
@@ -602,8 +544,14 @@ type LitecanvasInstance = {
|
|
|
602
544
|
r1: number,
|
|
603
545
|
x2: number,
|
|
604
546
|
y2: number,
|
|
605
|
-
r2: number
|
|
547
|
+
r2: number
|
|
606
548
|
): boolean
|
|
549
|
+
/**
|
|
550
|
+
* Get the mouse position
|
|
551
|
+
*
|
|
552
|
+
* @returns number[]
|
|
553
|
+
*/
|
|
554
|
+
mousepos(): number[]
|
|
607
555
|
|
|
608
556
|
/** PLUGINS API */
|
|
609
557
|
/**
|
|
@@ -623,8 +571,15 @@ type LitecanvasInstance = {
|
|
|
623
571
|
listen(
|
|
624
572
|
event: string,
|
|
625
573
|
callback: Function,
|
|
626
|
-
highPriority?: boolean
|
|
574
|
+
highPriority?: boolean
|
|
627
575
|
): Function | null
|
|
576
|
+
/**
|
|
577
|
+
* Call all listeners attached to a game event
|
|
578
|
+
*
|
|
579
|
+
* @param {string} event The game event type
|
|
580
|
+
* @param {...any} args Arguments passed to all listeners
|
|
581
|
+
*/
|
|
582
|
+
emit(event: string, ...args: any[]): void
|
|
628
583
|
/**
|
|
629
584
|
* Get the color value
|
|
630
585
|
*
|
|
@@ -674,11 +629,6 @@ type LitecanvasOptions = {
|
|
|
674
629
|
* If `true`, the pixel art images won't look blurry.
|
|
675
630
|
*/
|
|
676
631
|
pixelart?: boolean
|
|
677
|
-
/**
|
|
678
|
-
* By the game canvas is transparent.
|
|
679
|
-
* Set this option to a color index (from 0 to 7) to change the canvas background color.
|
|
680
|
-
*/
|
|
681
|
-
background?: number
|
|
682
632
|
/**
|
|
683
633
|
* If `false`, disable the canvas antialias.
|
|
684
634
|
*/
|
|
@@ -691,19 +641,11 @@ type LitecanvasOptions = {
|
|
|
691
641
|
* If `true` (default), all methods and properties of the engine will be exposed to the global scope (window).
|
|
692
642
|
*/
|
|
693
643
|
global?: boolean
|
|
694
|
-
|
|
695
|
-
/**
|
|
696
|
-
* By default, the litecanvas use only mouse or only touches (giving priority to the mouse).
|
|
697
|
-
* Set this option to `true` if you are having any troubles to detect your mouse
|
|
698
|
-
*/
|
|
699
|
-
useMouse?: boolean
|
|
700
|
-
|
|
701
644
|
/**
|
|
702
645
|
* if `false` disable the click/touch events handling.
|
|
703
646
|
* Useful when you want to implement your own input handler.
|
|
704
647
|
*/
|
|
705
648
|
tapEvents?: boolean
|
|
706
|
-
|
|
707
649
|
/**
|
|
708
650
|
* Specify your game loop callbacks.
|
|
709
651
|
* By default use that global functions (if they exist):
|
|
@@ -722,16 +664,9 @@ type LitecanvasGameLoop = {
|
|
|
722
664
|
resized?: () => void
|
|
723
665
|
}
|
|
724
666
|
|
|
725
|
-
type LitecanvasGameLoopListeners = {
|
|
726
|
-
init: Function[]
|
|
727
|
-
update: Function[]
|
|
728
|
-
draw: Function[]
|
|
729
|
-
resized: Function[]
|
|
730
|
-
}
|
|
731
|
-
|
|
732
667
|
type drawCallback = (
|
|
733
668
|
offcanvas: OffscreenCanvas,
|
|
734
|
-
context: CanvasRenderingContext2D
|
|
669
|
+
context: CanvasRenderingContext2D
|
|
735
670
|
) => void
|
|
736
671
|
|
|
737
672
|
type LitecanvasPluginHelpers = {
|
|
@@ -751,5 +686,5 @@ type LitecanvasPluginHelpers = {
|
|
|
751
686
|
|
|
752
687
|
type pluginCallback = (
|
|
753
688
|
instance: LitecanvasInstance,
|
|
754
|
-
helpers: LitecanvasPluginHelpers
|
|
689
|
+
helpers: LitecanvasPluginHelpers
|
|
755
690
|
) => any
|