littlejsengine 1.8.9 → 1.9.1
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 +17 -17
- package/build/littlejs.d.ts +352 -288
- package/build/littlejs.esm.js +695 -658
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +694 -658
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +629 -594
- package/examples/breakout/game.js +4 -4
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/electron/game.js +1 -1
- package/examples/electron/index.html +2 -2
- package/examples/favicon.png +0 -0
- package/examples/js13k/build.js +1 -1
- package/examples/js13k/index.html +13 -13
- package/examples/module/game.js +1 -1
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/game.js +6 -6
- package/examples/platformer/gameCharacter.js +293 -0
- package/examples/platformer/gameEffects.js +8 -5
- package/examples/platformer/gameObjects.js +13 -13
- package/examples/platformer/gamePlayer.js +9 -293
- package/examples/platformer/index.html +7 -6
- package/examples/puzzle/game.js +3 -2
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/build.js +1 -1
- package/examples/starter/game.js +2 -2
- package/examples/starter/index.html +13 -13
- package/examples/stress/index.html +35 -27
- package/examples/typescript/index.html +1 -1
- package/index.d.ts +2094 -0
- package/package.json +1 -1
- package/src/engine.js +28 -28
- package/src/engineAudio.js +57 -57
- package/src/engineDebug.js +66 -65
- package/src/engineDraw.js +64 -73
- package/src/engineExport.js +1 -0
- package/src/engineInput.js +57 -40
- package/src/engineMedals.js +32 -29
- package/src/engineObject.js +42 -27
- package/src/engineParticles.js +98 -72
- package/src/engineRelease.js +1 -1
- package/src/engineSettings.js +22 -22
- package/src/engineTileLayer.js +66 -60
- package/src/engineUtilities.js +49 -49
- package/src/engineWebGL.js +112 -135
- package/src/jsconfig.json +10 -0
package/build/littlejs.d.ts
CHANGED
|
@@ -56,13 +56,13 @@ declare module "littlejs.esm" {
|
|
|
56
56
|
export let timeReal: number;
|
|
57
57
|
/** Is the game paused? Causes time and objects to not be updated
|
|
58
58
|
* @type {Boolean}
|
|
59
|
-
* @default
|
|
59
|
+
* @default false
|
|
60
60
|
* @memberof Engine */
|
|
61
61
|
export let paused: boolean;
|
|
62
62
|
/** Set if game is paused
|
|
63
|
-
* @param {Boolean}
|
|
63
|
+
* @param {Boolean} isPaused
|
|
64
64
|
* @memberof Engine */
|
|
65
|
-
export function setPaused(
|
|
65
|
+
export function setPaused(isPaused: boolean): void;
|
|
66
66
|
/** Start up LittleJS engine with your callback functions
|
|
67
67
|
* @param {Function} gameInit - Called once after the engine starts up, setup the game
|
|
68
68
|
* @param {Function} gameUpdate - Called every frame at 60 frames per second, handle input and update the game state
|
|
@@ -80,11 +80,11 @@ declare module "littlejs.esm" {
|
|
|
80
80
|
export function engineObjectsDestroy(): void;
|
|
81
81
|
/** Triggers a callback for each object within a given area
|
|
82
82
|
* @param {Vector2} [pos] - Center of test area
|
|
83
|
-
* @param {Number} [size]
|
|
83
|
+
* @param {Number|Vector2} [size] - Radius of circle if float, rectangle size if Vector2
|
|
84
84
|
* @param {Function} [callbackFunction] - Calls this function on every object that passes the test
|
|
85
85
|
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
86
86
|
* @memberof Engine */
|
|
87
|
-
export function engineObjectsCallback(pos?: Vector2, size?: number, callbackFunction?: Function, objects?: any[]): void;
|
|
87
|
+
export function engineObjectsCallback(pos?: Vector2, size?: number | Vector2, callbackFunction?: Function, objects?: any[]): void;
|
|
88
88
|
/**
|
|
89
89
|
* LittleJS Debug System
|
|
90
90
|
* - Press Esc to show debug overlay with mouse pick
|
|
@@ -99,64 +99,69 @@ declare module "littlejs.esm" {
|
|
|
99
99
|
* @default
|
|
100
100
|
* @memberof Debug */
|
|
101
101
|
export const debug: boolean;
|
|
102
|
+
/** True if the debug overlay is active, always false in release builds
|
|
103
|
+
* @type {Boolean}
|
|
104
|
+
* @default
|
|
105
|
+
* @memberof Debug */
|
|
106
|
+
export let debugOverlay: boolean;
|
|
102
107
|
/** True if watermark with FPS should be shown, false in release builds
|
|
103
108
|
* @type {Boolean}
|
|
104
109
|
* @default
|
|
105
110
|
* @memberof Debug */
|
|
106
111
|
export let showWatermark: boolean;
|
|
107
112
|
/** Asserts if the experssion is false, does not do anything in release builds
|
|
108
|
-
* @param {Boolean}
|
|
109
|
-
* @param {Object}
|
|
113
|
+
* @param {Boolean} assert
|
|
114
|
+
* @param {Object} output
|
|
110
115
|
* @memberof Debug */
|
|
111
|
-
export function ASSERT(
|
|
116
|
+
export function ASSERT(assert: boolean, output: any): void;
|
|
112
117
|
/** Draw a debug rectangle in world space
|
|
113
118
|
* @param {Vector2} pos
|
|
114
119
|
* @param {Vector2} [size=Vector2()]
|
|
115
|
-
* @param {String} [color
|
|
116
|
-
* @param {Number} [time
|
|
117
|
-
* @param {Number} [angle
|
|
118
|
-
* @param {Boolean} [fill
|
|
120
|
+
* @param {String} [color]
|
|
121
|
+
* @param {Number} [time]
|
|
122
|
+
* @param {Number} [angle]
|
|
123
|
+
* @param {Boolean} [fill]
|
|
119
124
|
* @memberof Debug */
|
|
120
125
|
export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
|
|
121
126
|
/** Draw a debug circle in world space
|
|
122
127
|
* @param {Vector2} pos
|
|
123
|
-
* @param {Number} [radius
|
|
124
|
-
* @param {String} [color
|
|
125
|
-
* @param {Number} [time
|
|
126
|
-
* @param {Boolean} [fill
|
|
128
|
+
* @param {Number} [radius]
|
|
129
|
+
* @param {String} [color]
|
|
130
|
+
* @param {Number} [time]
|
|
131
|
+
* @param {Boolean} [fill]
|
|
127
132
|
* @memberof Debug */
|
|
128
133
|
export function debugCircle(pos: Vector2, radius?: number, color?: string, time?: number, fill?: boolean): void;
|
|
129
134
|
/** Draw a debug point in world space
|
|
130
135
|
* @param {Vector2} pos
|
|
131
|
-
* @param {String} [color
|
|
132
|
-
* @param {Number} [time
|
|
133
|
-
* @param {Number} [angle
|
|
136
|
+
* @param {String} [color]
|
|
137
|
+
* @param {Number} [time]
|
|
138
|
+
* @param {Number} [angle]
|
|
134
139
|
* @memberof Debug */
|
|
135
140
|
export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
|
|
136
141
|
/** Draw a debug line in world space
|
|
137
142
|
* @param {Vector2} posA
|
|
138
143
|
* @param {Vector2} posB
|
|
139
|
-
* @param {String} [color
|
|
140
|
-
* @param {Number} [thickness
|
|
141
|
-
* @param {Number} [time
|
|
144
|
+
* @param {String} [color]
|
|
145
|
+
* @param {Number} [thickness]
|
|
146
|
+
* @param {Number} [time]
|
|
142
147
|
* @memberof Debug */
|
|
143
148
|
export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
|
|
144
149
|
/** Draw a debug axis aligned bounding box in world space
|
|
145
|
-
* @param {Vector2}
|
|
146
|
-
* @param {Vector2}
|
|
147
|
-
* @param {Vector2}
|
|
148
|
-
* @param {Vector2}
|
|
149
|
-
* @param {String} [color
|
|
150
|
+
* @param {Vector2} pA - position A
|
|
151
|
+
* @param {Vector2} sA - size A
|
|
152
|
+
* @param {Vector2} pB - position B
|
|
153
|
+
* @param {Vector2} sB - size B
|
|
154
|
+
* @param {String} [color]
|
|
150
155
|
* @memberof Debug */
|
|
151
|
-
export function debugAABB(pA:
|
|
156
|
+
export function debugAABB(pA: Vector2, sA: Vector2, pB: Vector2, sB: Vector2, color?: string): void;
|
|
152
157
|
/** Draw a debug axis aligned bounding box in world space
|
|
153
158
|
* @param {String} text
|
|
154
159
|
* @param {Vector2} pos
|
|
155
|
-
* @param {Number} [size
|
|
156
|
-
* @param {String} [color
|
|
157
|
-
* @param {Number} [time
|
|
158
|
-
* @param {Number} [angle
|
|
159
|
-
* @param {String} [font
|
|
160
|
+
* @param {Number} [size]
|
|
161
|
+
* @param {String} [color]
|
|
162
|
+
* @param {Number} [time]
|
|
163
|
+
* @param {Number} [angle]
|
|
164
|
+
* @param {String} [font]
|
|
160
165
|
* @memberof Debug */
|
|
161
166
|
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
162
167
|
/** Clear all debug primitives in the list
|
|
@@ -165,7 +170,7 @@ declare module "littlejs.esm" {
|
|
|
165
170
|
/** Save a canvas to disk
|
|
166
171
|
* @param {HTMLCanvasElement} canvas
|
|
167
172
|
* @param {String} [filename]
|
|
168
|
-
* @param {String} [type
|
|
173
|
+
* @param {String} [type]
|
|
169
174
|
* @memberof Debug */
|
|
170
175
|
export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string): void;
|
|
171
176
|
/**
|
|
@@ -241,7 +246,7 @@ declare module "littlejs.esm" {
|
|
|
241
246
|
export let objectDefaultAngleDamping: number;
|
|
242
247
|
/** How much to bounce when a collision occurs (0-1)
|
|
243
248
|
* @type {Number}
|
|
244
|
-
* @default
|
|
249
|
+
* @default
|
|
245
250
|
* @memberof Settings */
|
|
246
251
|
export let objectDefaultElasticity: number;
|
|
247
252
|
/** How much to slow when touching (0-1)
|
|
@@ -256,7 +261,7 @@ declare module "littlejs.esm" {
|
|
|
256
261
|
export let objectMaxSpeed: number;
|
|
257
262
|
/** How much gravity to apply to objects along the Y axis, negative is down
|
|
258
263
|
* @type {Number}
|
|
259
|
-
* @default
|
|
264
|
+
* @default
|
|
260
265
|
* @memberof Settings */
|
|
261
266
|
export let gravity: number;
|
|
262
267
|
/** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
|
|
@@ -293,7 +298,7 @@ declare module "littlejs.esm" {
|
|
|
293
298
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
294
299
|
* - Must be set by end of gameInit to be activated
|
|
295
300
|
* @type {Boolean}
|
|
296
|
-
* @default
|
|
301
|
+
* @default
|
|
297
302
|
* @memberof Settings */
|
|
298
303
|
export let touchGamepadEnable: boolean;
|
|
299
304
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
@@ -409,13 +414,13 @@ declare module "littlejs.esm" {
|
|
|
409
414
|
* @memberof Settings */
|
|
410
415
|
export function setObjectDefaultMass(mass: number): void;
|
|
411
416
|
/** Set how much to slow velocity by each frame
|
|
412
|
-
* @param {Number}
|
|
417
|
+
* @param {Number} damp
|
|
413
418
|
* @memberof Settings */
|
|
414
|
-
export function setObjectDefaultDamping(damp:
|
|
419
|
+
export function setObjectDefaultDamping(damp: number): void;
|
|
415
420
|
/** Set how much to slow angular velocity each frame
|
|
416
|
-
* @param {Number}
|
|
421
|
+
* @param {Number} damp
|
|
417
422
|
* @memberof Settings */
|
|
418
|
-
export function setObjectDefaultAngleDamping(damp:
|
|
423
|
+
export function setObjectDefaultAngleDamping(damp: number): void;
|
|
419
424
|
/** Set how much to bounce when a collision occur
|
|
420
425
|
* @param {Number} elasticity
|
|
421
426
|
* @memberof Settings */
|
|
@@ -429,9 +434,9 @@ declare module "littlejs.esm" {
|
|
|
429
434
|
* @memberof Settings */
|
|
430
435
|
export function setObjectMaxSpeed(speed: number): void;
|
|
431
436
|
/** Set how much gravity to apply to objects along the Y axis
|
|
432
|
-
* @param {Number}
|
|
437
|
+
* @param {Number} newGravity
|
|
433
438
|
* @memberof Settings */
|
|
434
|
-
export function setGravity(
|
|
439
|
+
export function setGravity(newGravity: number): void;
|
|
435
440
|
/** Set to scales emit rate of particles
|
|
436
441
|
* @param {Number} scale
|
|
437
442
|
* @memberof Settings */
|
|
@@ -509,9 +514,9 @@ declare module "littlejs.esm" {
|
|
|
509
514
|
* @memberof Debug */
|
|
510
515
|
export function setShowWatermark(show: boolean): void;
|
|
511
516
|
/** Set key code used to toggle debug mode, Esc by default
|
|
512
|
-
* @param {
|
|
517
|
+
* @param {String} key
|
|
513
518
|
* @memberof Debug */
|
|
514
|
-
export function setDebugKey(key:
|
|
519
|
+
export function setDebugKey(key: string): void;
|
|
515
520
|
/**
|
|
516
521
|
* LittleJS Utility Classes and Functions
|
|
517
522
|
* - General purpose math library
|
|
@@ -550,14 +555,14 @@ declare module "littlejs.esm" {
|
|
|
550
555
|
export function sign(value: number): number;
|
|
551
556
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
552
557
|
* @param {Number} dividend
|
|
553
|
-
* @param {Number} [divisor
|
|
558
|
+
* @param {Number} [divisor]
|
|
554
559
|
* @return {Number}
|
|
555
560
|
* @memberof Utilities */
|
|
556
561
|
export function mod(dividend: number, divisor?: number): number;
|
|
557
562
|
/** Clamps the value beween max and min
|
|
558
563
|
* @param {Number} value
|
|
559
|
-
* @param {Number} [min
|
|
560
|
-
* @param {Number} [max
|
|
564
|
+
* @param {Number} [min]
|
|
565
|
+
* @param {Number} [max]
|
|
561
566
|
* @return {Number}
|
|
562
567
|
* @memberof Utilities */
|
|
563
568
|
export function clamp(value: number, min?: number, max?: number): number;
|
|
@@ -571,7 +576,7 @@ declare module "littlejs.esm" {
|
|
|
571
576
|
/** Returns signed wrapped distance between the two values passed in
|
|
572
577
|
* @param {Number} valueA
|
|
573
578
|
* @param {Number} valueB
|
|
574
|
-
* @param {Number} [wrapSize
|
|
579
|
+
* @param {Number} [wrapSize]
|
|
575
580
|
* @returns {Number}
|
|
576
581
|
* @memberof Utilities */
|
|
577
582
|
export function distanceWrap(valueA: number, valueB: number, wrapSize?: number): number;
|
|
@@ -579,7 +584,7 @@ declare module "littlejs.esm" {
|
|
|
579
584
|
* @param {Number} percent
|
|
580
585
|
* @param {Number} valueA
|
|
581
586
|
* @param {Number} valueB
|
|
582
|
-
* @param {Number} [wrapSize
|
|
587
|
+
* @param {Number} [wrapSize]
|
|
583
588
|
* @returns {Number}
|
|
584
589
|
* @memberof Utilities */
|
|
585
590
|
export function lerpWrap(percent: number, valueA: number, valueB: number, wrapSize?: number): number;
|
|
@@ -614,18 +619,18 @@ declare module "littlejs.esm" {
|
|
|
614
619
|
* @memberof Utilities */
|
|
615
620
|
export function nearestPowerOfTwo(value: number): number;
|
|
616
621
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
617
|
-
* @param {Vector2} pointA
|
|
618
|
-
* @param {Vector2} sizeA
|
|
619
|
-
* @param {Vector2} pointB
|
|
620
|
-
* @param {Vector2} sizeB
|
|
621
|
-
* @return {Boolean}
|
|
622
|
+
* @param {Vector2} pointA - Center of box A
|
|
623
|
+
* @param {Vector2} sizeA - Size of box A
|
|
624
|
+
* @param {Vector2} pointB - Center of box B
|
|
625
|
+
* @param {Vector2} sizeB - Size of box B
|
|
626
|
+
* @return {Boolean} - True if overlapping
|
|
622
627
|
* @memberof Utilities */
|
|
623
628
|
export function isOverlapping(pointA: Vector2, sizeA: Vector2, pointB: Vector2, sizeB: Vector2): boolean;
|
|
624
629
|
/** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
|
|
625
|
-
* @param {Number} [frequency
|
|
626
|
-
* @param {Number} [amplitude
|
|
627
|
-
* @param {Number} [t=time]
|
|
628
|
-
* @return {Number}
|
|
630
|
+
* @param {Number} [frequency] - Frequency of the wave in Hz
|
|
631
|
+
* @param {Number} [amplitude] - Amplitude (max height) of the wave
|
|
632
|
+
* @param {Number} [t=time] - Value to use for time of the wave
|
|
633
|
+
* @return {Number} - Value waving between 0 and amplitude
|
|
629
634
|
* @memberof Utilities */
|
|
630
635
|
export function wave(frequency?: number, amplitude?: number, t?: number): number;
|
|
631
636
|
/** Formats seconds to mm:ss style for display purposes
|
|
@@ -636,14 +641,14 @@ declare module "littlejs.esm" {
|
|
|
636
641
|
/** Random global functions
|
|
637
642
|
* @namespace Random */
|
|
638
643
|
/** Returns a random value between the two values passed in
|
|
639
|
-
* @param {Number} [valueA
|
|
640
|
-
* @param {Number} [valueB
|
|
644
|
+
* @param {Number} [valueA]
|
|
645
|
+
* @param {Number} [valueB]
|
|
641
646
|
* @return {Number}
|
|
642
647
|
* @memberof Random */
|
|
643
648
|
export function rand(valueA?: number, valueB?: number): number;
|
|
644
649
|
/** Returns a floored random value the two values passed in
|
|
645
650
|
* @param {Number} valueA
|
|
646
|
-
* @param {Number} [valueB
|
|
651
|
+
* @param {Number} [valueB]
|
|
647
652
|
* @return {Number}
|
|
648
653
|
* @memberof Random */
|
|
649
654
|
export function randInt(valueA: number, valueB?: number): number;
|
|
@@ -652,13 +657,13 @@ declare module "littlejs.esm" {
|
|
|
652
657
|
* @memberof Random */
|
|
653
658
|
export function randSign(): number;
|
|
654
659
|
/** Returns a random Vector2 within a circular shape
|
|
655
|
-
* @param {Number} [radius
|
|
656
|
-
* @param {Number} [minRadius
|
|
660
|
+
* @param {Number} [radius]
|
|
661
|
+
* @param {Number} [minRadius]
|
|
657
662
|
* @return {Vector2}
|
|
658
663
|
* @memberof Random */
|
|
659
664
|
export function randInCircle(radius?: number, minRadius?: number): Vector2;
|
|
660
665
|
/** Returns a random Vector2 with the passed in length
|
|
661
|
-
* @param {Number} [length
|
|
666
|
+
* @param {Number} [length]
|
|
662
667
|
* @return {Vector2}
|
|
663
668
|
* @memberof Random */
|
|
664
669
|
export function randVector(length?: number): Vector2;
|
|
@@ -686,13 +691,13 @@ declare module "littlejs.esm" {
|
|
|
686
691
|
/** @property {Number} - random seed */
|
|
687
692
|
seed: number;
|
|
688
693
|
/** Returns a seeded random value between the two values passed in
|
|
689
|
-
* @param {Number} [valueA
|
|
690
|
-
* @param {Number} [valueB
|
|
694
|
+
* @param {Number} [valueA]
|
|
695
|
+
* @param {Number} [valueB]
|
|
691
696
|
* @return {Number} */
|
|
692
697
|
float(valueA?: number, valueB?: number): number;
|
|
693
698
|
/** Returns a floored seeded random value the two values passed in
|
|
694
699
|
* @param {Number} valueA
|
|
695
|
-
* @param {Number} [valueB
|
|
700
|
+
* @param {Number} [valueB]
|
|
696
701
|
* @return {Number} */
|
|
697
702
|
int(valueA: number, valueB?: number): number;
|
|
698
703
|
/** Randomly returns either -1 or 1 deterministically
|
|
@@ -710,8 +715,8 @@ declare module "littlejs.esm" {
|
|
|
710
715
|
*/
|
|
711
716
|
export class Vector2 {
|
|
712
717
|
/** Create a 2D vector with the x and y passed in, can also be created with vec2()
|
|
713
|
-
* @param {Number} [x
|
|
714
|
-
* @param {Number} [y
|
|
718
|
+
* @param {Number} [x] - X axis location
|
|
719
|
+
* @param {Number} [y] - Y axis location */
|
|
715
720
|
constructor(x?: number, y?: number);
|
|
716
721
|
/** @property {Number} - X axis location */
|
|
717
722
|
x: number;
|
|
@@ -755,11 +760,11 @@ declare module "littlejs.esm" {
|
|
|
755
760
|
* @return {Number} */
|
|
756
761
|
distanceSquared(v: Vector2): number;
|
|
757
762
|
/** Returns a new vector in same direction as this one with the length passed in
|
|
758
|
-
* @param {Number} [length
|
|
763
|
+
* @param {Number} [length]
|
|
759
764
|
* @return {Vector2} */
|
|
760
765
|
normalize(length?: number): Vector2;
|
|
761
766
|
/** Returns a new vector clamped to length passed in
|
|
762
|
-
* @param {Number} [length
|
|
767
|
+
* @param {Number} [length]
|
|
763
768
|
* @return {Vector2} */
|
|
764
769
|
clampLength(length?: number): Vector2;
|
|
765
770
|
/** Returns the dot product of this and the vector passed in
|
|
@@ -774,8 +779,8 @@ declare module "littlejs.esm" {
|
|
|
774
779
|
* @return {Number} */
|
|
775
780
|
angle(): number;
|
|
776
781
|
/** Sets this vector with angle and length passed in
|
|
777
|
-
* @param {Number} [angle
|
|
778
|
-
* @param {Number} [length
|
|
782
|
+
* @param {Number} [angle]
|
|
783
|
+
* @param {Number} [length]
|
|
779
784
|
* @return {Vector2} */
|
|
780
785
|
setAngle(angle?: number, length?: number): Vector2;
|
|
781
786
|
/** Returns copy of this vector rotated by the angle passed in
|
|
@@ -819,10 +824,10 @@ declare module "littlejs.esm" {
|
|
|
819
824
|
*/
|
|
820
825
|
export class Color {
|
|
821
826
|
/** Create a color with the rgba components passed in, white by default
|
|
822
|
-
* @param {Number} [r
|
|
823
|
-
* @param {Number} [g
|
|
824
|
-
* @param {Number} [b
|
|
825
|
-
* @param {Number} [a
|
|
827
|
+
* @param {Number} [r] - red
|
|
828
|
+
* @param {Number} [g] - green
|
|
829
|
+
* @param {Number} [b] - blue
|
|
830
|
+
* @param {Number} [a] - alpha*/
|
|
826
831
|
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
827
832
|
/** @property {Number} - Red */
|
|
828
833
|
r: number;
|
|
@@ -865,22 +870,22 @@ declare module "littlejs.esm" {
|
|
|
865
870
|
* @return {Color} */
|
|
866
871
|
lerp(c: Color, percent: number): Color;
|
|
867
872
|
/** Sets this color given a hue, saturation, lightness, and alpha
|
|
868
|
-
* @param {Number} [h
|
|
869
|
-
* @param {Number} [s
|
|
870
|
-
* @param {Number} [l
|
|
871
|
-
* @param {Number} [a
|
|
873
|
+
* @param {Number} [h] - hue
|
|
874
|
+
* @param {Number} [s] - saturation
|
|
875
|
+
* @param {Number} [l] - lightness
|
|
876
|
+
* @param {Number} [a] - alpha
|
|
872
877
|
* @return {Color} */
|
|
873
878
|
setHSLA(h?: number, s?: number, l?: number, a?: number): Color;
|
|
874
879
|
/** Returns this color expressed in hsla format
|
|
875
880
|
* @return {Array} */
|
|
876
881
|
getHSLA(): any[];
|
|
877
882
|
/** Returns a new color that has each component randomly adjusted
|
|
878
|
-
* @param {Number} [amount
|
|
879
|
-
* @param {Number} [alphaAmount
|
|
883
|
+
* @param {Number} [amount]
|
|
884
|
+
* @param {Number} [alphaAmount]
|
|
880
885
|
* @return {Color} */
|
|
881
886
|
mutate(amount?: number, alphaAmount?: number): Color;
|
|
882
887
|
/** Returns this color expressed as a hex color code
|
|
883
|
-
* @param {Boolean} [useAlpha
|
|
888
|
+
* @param {Boolean} [useAlpha] - if alpha should be included in result
|
|
884
889
|
* @return {String} */
|
|
885
890
|
toString(useAlpha?: boolean): string;
|
|
886
891
|
/** Set this color from a hex code
|
|
@@ -907,7 +912,7 @@ declare module "littlejs.esm" {
|
|
|
907
912
|
time: number;
|
|
908
913
|
setTime: number;
|
|
909
914
|
/** Set the timer with seconds passed in
|
|
910
|
-
* @param {Number} [timeLeft
|
|
915
|
+
* @param {Number} [timeLeft] - How much time left before the timer is elapsed in seconds */
|
|
911
916
|
set(timeLeft?: number): void;
|
|
912
917
|
/** Unset the timer */
|
|
913
918
|
unset(): void;
|
|
@@ -935,8 +940,8 @@ declare module "littlejs.esm" {
|
|
|
935
940
|
}
|
|
936
941
|
/**
|
|
937
942
|
* Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar
|
|
938
|
-
* @param {(Number|Vector2)} [x
|
|
939
|
-
* @param {Number} [y
|
|
943
|
+
* @param {(Number|Vector2)} [x]
|
|
944
|
+
* @param {Number} [y]
|
|
940
945
|
* @return {Vector2}
|
|
941
946
|
* @example
|
|
942
947
|
* let a = vec2(0, 1); // vector with coordinates (0, 1)
|
|
@@ -974,9 +979,9 @@ declare module "littlejs.esm" {
|
|
|
974
979
|
* Create a tile info object
|
|
975
980
|
* - This can take vecs or floats for easier use and conversion
|
|
976
981
|
* - If an index is passed in, the tile size and index will determine the position
|
|
977
|
-
* @param {(Number|Vector2)} [pos=
|
|
978
|
-
* @param {(Number|Vector2)} [size=tileSizeDefault]
|
|
979
|
-
* @param {Number} [textureIndex
|
|
982
|
+
* @param {(Number|Vector2)} [pos=(0,0)] - Top left corner of tile in pixels or index
|
|
983
|
+
* @param {(Number|Vector2)} [size=tileSizeDefault] - Size of tile in pixels
|
|
984
|
+
* @param {Number} [textureIndex] - Texture index to use
|
|
980
985
|
* @return {TileInfo}
|
|
981
986
|
* @example
|
|
982
987
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
@@ -991,9 +996,9 @@ declare module "littlejs.esm" {
|
|
|
991
996
|
*/
|
|
992
997
|
export class TileInfo {
|
|
993
998
|
/** Create a tile info object
|
|
994
|
-
* @param {Vector2} [pos=
|
|
999
|
+
* @param {Vector2} [pos=(0,0)] - Top left corner of tile in pixels
|
|
995
1000
|
* @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
|
|
996
|
-
* @param {Number} [textureIndex
|
|
1001
|
+
* @param {Number} [textureIndex] - Texture index to use
|
|
997
1002
|
*/
|
|
998
1003
|
constructor(pos?: Vector2, size?: Vector2, textureIndex?: number);
|
|
999
1004
|
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
@@ -1014,9 +1019,13 @@ declare module "littlejs.esm" {
|
|
|
1014
1019
|
}
|
|
1015
1020
|
/** Texture Info - Stores info about each texture */
|
|
1016
1021
|
export class TextureInfo {
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* Create a TextureInfo, called automatically by the engine
|
|
1024
|
+
* @param {HTMLImageElement} image
|
|
1025
|
+
*/
|
|
1026
|
+
constructor(image: HTMLImageElement);
|
|
1027
|
+
/** @property {HTMLImageElement} - image source */
|
|
1028
|
+
image: HTMLImageElement;
|
|
1020
1029
|
/** @property {Vector2} - size of the image */
|
|
1021
1030
|
size: Vector2;
|
|
1022
1031
|
/** @property {WebGLTexture} - webgl texture */
|
|
@@ -1076,36 +1085,35 @@ declare module "littlejs.esm" {
|
|
|
1076
1085
|
* @memberof Draw */
|
|
1077
1086
|
export function worldToScreen(worldPos: Vector2): Vector2;
|
|
1078
1087
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1079
|
-
* @param {Vector2} pos
|
|
1080
|
-
* @param {Vector2} [size=
|
|
1081
|
-
* @param {TileInfo}[tileInfo]
|
|
1082
|
-
* @param {
|
|
1083
|
-
* @param {
|
|
1084
|
-
* @param {
|
|
1085
|
-
* @param {
|
|
1086
|
-
* @param {
|
|
1087
|
-
* @param {Boolean} [
|
|
1088
|
-
* @param {
|
|
1089
|
-
* @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1088
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
1089
|
+
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
|
|
1090
|
+
* @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
|
|
1091
|
+
* @param {Color} [color=(1,1,1,1)] - Color to modulate with
|
|
1092
|
+
* @param {Number} [angle] - Angle to rotate by
|
|
1093
|
+
* @param {Boolean} [mirror] - If true image is flipped along the Y axis
|
|
1094
|
+
* @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
|
|
1095
|
+
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1096
|
+
* @param {Boolean} [screenSpace=false] - If true the pos and size are in screen space
|
|
1097
|
+
* @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1090
1098
|
* @memberof Draw */
|
|
1091
1099
|
export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1092
1100
|
/** Draw colored rect centered on pos
|
|
1093
1101
|
* @param {Vector2} pos
|
|
1094
|
-
* @param {Vector2} [size=
|
|
1095
|
-
* @param {Color} [color=
|
|
1096
|
-
* @param {Number} [angle
|
|
1102
|
+
* @param {Vector2} [size=(1,1)]
|
|
1103
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1104
|
+
* @param {Number} [angle]
|
|
1097
1105
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1098
|
-
* @param {Boolean} [screenSpace=
|
|
1106
|
+
* @param {Boolean} [screenSpace=false]
|
|
1099
1107
|
* @param {CanvasRenderingContext2D} [context]
|
|
1100
1108
|
* @memberof Draw */
|
|
1101
1109
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1102
1110
|
/** Draw colored line between two points
|
|
1103
1111
|
* @param {Vector2} posA
|
|
1104
1112
|
* @param {Vector2} posB
|
|
1105
|
-
* @param {Number} [thickness
|
|
1106
|
-
* @param {Color} [color=
|
|
1113
|
+
* @param {Number} [thickness]
|
|
1114
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1107
1115
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1108
|
-
* @param {Boolean} [screenSpace=
|
|
1116
|
+
* @param {Boolean} [screenSpace=false]
|
|
1109
1117
|
* @param {CanvasRenderingContext2D} [context]
|
|
1110
1118
|
* @memberof Draw */
|
|
1111
1119
|
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
@@ -1115,12 +1123,12 @@ declare module "littlejs.esm" {
|
|
|
1115
1123
|
* @param {Number} angle
|
|
1116
1124
|
* @param {Boolean} mirror
|
|
1117
1125
|
* @param {Function} drawFunction
|
|
1118
|
-
* @param {Boolean} [screenSpace=
|
|
1126
|
+
* @param {Boolean} [screenSpace=false]
|
|
1119
1127
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1120
1128
|
* @memberof Draw */
|
|
1121
1129
|
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1122
1130
|
/** Enable normal or additive blend mode
|
|
1123
|
-
* @param {Boolean} [additive
|
|
1131
|
+
* @param {Boolean} [additive]
|
|
1124
1132
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1125
1133
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1126
1134
|
* @memberof Draw */
|
|
@@ -1129,28 +1137,28 @@ declare module "littlejs.esm" {
|
|
|
1129
1137
|
* Automatically splits new lines into rows
|
|
1130
1138
|
* @param {String} text
|
|
1131
1139
|
* @param {Vector2} pos
|
|
1132
|
-
* @param {Number} [size
|
|
1133
|
-
* @param {Color} [color=
|
|
1134
|
-
* @param {Number} [lineWidth
|
|
1135
|
-
* @param {Color} [lineColor=
|
|
1136
|
-
* @param {
|
|
1140
|
+
* @param {Number} [size]
|
|
1141
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1142
|
+
* @param {Number} [lineWidth]
|
|
1143
|
+
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1144
|
+
* @param {CanvasTextAlign} [textAlign]
|
|
1137
1145
|
* @param {String} [font=fontDefault]
|
|
1138
1146
|
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
1139
1147
|
* @memberof Draw */
|
|
1140
|
-
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?:
|
|
1148
|
+
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, context?: CanvasRenderingContext2D): void;
|
|
1141
1149
|
/** Draw text on overlay canvas in world space
|
|
1142
1150
|
* Automatically splits new lines into rows
|
|
1143
1151
|
* @param {String} text
|
|
1144
1152
|
* @param {Vector2} pos
|
|
1145
|
-
* @param {Number} [size
|
|
1146
|
-
* @param {Color} [color=
|
|
1147
|
-
* @param {Number} [lineWidth
|
|
1148
|
-
* @param {Color} [lineColor=
|
|
1149
|
-
* @param {
|
|
1153
|
+
* @param {Number} [size]
|
|
1154
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1155
|
+
* @param {Number} [lineWidth]
|
|
1156
|
+
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1157
|
+
* @param {CanvasTextAlign} [textAlign='center']
|
|
1150
1158
|
* @param {String} [font=fontDefault]
|
|
1151
1159
|
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
1152
1160
|
* @memberof Draw */
|
|
1153
|
-
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?:
|
|
1161
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, context?: CanvasRenderingContext2D): void;
|
|
1154
1162
|
export let engineFontImage: any;
|
|
1155
1163
|
/**
|
|
1156
1164
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
@@ -1166,9 +1174,9 @@ declare module "littlejs.esm" {
|
|
|
1166
1174
|
*/
|
|
1167
1175
|
export class FontImage {
|
|
1168
1176
|
/** Create an image font
|
|
1169
|
-
* @param {HTMLImageElement} [image]
|
|
1170
|
-
* @param {Vector2} [tileSize=
|
|
1171
|
-
* @param {Vector2} [paddingSize=
|
|
1177
|
+
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
|
|
1178
|
+
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1179
|
+
* @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
|
|
1172
1180
|
* @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
|
|
1173
1181
|
*/
|
|
1174
1182
|
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D);
|
|
@@ -1186,7 +1194,7 @@ declare module "littlejs.esm" {
|
|
|
1186
1194
|
/** Draw text in screen space using the image font
|
|
1187
1195
|
* @param {String} text
|
|
1188
1196
|
* @param {Vector2} pos
|
|
1189
|
-
* @param {Number} [scale
|
|
1197
|
+
* @param {Number} [scale]
|
|
1190
1198
|
* @param {Boolean} [center]
|
|
1191
1199
|
*/
|
|
1192
1200
|
drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
@@ -1214,9 +1222,9 @@ declare module "littlejs.esm" {
|
|
|
1214
1222
|
* @memberof WebGL */
|
|
1215
1223
|
export let glCanvas: HTMLCanvasElement;
|
|
1216
1224
|
/** 2d context for glCanvas
|
|
1217
|
-
* @type {
|
|
1225
|
+
* @type {WebGL2RenderingContext}
|
|
1218
1226
|
* @memberof WebGL */
|
|
1219
|
-
export let glContext:
|
|
1227
|
+
export let glContext: WebGL2RenderingContext;
|
|
1220
1228
|
/** Set the WebGl texture, called automatically if using multiple textures
|
|
1221
1229
|
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1222
1230
|
* @param {WebGLTexture} texture
|
|
@@ -1224,26 +1232,26 @@ declare module "littlejs.esm" {
|
|
|
1224
1232
|
export function glSetTexture(texture: WebGLTexture): void;
|
|
1225
1233
|
/** Compile WebGL shader of the given type, will throw errors if in debug mode
|
|
1226
1234
|
* @param {String} source
|
|
1227
|
-
* @param
|
|
1235
|
+
* @param {Number} type
|
|
1228
1236
|
* @return {WebGLShader}
|
|
1229
1237
|
* @memberof WebGL */
|
|
1230
|
-
export function glCompileShader(source: string, type:
|
|
1238
|
+
export function glCompileShader(source: string, type: number): WebGLShader;
|
|
1231
1239
|
/** Create WebGL program with given shaders
|
|
1232
|
-
* @param {
|
|
1233
|
-
* @param {
|
|
1240
|
+
* @param {String} vsSource
|
|
1241
|
+
* @param {String} fsSource
|
|
1234
1242
|
* @return {WebGLProgram}
|
|
1235
1243
|
* @memberof WebGL */
|
|
1236
|
-
export function glCreateProgram(vsSource:
|
|
1244
|
+
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
|
|
1237
1245
|
/** Create WebGL texture from an image and init the texture settings
|
|
1238
|
-
* @param {
|
|
1246
|
+
* @param {HTMLImageElement} image
|
|
1239
1247
|
* @return {WebGLTexture}
|
|
1240
1248
|
* @memberof WebGL */
|
|
1241
|
-
export function glCreateTexture(image:
|
|
1249
|
+
export function glCreateTexture(image: HTMLImageElement): WebGLTexture;
|
|
1242
1250
|
/** Set up a post processing shader
|
|
1243
1251
|
* @param {String} shaderCode
|
|
1244
1252
|
* @param {Boolean} includeOverlay
|
|
1245
1253
|
* @memberof WebGL */
|
|
1246
|
-
export function glInitPostProcess(shaderCode: string, includeOverlay
|
|
1254
|
+
export function glInitPostProcess(shaderCode: string, includeOverlay?: boolean): void;
|
|
1247
1255
|
/**
|
|
1248
1256
|
* LittleJS Input System
|
|
1249
1257
|
* - Tracks keyboard down, pressed, and released
|
|
@@ -1253,23 +1261,23 @@ declare module "littlejs.esm" {
|
|
|
1253
1261
|
* @namespace Input
|
|
1254
1262
|
*/
|
|
1255
1263
|
/** Returns true if device key is down
|
|
1256
|
-
* @param {Number} key
|
|
1257
|
-
* @param {Number} [device
|
|
1264
|
+
* @param {String|Number} key
|
|
1265
|
+
* @param {Number} [device]
|
|
1258
1266
|
* @return {Boolean}
|
|
1259
1267
|
* @memberof Input */
|
|
1260
|
-
export function keyIsDown(key: number, device?: number): boolean;
|
|
1268
|
+
export function keyIsDown(key: string | number, device?: number): boolean;
|
|
1261
1269
|
/** Returns true if device key was pressed this frame
|
|
1262
|
-
* @param {Number} key
|
|
1263
|
-
* @param {Number} [device
|
|
1270
|
+
* @param {String|Number} key
|
|
1271
|
+
* @param {Number} [device]
|
|
1264
1272
|
* @return {Boolean}
|
|
1265
1273
|
* @memberof Input */
|
|
1266
|
-
export function keyWasPressed(key: number, device?: number): boolean;
|
|
1274
|
+
export function keyWasPressed(key: string | number, device?: number): boolean;
|
|
1267
1275
|
/** Returns true if device key was released this frame
|
|
1268
|
-
* @param {Number} key
|
|
1269
|
-
* @param {Number} [device
|
|
1276
|
+
* @param {String|Number} key
|
|
1277
|
+
* @param {Number} [device]
|
|
1270
1278
|
* @return {Boolean}
|
|
1271
1279
|
* @memberof Input */
|
|
1272
|
-
export function keyWasReleased(key: number, device?: number): boolean;
|
|
1280
|
+
export function keyWasReleased(key: string | number, device?: number): boolean;
|
|
1273
1281
|
/** Clears all input
|
|
1274
1282
|
* @memberof Input */
|
|
1275
1283
|
export function clearInput(): void;
|
|
@@ -1282,23 +1290,23 @@ declare module "littlejs.esm" {
|
|
|
1282
1290
|
* @namespace Input
|
|
1283
1291
|
*/
|
|
1284
1292
|
/** Returns true if device key is down
|
|
1285
|
-
* @param {Number} key
|
|
1286
|
-
* @param {Number} [device
|
|
1293
|
+
* @param {String|Number} key
|
|
1294
|
+
* @param {Number} [device]
|
|
1287
1295
|
* @return {Boolean}
|
|
1288
1296
|
* @memberof Input */
|
|
1289
|
-
export function mouseIsDown(key: number, device?: number): boolean;
|
|
1297
|
+
export function mouseIsDown(key: string | number, device?: number): boolean;
|
|
1290
1298
|
/** Returns true if device key was pressed this frame
|
|
1291
|
-
* @param {Number} key
|
|
1292
|
-
* @param {Number} [device
|
|
1299
|
+
* @param {String|Number} key
|
|
1300
|
+
* @param {Number} [device]
|
|
1293
1301
|
* @return {Boolean}
|
|
1294
1302
|
* @memberof Input */
|
|
1295
|
-
export function mouseWasPressed(key: number, device?: number): boolean;
|
|
1303
|
+
export function mouseWasPressed(key: string | number, device?: number): boolean;
|
|
1296
1304
|
/** Returns true if device key was released this frame
|
|
1297
|
-
* @param {Number} key
|
|
1298
|
-
* @param {Number} [device
|
|
1305
|
+
* @param {String|Number} key
|
|
1306
|
+
* @param {Number} [device]
|
|
1299
1307
|
* @return {Boolean}
|
|
1300
1308
|
* @memberof Input */
|
|
1301
|
-
export function mouseWasReleased(key: number, device?: number): boolean;
|
|
1309
|
+
export function mouseWasReleased(key: string | number, device?: number): boolean;
|
|
1302
1310
|
/** Mouse pos in world space
|
|
1303
1311
|
* @type {Vector2}
|
|
1304
1312
|
* @memberof Input */
|
|
@@ -1321,34 +1329,34 @@ declare module "littlejs.esm" {
|
|
|
1321
1329
|
export let preventDefaultInput: boolean;
|
|
1322
1330
|
/** Returns true if gamepad button is down
|
|
1323
1331
|
* @param {Number} button
|
|
1324
|
-
* @param {Number} [gamepad
|
|
1332
|
+
* @param {Number} [gamepad]
|
|
1325
1333
|
* @return {Boolean}
|
|
1326
1334
|
* @memberof Input */
|
|
1327
1335
|
export function gamepadIsDown(button: number, gamepad?: number): boolean;
|
|
1328
1336
|
/** Returns true if gamepad button was pressed
|
|
1329
1337
|
* @param {Number} button
|
|
1330
|
-
* @param {Number} [gamepad
|
|
1338
|
+
* @param {Number} [gamepad]
|
|
1331
1339
|
* @return {Boolean}
|
|
1332
1340
|
* @memberof Input */
|
|
1333
1341
|
export function gamepadWasPressed(button: number, gamepad?: number): boolean;
|
|
1334
1342
|
/** Returns true if gamepad button was released
|
|
1335
1343
|
* @param {Number} button
|
|
1336
|
-
* @param {Number} [gamepad
|
|
1344
|
+
* @param {Number} [gamepad]
|
|
1337
1345
|
* @return {Boolean}
|
|
1338
1346
|
* @memberof Input */
|
|
1339
1347
|
export function gamepadWasReleased(button: number, gamepad?: number): boolean;
|
|
1340
1348
|
/** Returns gamepad stick value
|
|
1341
1349
|
* @param {Number} stick
|
|
1342
|
-
* @param {Number} [gamepad
|
|
1350
|
+
* @param {Number} [gamepad]
|
|
1343
1351
|
* @return {Vector2}
|
|
1344
1352
|
* @memberof Input */
|
|
1345
1353
|
export function gamepadStick(stick: number, gamepad?: number): Vector2;
|
|
1346
1354
|
export function mouseToScreen(mousePos: any): Vector2;
|
|
1347
1355
|
export function gamepadsUpdate(): void;
|
|
1348
1356
|
/** Pulse the vibration hardware if it exists
|
|
1349
|
-
* @param {Number} [pattern
|
|
1357
|
+
* @param {Number|Array} [pattern] - single value in ms or vibration interval array
|
|
1350
1358
|
* @memberof Input */
|
|
1351
|
-
export function vibrate(pattern?: number): void;
|
|
1359
|
+
export function vibrate(pattern?: number | any[]): void;
|
|
1352
1360
|
/** Cancel any ongoing vibration
|
|
1353
1361
|
* @memberof Input */
|
|
1354
1362
|
export function vibrateStop(): void;
|
|
@@ -1393,16 +1401,20 @@ declare module "littlejs.esm" {
|
|
|
1393
1401
|
sampleRate: number;
|
|
1394
1402
|
/** Play the sound
|
|
1395
1403
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
1396
|
-
* @param {Number} [volume
|
|
1397
|
-
* @param {Number} [pitch
|
|
1398
|
-
* @param {Number} [randomnessScale
|
|
1399
|
-
* @param {Boolean} [loop
|
|
1404
|
+
* @param {Number} [volume] - How much to scale volume by (in addition to range fade)
|
|
1405
|
+
* @param {Number} [pitch] - How much to scale pitch by (also adjusted by this.randomness)
|
|
1406
|
+
* @param {Number} [randomnessScale] - How much to scale randomness
|
|
1407
|
+
* @param {Boolean} [loop] - Should the sound loop
|
|
1400
1408
|
* @return {AudioBufferSourceNode} - The audio source node
|
|
1401
1409
|
*/
|
|
1402
1410
|
play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1403
|
-
source:
|
|
1411
|
+
source: AudioBufferSourceNode;
|
|
1404
1412
|
/** Stop the last instance of this sound that was played */
|
|
1405
1413
|
stop(): void;
|
|
1414
|
+
/** Get source of most recent instance of this sound that was played
|
|
1415
|
+
* @return {AudioBufferSourceNode}
|
|
1416
|
+
*/
|
|
1417
|
+
getSource(): AudioBufferSourceNode;
|
|
1406
1418
|
/** Play the sound as a note with a semitone offset
|
|
1407
1419
|
* @param {Number} semitoneOffset - How many semitones to offset pitch
|
|
1408
1420
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
@@ -1414,10 +1426,6 @@ declare module "littlejs.esm" {
|
|
|
1414
1426
|
* @return {Number} - How long the sound is in seconds (undefined if loading)
|
|
1415
1427
|
*/
|
|
1416
1428
|
getDuration(): number;
|
|
1417
|
-
/** Check if the last instance of this sound is playing
|
|
1418
|
-
* @return {Boolean} - True if the sound is playing
|
|
1419
|
-
*/
|
|
1420
|
-
isPlaying(): boolean;
|
|
1421
1429
|
/** Check if sound is loading, for sounds fetched from a url
|
|
1422
1430
|
* @return {Boolean} - True if sound is loading and not ready to play
|
|
1423
1431
|
*/
|
|
@@ -1436,7 +1444,7 @@ declare module "littlejs.esm" {
|
|
|
1436
1444
|
export class SoundWave extends Sound {
|
|
1437
1445
|
/** Create a sound object and cache the wave file for later use
|
|
1438
1446
|
* @param {String} filename - Filename of audio file to load
|
|
1439
|
-
* @param {Number} [randomness
|
|
1447
|
+
* @param {Number} [randomness] - How much to randomize frequency each time sound plays
|
|
1440
1448
|
* @param {Number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
|
|
1441
1449
|
* @param {Number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
|
|
1442
1450
|
*/
|
|
@@ -1475,9 +1483,9 @@ declare module "littlejs.esm" {
|
|
|
1475
1483
|
*/
|
|
1476
1484
|
export class Music extends Sound {
|
|
1477
1485
|
/** Create a music object and cache the zzfx music samples for later use
|
|
1478
|
-
* @param {Array} zzfxMusic - Array of zzfx music parameters
|
|
1486
|
+
* @param {[Array, Array, Array, Number]} zzfxMusic - Array of zzfx music parameters
|
|
1479
1487
|
*/
|
|
1480
|
-
constructor(zzfxMusic: any[]);
|
|
1488
|
+
constructor(zzfxMusic: [any[], any[], any[], number]);
|
|
1481
1489
|
sampleChannels: any[];
|
|
1482
1490
|
/** Play the music
|
|
1483
1491
|
* @param {Number} [volume=1] - How much to scale volume by
|
|
@@ -1488,17 +1496,17 @@ declare module "littlejs.esm" {
|
|
|
1488
1496
|
}
|
|
1489
1497
|
/** Play an mp3, ogg, or wav audio from a local file or url
|
|
1490
1498
|
* @param {String} url - Location of sound file to play
|
|
1491
|
-
* @param {Number} [volume
|
|
1492
|
-
* @param {Boolean} [loop
|
|
1499
|
+
* @param {Number} [volume] - How much to scale volume by
|
|
1500
|
+
* @param {Boolean} [loop] - True if the music should loop
|
|
1493
1501
|
* @return {HTMLAudioElement} - The audio element for this sound
|
|
1494
1502
|
* @memberof Audio */
|
|
1495
1503
|
export function playAudioFile(url: string, volume?: number, loop?: boolean): HTMLAudioElement;
|
|
1496
1504
|
/** Speak text with passed in settings
|
|
1497
1505
|
* @param {String} text - The text to speak
|
|
1498
1506
|
* @param {String} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
1499
|
-
* @param {Number} [volume
|
|
1500
|
-
* @param {Number} [rate
|
|
1501
|
-
* @param {Number} [pitch
|
|
1507
|
+
* @param {Number} [volume] - How much to scale volume by
|
|
1508
|
+
* @param {Number} [rate] - How quickly to speak
|
|
1509
|
+
* @param {Number} [pitch] - How much to change the pitch by
|
|
1502
1510
|
* @return {SpeechSynthesisUtterance} - The utterance that was spoken
|
|
1503
1511
|
* @memberof Audio */
|
|
1504
1512
|
export function speak(text: string, language?: string, volume?: number, rate?: number, pitch?: number): SpeechSynthesisUtterance;
|
|
@@ -1507,7 +1515,7 @@ declare module "littlejs.esm" {
|
|
|
1507
1515
|
export function speakStop(): void;
|
|
1508
1516
|
/** Get frequency of a note on a musical scale
|
|
1509
1517
|
* @param {Number} semitoneOffset - How many semitones away from the root note
|
|
1510
|
-
* @param {Number} [
|
|
1518
|
+
* @param {Number} [rootFrequency=220] - Frequency at semitone offset 0
|
|
1511
1519
|
* @return {Number} - The frequency of the note
|
|
1512
1520
|
* @memberof Audio */
|
|
1513
1521
|
export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
|
|
@@ -1516,10 +1524,10 @@ declare module "littlejs.esm" {
|
|
|
1516
1524
|
export let audioContext: any;
|
|
1517
1525
|
/** Play cached audio samples with given settings
|
|
1518
1526
|
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
|
|
1519
|
-
* @param {Number} [volume
|
|
1520
|
-
* @param {Number} [rate
|
|
1521
|
-
* @param {Number} [pan
|
|
1522
|
-
* @param {Boolean} [loop
|
|
1527
|
+
* @param {Number} [volume] - How much to scale volume by
|
|
1528
|
+
* @param {Number} [rate] - The playback rate to use
|
|
1529
|
+
* @param {Number} [pan] - How much to apply stereo panning
|
|
1530
|
+
* @param {Boolean} [loop] - True if the sound should loop when it reaches the end
|
|
1523
1531
|
* @param {Number} [sampleRate=44100] - Sample rate for the sound
|
|
1524
1532
|
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1525
1533
|
* @memberof Audio */
|
|
@@ -1561,24 +1569,30 @@ declare module "littlejs.esm" {
|
|
|
1561
1569
|
*/
|
|
1562
1570
|
export class EngineObject {
|
|
1563
1571
|
/** Create an engine object and adds it to the list of objects
|
|
1564
|
-
* @param {Vector2}
|
|
1565
|
-
* @param {Vector2}
|
|
1566
|
-
* @param {TileInfo} [tileInfo]
|
|
1567
|
-
* @param {Number}
|
|
1568
|
-
* @param {Color}
|
|
1569
|
-
* @param {Number}
|
|
1572
|
+
* @param {Vector2} [pos=(0,0)] - World space position of the object
|
|
1573
|
+
* @param {Vector2} [size=(1,1)] - World space size of the object
|
|
1574
|
+
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
|
|
1575
|
+
* @param {Number} [angle] - Angle the object is rotated by
|
|
1576
|
+
* @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
|
|
1577
|
+
* @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
1570
1578
|
*/
|
|
1571
1579
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
1572
1580
|
/** @property {Vector2} - World space position of the object */
|
|
1573
1581
|
pos: Vector2;
|
|
1574
1582
|
/** @property {Vector2} - World space width and height of the object */
|
|
1575
1583
|
size: Vector2;
|
|
1584
|
+
/** @property {Vector2} - Size of object used for drawing, uses size if not set */
|
|
1585
|
+
drawSize: any;
|
|
1576
1586
|
/** @property {TileInfo} - Tile info to render object (undefined is untextured) */
|
|
1577
1587
|
tileInfo: TileInfo;
|
|
1578
1588
|
/** @property {Number} - Angle to rotate the object */
|
|
1579
1589
|
angle: number;
|
|
1580
1590
|
/** @property {Color} - Color to apply when rendered */
|
|
1581
1591
|
color: Color;
|
|
1592
|
+
/** @property {Color} - Additive color to apply when rendered */
|
|
1593
|
+
additiveColor: any;
|
|
1594
|
+
/** @property {Boolean} - Should it flip along y axis when rendered */
|
|
1595
|
+
mirror: boolean;
|
|
1582
1596
|
/** @property {Number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
|
|
1583
1597
|
mass: number;
|
|
1584
1598
|
/** @property {Number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
|
|
@@ -1589,17 +1603,30 @@ declare module "littlejs.esm" {
|
|
|
1589
1603
|
elasticity: number;
|
|
1590
1604
|
/** @property {Number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
|
|
1591
1605
|
friction: number;
|
|
1592
|
-
/** @property {Number}
|
|
1606
|
+
/** @property {Number} - How much to scale gravity by for this object */
|
|
1593
1607
|
gravityScale: number;
|
|
1594
|
-
/** @property {Number}
|
|
1608
|
+
/** @property {Number} - Objects are sorted by render order */
|
|
1595
1609
|
renderOrder: number;
|
|
1596
|
-
/** @property {Vector2}
|
|
1610
|
+
/** @property {Vector2} - Velocity of the object */
|
|
1597
1611
|
velocity: Vector2;
|
|
1598
|
-
/** @property {Number}
|
|
1612
|
+
/** @property {Number} - Angular velocity of the object */
|
|
1599
1613
|
angleVelocity: number;
|
|
1614
|
+
/** @property {Number} - Track when object was created */
|
|
1600
1615
|
spawnTime: number;
|
|
1616
|
+
/** @property {Array} - List of children of this object */
|
|
1601
1617
|
children: any[];
|
|
1618
|
+
/** @property {EngineObject} - Parent of object if in local space */
|
|
1619
|
+
parent: any;
|
|
1620
|
+
/** @property {Vector2} - Local position if child */
|
|
1621
|
+
localPos: Vector2;
|
|
1622
|
+
/** @property {Number} - Local angle if child */
|
|
1623
|
+
localAngle: number;
|
|
1624
|
+
/** @property {Boolean} - Object collides with the tile collision */
|
|
1602
1625
|
collideTiles: boolean;
|
|
1626
|
+
/** @property {Boolean} - Object collides with solid objects */
|
|
1627
|
+
collideSolidObjects: boolean;
|
|
1628
|
+
/** @property {Boolean} - Object collides with and blocks other objects */
|
|
1629
|
+
isSolid: boolean;
|
|
1603
1630
|
/** Update the object transform and physics, called automatically by engine once each frame */
|
|
1604
1631
|
update(): void;
|
|
1605
1632
|
groundObject: any;
|
|
@@ -1637,19 +1664,17 @@ declare module "littlejs.esm" {
|
|
|
1637
1664
|
getMirrorSign(): number;
|
|
1638
1665
|
/** Attaches a child to this with a given local transform
|
|
1639
1666
|
* @param {EngineObject} child
|
|
1640
|
-
* @param {Vector2} [localPos=
|
|
1641
|
-
* @param {Number} [localAngle
|
|
1667
|
+
* @param {Vector2} [localPos=(0,0)]
|
|
1668
|
+
* @param {Number} [localAngle] */
|
|
1642
1669
|
addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
|
|
1643
1670
|
/** Removes a child from this one
|
|
1644
1671
|
* @param {EngineObject} child */
|
|
1645
1672
|
removeChild(child: EngineObject): void;
|
|
1646
1673
|
/** Set how this object collides
|
|
1647
|
-
* @param {Boolean} [collideSolidObjects
|
|
1648
|
-
* @param {Boolean} [isSolid
|
|
1649
|
-
* @param {Boolean} [collideTiles
|
|
1674
|
+
* @param {Boolean} [collideSolidObjects] - Does it collide with solid objects
|
|
1675
|
+
* @param {Boolean} [isSolid] - Does it collide with and block other objects (expensive in large numbers)
|
|
1676
|
+
* @param {Boolean} [collideTiles] - Does it collide with the tile collision */
|
|
1650
1677
|
setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean): void;
|
|
1651
|
-
collideSolidObjects: boolean;
|
|
1652
|
-
isSolid: boolean;
|
|
1653
1678
|
/** Returns string containg info about this object for debugging
|
|
1654
1679
|
* @return {String} */
|
|
1655
1680
|
toString(): string;
|
|
@@ -1679,7 +1704,7 @@ declare module "littlejs.esm" {
|
|
|
1679
1704
|
export function initTileCollision(size: Vector2): void;
|
|
1680
1705
|
/** Set tile collision data
|
|
1681
1706
|
* @param {Vector2} pos
|
|
1682
|
-
* @param {Number} [data
|
|
1707
|
+
* @param {Number} [data]
|
|
1683
1708
|
* @memberof TileCollision */
|
|
1684
1709
|
export function setTileCollisionData(pos: Vector2, data?: number): void;
|
|
1685
1710
|
/** Get tile collision data
|
|
@@ -1689,7 +1714,7 @@ declare module "littlejs.esm" {
|
|
|
1689
1714
|
export function getTileCollisionData(pos: Vector2): number;
|
|
1690
1715
|
/** Check if collision with another object should occur
|
|
1691
1716
|
* @param {Vector2} pos
|
|
1692
|
-
* @param {Vector2} [size=
|
|
1717
|
+
* @param {Vector2} [size=(1,1)]
|
|
1693
1718
|
* @param {EngineObject} [object]
|
|
1694
1719
|
* @return {Boolean}
|
|
1695
1720
|
* @memberof TileCollision */
|
|
@@ -1713,10 +1738,10 @@ declare module "littlejs.esm" {
|
|
|
1713
1738
|
*/
|
|
1714
1739
|
export class TileLayerData {
|
|
1715
1740
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
1716
|
-
* @param {Number} [tile]
|
|
1717
|
-
* @param {Number} [direction
|
|
1718
|
-
* @param {Boolean} [mirror
|
|
1719
|
-
* @param {Color} [color
|
|
1741
|
+
* @param {Number} [tile] - The tile to use, untextured if undefined
|
|
1742
|
+
* @param {Number} [direction] - Integer direction of tile, in 90 degree increments
|
|
1743
|
+
* @param {Boolean} [mirror] - If the tile should be mirrored along the x axis
|
|
1744
|
+
* @param {Color} [color] - Color of the tile */
|
|
1720
1745
|
constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
|
|
1721
1746
|
/** @property {Number} - The tile to use, untextured if undefined */
|
|
1722
1747
|
tile: number;
|
|
@@ -1743,44 +1768,49 @@ declare module "littlejs.esm" {
|
|
|
1743
1768
|
*/
|
|
1744
1769
|
export class TileLayer extends EngineObject {
|
|
1745
1770
|
/** Create a tile layer object
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
constructor(
|
|
1753
|
-
/** @property {HTMLCanvasElement}
|
|
1771
|
+
* @param {Vector2} [position=(0,0)] - World space position
|
|
1772
|
+
* @param {Vector2} [size=tileCollisionSize] - World space size
|
|
1773
|
+
* @param {TileInfo} [tileInfo] - Tile info for layer
|
|
1774
|
+
* @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
|
|
1775
|
+
* @param {Number} [renderOrder] - Objects are sorted by renderOrder
|
|
1776
|
+
*/
|
|
1777
|
+
constructor(position?: Vector2, size?: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number);
|
|
1778
|
+
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
1754
1779
|
canvas: HTMLCanvasElement;
|
|
1755
1780
|
/** @property {CanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
|
|
1756
1781
|
context: CanvasRenderingContext2D;
|
|
1757
|
-
/** @property {Vector2}
|
|
1782
|
+
/** @property {Vector2} - How much to scale this layer when rendered */
|
|
1758
1783
|
scale: Vector2;
|
|
1784
|
+
/** @property {Boolean} - If true this layer will render to overlay canvas and appear above all objects */
|
|
1785
|
+
isOverlay: boolean;
|
|
1759
1786
|
data: TileLayerData[];
|
|
1760
1787
|
/** Set data at a given position in the array
|
|
1761
|
-
* @param {Vector2}
|
|
1762
|
-
* @param {TileLayerData} data
|
|
1763
|
-
* @param {Boolean} [redraw
|
|
1764
|
-
setData(layerPos:
|
|
1788
|
+
* @param {Vector2} layerPos - Local position in array
|
|
1789
|
+
* @param {TileLayerData} data - Data to set
|
|
1790
|
+
* @param {Boolean} [redraw] - Force the tile to redraw if true */
|
|
1791
|
+
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
1765
1792
|
/** Get data at a given position in the array
|
|
1766
1793
|
* @param {Vector2} layerPos - Local position in array
|
|
1767
1794
|
* @return {TileLayerData} */
|
|
1768
1795
|
getData(layerPos: Vector2): TileLayerData;
|
|
1769
1796
|
/** Draw all the tile data to an offscreen canvas
|
|
1770
|
-
* - This may be slow in some browsers
|
|
1771
|
-
*/
|
|
1797
|
+
* - This may be slow in some browsers but only needs to be done once */
|
|
1772
1798
|
redraw(): void;
|
|
1773
1799
|
/** Call to start the redraw process
|
|
1774
|
-
*
|
|
1800
|
+
* - This can be used to manually update small parts of the level
|
|
1801
|
+
* @param {Boolean} [clear] - Should it clear the canvas before drawing */
|
|
1775
1802
|
redrawStart(clear?: boolean): void;
|
|
1776
|
-
|
|
1803
|
+
/** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
1804
|
+
savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
|
|
1777
1805
|
/** Call to end the redraw process */
|
|
1778
1806
|
redrawEnd(): void;
|
|
1779
|
-
/** Draw the tile at a given position
|
|
1780
|
-
*
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1807
|
+
/** Draw the tile at a given position in the tile grid
|
|
1808
|
+
* This can be used to clear out tiles when they are destroyed
|
|
1809
|
+
* Tiles can also be redrawn if isinde a redrawStart/End block
|
|
1810
|
+
* @param {Vector2} layerPos
|
|
1811
|
+
* @param {Boolean} [clear] - should the old tile be cleared out
|
|
1812
|
+
*/
|
|
1813
|
+
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
1784
1814
|
/** Draw directly to the 2D canvas in world space (bipass webgl)
|
|
1785
1815
|
* @param {Vector2} pos
|
|
1786
1816
|
* @param {Vector2} size
|
|
@@ -1788,18 +1818,18 @@ declare module "littlejs.esm" {
|
|
|
1788
1818
|
* @param {Boolean} mirror
|
|
1789
1819
|
* @param {Function} drawFunction */
|
|
1790
1820
|
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
1791
|
-
/** Draw a tile directly onto the layer canvas
|
|
1821
|
+
/** Draw a tile directly onto the layer canvas in world space
|
|
1792
1822
|
* @param {Vector2} pos
|
|
1793
|
-
* @param {Vector2} [size=
|
|
1823
|
+
* @param {Vector2} [size=(1,1)]
|
|
1794
1824
|
* @param {TileInfo} [tileInfo]
|
|
1795
|
-
* @param {Color} [color=
|
|
1825
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1796
1826
|
* @param {Number} [angle=0]
|
|
1797
1827
|
* @param {Boolean} [mirror=0] */
|
|
1798
1828
|
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
1799
|
-
/** Draw a rectangle directly onto the layer canvas
|
|
1829
|
+
/** Draw a rectangle directly onto the layer canvas in world space
|
|
1800
1830
|
* @param {Vector2} pos
|
|
1801
|
-
* @param {Vector2} [size=
|
|
1802
|
-
* @param {Color} [color=
|
|
1831
|
+
* @param {Vector2} [size=(1,1)]
|
|
1832
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1803
1833
|
* @param {Number} [angle=0] */
|
|
1804
1834
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
1805
1835
|
}
|
|
@@ -1826,34 +1856,34 @@ declare module "littlejs.esm" {
|
|
|
1826
1856
|
export class ParticleEmitter extends EngineObject {
|
|
1827
1857
|
/** Create a particle system with the given settings
|
|
1828
1858
|
* @param {Vector2} position - World space position of the emitter
|
|
1829
|
-
* @param {Number}
|
|
1830
|
-
* @param {Number|Vector2} [emitSize
|
|
1831
|
-
* @param {Number}
|
|
1832
|
-
* @param {Number}
|
|
1833
|
-
* @param {Number}
|
|
1859
|
+
* @param {Number} [angle] - Angle to emit the particles
|
|
1860
|
+
* @param {Number|Vector2} [emitSize] - World space size of the emitter (float for circle diameter, vec2 for rect)
|
|
1861
|
+
* @param {Number} [emitTime] - How long to stay alive (0 is forever)
|
|
1862
|
+
* @param {Number} [emitRate] - How many particles per second to spawn, does not emit if 0
|
|
1863
|
+
* @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
1834
1864
|
* @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
|
|
1835
|
-
* @param {Color}
|
|
1836
|
-
* @param {Color}
|
|
1837
|
-
* @param {Color}
|
|
1838
|
-
* @param {Color}
|
|
1839
|
-
* @param {Number}
|
|
1840
|
-
* @param {Number}
|
|
1841
|
-
* @param {Number}
|
|
1842
|
-
* @param {Number}
|
|
1843
|
-
* @param {Number}
|
|
1844
|
-
* @param {Number}
|
|
1845
|
-
* @param {Number}
|
|
1846
|
-
* @param {Number}
|
|
1847
|
-
* @param {Number}
|
|
1848
|
-
* @param {Number}
|
|
1849
|
-
* @param {Number}
|
|
1850
|
-
* @param {Boolean} [collideTiles
|
|
1851
|
-
* @param {Boolean} [additive
|
|
1852
|
-
* @param {Boolean} [randomColorLinear
|
|
1853
|
-
* @param {Number}
|
|
1854
|
-
* @param {Boolean} [localSpace
|
|
1865
|
+
* @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
|
|
1866
|
+
* @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
|
|
1867
|
+
* @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
|
|
1868
|
+
* @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
|
|
1869
|
+
* @param {Number} [particleTime] - How long particles live
|
|
1870
|
+
* @param {Number} [sizeStart] - How big are particles at start
|
|
1871
|
+
* @param {Number} [sizeEnd] - How big are particles at end
|
|
1872
|
+
* @param {Number} [speed] - How fast are particles when spawned
|
|
1873
|
+
* @param {Number} [angleSpeed] - How fast are particles rotating
|
|
1874
|
+
* @param {Number} [damping] - How much to dampen particle speed
|
|
1875
|
+
* @param {Number} [angleDamping] - How much to dampen particle angular speed
|
|
1876
|
+
* @param {Number} [gravityScale] - How much gravity effect particles
|
|
1877
|
+
* @param {Number} [particleConeAngle] - Cone for start particle angle
|
|
1878
|
+
* @param {Number} [fadeRate] - How quick to fade particles at start/end in percent of life
|
|
1879
|
+
* @param {Number} [randomness] - Apply extra randomness percent
|
|
1880
|
+
* @param {Boolean} [collideTiles] - Do particles collide against tiles
|
|
1881
|
+
* @param {Boolean} [additive] - Should particles use addtive blend
|
|
1882
|
+
* @param {Boolean} [randomColorLinear] - Should color be randomized linearly or across each component
|
|
1883
|
+
* @param {Number} [renderOrder] - Render order for particles (additive is above other stuff by default)
|
|
1884
|
+
* @param {Boolean} [localSpace] - Should it be in local space of emitter (world space is default)
|
|
1855
1885
|
*/
|
|
1856
|
-
constructor(
|
|
1886
|
+
constructor(position: Vector2, angle?: number, emitSize?: number | Vector2, emitTime?: number, emitRate?: number, emitConeAngle?: number, tileInfo?: TileInfo, colorStartA?: Color, colorStartB?: Color, colorEndA?: Color, colorEndB?: Color, particleTime?: number, sizeStart?: number, sizeEnd?: number, speed?: number, angleSpeed?: number, damping?: number, angleDamping?: number, gravityScale?: number, particleConeAngle?: number, fadeRate?: number, randomness?: number, collideTiles?: boolean, additive?: boolean, randomColorLinear?: boolean, renderOrder?: number, localSpace?: boolean);
|
|
1857
1887
|
/** @property {Number|Vector2} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
1858
1888
|
emitSize: number | Vector2;
|
|
1859
1889
|
/** @property {Number} - How long to stay alive (0 is forever) */
|
|
@@ -1888,12 +1918,17 @@ declare module "littlejs.esm" {
|
|
|
1888
1918
|
fadeRate: number;
|
|
1889
1919
|
/** @property {Number} - Apply extra randomness percent */
|
|
1890
1920
|
randomness: number;
|
|
1891
|
-
/** @property {
|
|
1921
|
+
/** @property {Boolean} - Should particles use addtive blend */
|
|
1892
1922
|
additive: boolean;
|
|
1893
1923
|
/** @property {Boolean} - Should it be in local space of emitter */
|
|
1894
1924
|
localSpace: boolean;
|
|
1895
|
-
/** @property {Number} - If
|
|
1925
|
+
/** @property {Number} - If non zero the partile is drawn as a trail, stretched in the drection of velocity */
|
|
1896
1926
|
trailScale: number;
|
|
1927
|
+
/** @property {Function} - Callback when particle is destroyed */
|
|
1928
|
+
particleDestroyCallback: any;
|
|
1929
|
+
/** @property {Function} - Callback when particle is created */
|
|
1930
|
+
particleCreateCallback: any;
|
|
1931
|
+
/** @property {Number} - Track particle emit time */
|
|
1897
1932
|
emitTimeBuffer: number;
|
|
1898
1933
|
/** Spawn one particle
|
|
1899
1934
|
* @return {Particle} */
|
|
@@ -1905,12 +1940,42 @@ declare module "littlejs.esm" {
|
|
|
1905
1940
|
*/
|
|
1906
1941
|
export class Particle extends EngineObject {
|
|
1907
1942
|
/**
|
|
1908
|
-
* Create a particle with the given
|
|
1909
|
-
* @param {Vector2}
|
|
1910
|
-
* @param {TileInfo} [tileInfo]
|
|
1911
|
-
* @param {Number}
|
|
1943
|
+
* Create a particle with the given shis.colorStart = undefined;ettings
|
|
1944
|
+
* @param {Vector2} position - World space position of the particle
|
|
1945
|
+
* @param {TileInfo} [tileInfo] - Tile info to render particles
|
|
1946
|
+
* @param {Number} [angle] - Angle to rotate the particle
|
|
1947
|
+
* @param {Color} [colorStart] - Color at start of life
|
|
1948
|
+
* @param {Color} [colorEnd] - Color at end of life
|
|
1949
|
+
* @param {Number} [lifeTime] - How long to live for
|
|
1950
|
+
* @param {Number} [sizeStart] - Angle to rotate the particle
|
|
1951
|
+
* @param {Number} [sizeEnd] - Angle to rotate the particle
|
|
1952
|
+
* @param {Number} [fadeRate] - Angle to rotate the particle
|
|
1953
|
+
* @param {Boolean} [additive] - Angle to rotate the particle
|
|
1954
|
+
* @param {Number} [trailScale] - If a trail, how long to make it
|
|
1955
|
+
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
1956
|
+
* @param {Function} [destroyCallback] - Called when particle dies
|
|
1912
1957
|
*/
|
|
1913
|
-
constructor(
|
|
1958
|
+
constructor(position: Vector2, tileInfo?: TileInfo, angle?: number, colorStart?: Color, colorEnd?: Color, lifeTime?: number, sizeStart?: number, sizeEnd?: number, fadeRate?: number, additive?: boolean, trailScale?: number, localSpaceEmitter?: ParticleEmitter, destroyCallback?: Function);
|
|
1959
|
+
/** @property {Color} - Color at start of life */
|
|
1960
|
+
colorStart: Color;
|
|
1961
|
+
/** @property {Color} - Calculated change in color */
|
|
1962
|
+
colorEndDelta: Color;
|
|
1963
|
+
/** @property {Number} - How long to live for */
|
|
1964
|
+
lifeTime: number;
|
|
1965
|
+
/** @property {Number} - Size at start of life */
|
|
1966
|
+
sizeStart: number;
|
|
1967
|
+
/** @property {Number} - Calculated change in size */
|
|
1968
|
+
sizeEndDelta: number;
|
|
1969
|
+
/** @property {Number} - How quick to fade in/out */
|
|
1970
|
+
fadeRate: number;
|
|
1971
|
+
/** @property {Boolean} - Is it additive */
|
|
1972
|
+
additive: boolean;
|
|
1973
|
+
/** @property {Number} - If a trail, how long to make it */
|
|
1974
|
+
trailScale: number;
|
|
1975
|
+
/** @property {ParticleEmitter} - Parent emitter if local space */
|
|
1976
|
+
localSpaceEmitter: ParticleEmitter;
|
|
1977
|
+
/** @property {Function} - Called when particle dies */
|
|
1978
|
+
destroyCallback: Function;
|
|
1914
1979
|
}
|
|
1915
1980
|
/**
|
|
1916
1981
|
* LittleJS Medal System
|
|
@@ -1925,7 +1990,7 @@ declare module "littlejs.esm" {
|
|
|
1925
1990
|
export const medals: any[];
|
|
1926
1991
|
/** Set to stop medals from being unlockable (like if cheats are enabled)
|
|
1927
1992
|
* @type {Boolean}
|
|
1928
|
-
* @default
|
|
1993
|
+
* @default
|
|
1929
1994
|
* @memberof Settings */
|
|
1930
1995
|
export let medalsPreventUnlock: boolean;
|
|
1931
1996
|
/** Initialize medals with a save name used for storage
|
|
@@ -1957,7 +2022,7 @@ declare module "littlejs.esm" {
|
|
|
1957
2022
|
* @param {Number} id - The unique identifier of the medal
|
|
1958
2023
|
* @param {String} name - Name of the medal
|
|
1959
2024
|
* @param {String} [description] - Description of the medal
|
|
1960
|
-
* @param {String} [icon
|
|
2025
|
+
* @param {String} [icon] - Icon for the medal
|
|
1961
2026
|
* @param {String} [src] - Image location for the medal
|
|
1962
2027
|
*/
|
|
1963
2028
|
constructor(id: number, name: string, description?: string, icon?: string, src?: string);
|
|
@@ -1970,15 +2035,14 @@ declare module "littlejs.esm" {
|
|
|
1970
2035
|
unlock(): void;
|
|
1971
2036
|
unlocked: number;
|
|
1972
2037
|
/** Render a medal
|
|
1973
|
-
* @param {Number} [hidePercent
|
|
2038
|
+
* @param {Number} [hidePercent] - How much to slide the medal off screen
|
|
1974
2039
|
*/
|
|
1975
2040
|
render(hidePercent?: number): void;
|
|
1976
2041
|
/** Render the icon for a medal
|
|
1977
|
-
* @param {
|
|
1978
|
-
* @param {Number} y - Screen space Y position
|
|
2042
|
+
* @param {Vector2} pos - Screen space position
|
|
1979
2043
|
* @param {Number} [size=medalDisplayIconSize] - Screen space size
|
|
1980
2044
|
*/
|
|
1981
|
-
renderIcon(pos:
|
|
2045
|
+
renderIcon(pos: Vector2, size?: number): void;
|
|
1982
2046
|
storageKey(): string;
|
|
1983
2047
|
}
|
|
1984
2048
|
/**
|
|
@@ -2009,21 +2073,21 @@ declare module "littlejs.esm" {
|
|
|
2009
2073
|
* @param {Number} value - The score value */
|
|
2010
2074
|
postScore(id: number, value: number): any;
|
|
2011
2075
|
/** Get scores from a scoreboard
|
|
2012
|
-
* @param {Number} id
|
|
2013
|
-
* @param {String} [user
|
|
2014
|
-
* @param {Number} [social
|
|
2015
|
-
* @param {Number} [skip
|
|
2016
|
-
* @param {Number} [limit
|
|
2017
|
-
* @return {Object}
|
|
2076
|
+
* @param {Number} id - The scoreboard id
|
|
2077
|
+
* @param {String} [user] - A user's id or name
|
|
2078
|
+
* @param {Number} [social] - If true, only social scores will be loaded
|
|
2079
|
+
* @param {Number} [skip] - Number of scores to skip before start
|
|
2080
|
+
* @param {Number} [limit] - Number of scores to include in the list
|
|
2081
|
+
* @return {Object} - The response JSON object
|
|
2018
2082
|
*/
|
|
2019
2083
|
getScores(id: number, user?: string, social?: number, skip?: number, limit?: number): any;
|
|
2020
2084
|
/** Send message to log a view */
|
|
2021
2085
|
logView(): any;
|
|
2022
2086
|
/** Send a message to call a component of the Newgrounds API
|
|
2023
|
-
* @param {String} component
|
|
2024
|
-
* @param {Object} [parameters
|
|
2025
|
-
* @param {Boolean} [async
|
|
2026
|
-
* @return {Object}
|
|
2087
|
+
* @param {String} component - Name of the component
|
|
2088
|
+
* @param {Object} [parameters] - Parameters to use for call
|
|
2089
|
+
* @param {Boolean} [async] - If true, don't wait for response before continuing
|
|
2090
|
+
* @return {Object} - The response JSON object
|
|
2027
2091
|
*/
|
|
2028
2092
|
call(component: string, parameters?: any, async?: boolean): any;
|
|
2029
2093
|
}
|