littlejsengine 1.12.4 → 1.13.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/dist/box2d.wasm.js +630 -0
- package/dist/box2d.wasm.wasm +0 -0
- package/dist/littlejs.d.ts +437 -219
- package/dist/littlejs.esm.js +5950 -5307
- package/dist/littlejs.esm.min.js +4 -1
- package/dist/littlejs.js +5921 -5295
- package/dist/littlejs.min.js +4 -1
- package/dist/littlejs.release.js +5485 -4886
- package/examples/box2d/game.js +37 -42
- package/examples/box2d/gameObjects.js +41 -37
- package/examples/box2d/index.html +2 -2
- package/examples/box2d/scenes.js +24 -20
- package/examples/box2d/tiles.png +0 -0
- package/examples/breakout/game.js +1 -1
- package/examples/breakout/gameObjects.js +2 -2
- package/examples/breakout/index.html +1 -1
- package/examples/breakoutTutorial/README.md +2 -2
- package/examples/breakoutTutorial/game.js +1 -1
- package/examples/breakoutTutorial/index.html +1 -1
- package/examples/empty/index.html +1 -1
- package/examples/htmlMenu/index.html +1 -1
- package/examples/index.html +410 -159
- package/examples/module/game.js +1 -1
- package/examples/module/index.html +1 -1
- package/examples/platformer/game.js +6 -15
- package/examples/platformer/gameCharacter.js +6 -6
- package/examples/platformer/gameEffects.js +74 -57
- package/examples/platformer/gameLevel.js +61 -70
- package/examples/platformer/gameObjects.js +4 -4
- package/examples/platformer/index.html +1 -1
- package/examples/puzzle/index.html +1 -1
- package/examples/shorts/base.html +24 -3
- package/examples/shorts/box2d.js +46 -0
- package/examples/shorts/box2dCar.js +45 -0
- package/examples/shorts/flappyGame.js +52 -0
- package/examples/shorts/helloWorld.js +6 -3
- package/examples/shorts/hillGlideGame.js +56 -0
- package/examples/shorts/landerGame.js +32 -0
- package/examples/shorts/maze.js +47 -0
- package/examples/shorts/medals.js +42 -0
- package/examples/shorts/nineSlice.js +21 -0
- package/examples/shorts/piano.js +52 -0
- package/examples/shorts/platformer.js +24 -20
- package/examples/shorts/{pong.js → pongGame.js} +1 -1
- package/examples/shorts/postProcess.js +45 -0
- package/examples/shorts/raycasting.js +71 -0
- package/examples/shorts/slidingPuzzle.js +42 -0
- package/examples/shorts/spaceGame.js +56 -0
- package/examples/shorts/starfield.js +17 -0
- package/examples/shorts/tileLayer.js +3 -5
- package/examples/shorts/tiles.png +0 -0
- package/examples/shorts/tiltedView.js +8 -7
- package/examples/shorts/topDown.js +18 -26
- package/examples/shorts/uiSystem.js +36 -0
- package/examples/starter/build.bat +6 -1
- package/examples/starter/game.js +4 -2
- package/examples/starter/index.html +23 -13
- package/examples/stress/index.html +2 -3
- package/examples/style.css +136 -0
- package/examples/typescript/build.js +1 -2
- package/examples/typescript/game.js +2 -2
- package/examples/typescript/game.ts +1 -1
- package/examples/typescript/index.html +1 -1
- package/examples/uiSystem/game.js +9 -25
- package/examples/uiSystem/index.html +1 -1
- package/package.json +1 -1
- package/plugins/box2d.js +29 -35
- package/plugins/drawUtilities.js +126 -0
- package/plugins/newgrounds.js +1 -1
- package/plugins/pluginExport.js +8 -2
- package/plugins/postProcess.js +2 -2
- package/plugins/uiSystem.js +162 -68
- package/plugins/zzfxm.js +1 -1
- package/reference.md +10 -10
- package/src/engine.js +59 -39
- package/src/engineAudio.js +38 -20
- package/src/engineBuild.bat +6 -1
- package/src/engineBuild.js +32 -7
- package/src/engineDebug.js +53 -26
- package/src/engineDraw.js +108 -57
- package/src/engineExport.js +22 -9
- package/src/engineInput.js +112 -40
- package/src/engineObject.js +68 -67
- package/src/engineParticles.js +26 -9
- package/src/engineSettings.js +15 -16
- package/src/engineTileLayer.js +312 -153
- package/src/engineUtilities.js +198 -130
- package/src/engineWebGL.js +58 -35
package/dist/littlejs.d.ts
CHANGED
|
@@ -59,20 +59,34 @@ declare module "littlejsengine" {
|
|
|
59
59
|
* @default false
|
|
60
60
|
* @memberof Engine */
|
|
61
61
|
export let paused: boolean;
|
|
62
|
+
/** Get if game is paused
|
|
63
|
+
* @return {boolean}
|
|
64
|
+
* @memberof Engine */
|
|
65
|
+
export function getPaused(): boolean;
|
|
62
66
|
/** Set if game is paused
|
|
63
|
-
* @param {boolean} isPaused
|
|
67
|
+
* @param {boolean} [isPaused]
|
|
64
68
|
* @memberof Engine */
|
|
65
|
-
export function setPaused(isPaused
|
|
69
|
+
export function setPaused(isPaused?: boolean): void;
|
|
66
70
|
/** Startup LittleJS engine with your callback functions
|
|
67
|
-
* @param {Function|function():Promise} gameInit - Called once after the engine starts up
|
|
68
|
-
* @param {Function} gameUpdate - Called every frame before objects are updated
|
|
69
|
-
* @param {Function} gameUpdatePost - Called after physics and objects are updated, even when paused
|
|
70
|
-
* @param {Function} gameRender - Called before objects are rendered, for drawing
|
|
71
|
-
* @param {Function} gameRenderPost - Called after objects are rendered,
|
|
72
|
-
* @param {Array<string>} [imageSources=[]] - List of
|
|
73
|
-
* @param {HTMLElement} [rootElement] - Root element to attach to,
|
|
71
|
+
* @param {Function|function():Promise} gameInit - Called once after the engine starts up, can be async for loading
|
|
72
|
+
* @param {Function} gameUpdate - Called every frame before objects are updated (60fps), use for game logic
|
|
73
|
+
* @param {Function} gameUpdatePost - Called after physics and objects are updated, even when paused, use for UI updates
|
|
74
|
+
* @param {Function} gameRender - Called before objects are rendered, use for drawing backgrounds/world elements
|
|
75
|
+
* @param {Function} gameRenderPost - Called after objects are rendered, use for drawing UI/overlays
|
|
76
|
+
* @param {Array<string>} [imageSources=[]] - List of image file paths to preload (e.g., ['player.png', 'tiles.png'])
|
|
77
|
+
* @param {HTMLElement} [rootElement] - Root DOM element to attach canvas to, defaults to document.body
|
|
78
|
+
* @example
|
|
79
|
+
* // Basic engine startup
|
|
80
|
+
* engineInit(
|
|
81
|
+
* () => { console.log('Game initialized!'); }, // gameInit
|
|
82
|
+
* () => { updatePlayer(); }, // gameUpdate
|
|
83
|
+
* () => { updateUI(); }, // gameUpdatePost
|
|
84
|
+
* () => { drawBackground(); }, // gameRender
|
|
85
|
+
* () => { drawHUD(); }, // gameRenderPost
|
|
86
|
+
* ['tiles.png', 'tilesLevel.png'] // images to load
|
|
87
|
+
* );
|
|
74
88
|
* @memberof Engine */
|
|
75
|
-
export function engineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: Array<string>, rootElement?: HTMLElement): void
|
|
89
|
+
export function engineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: Array<string>, rootElement?: HTMLElement): Promise<void>;
|
|
76
90
|
/** Update each engine object, remove destroyed objects, and update time
|
|
77
91
|
* @memberof Engine */
|
|
78
92
|
export function engineObjectsUpdate(): void;
|
|
@@ -131,9 +145,9 @@ declare module "littlejsengine" {
|
|
|
131
145
|
export let showWatermark: boolean;
|
|
132
146
|
/** Asserts if the expression is false, does not do anything in release builds
|
|
133
147
|
* @param {boolean} assert
|
|
134
|
-
* @param {Object} [output]
|
|
148
|
+
* @param {...Object} [output] - error message output
|
|
135
149
|
* @memberof Debug */
|
|
136
|
-
export function ASSERT(assert: boolean, output?: any): void;
|
|
150
|
+
export function ASSERT(assert: boolean, ...output?: any[]): void;
|
|
137
151
|
/** Draw a debug rectangle in world space
|
|
138
152
|
* @param {Vector2} pos
|
|
139
153
|
* @param {Vector2} [size=Vector2()]
|
|
@@ -176,13 +190,13 @@ declare module "littlejsengine" {
|
|
|
176
190
|
* @memberof Debug */
|
|
177
191
|
export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
|
|
178
192
|
/** Draw a debug combined axis aligned bounding box in world space
|
|
179
|
-
* @param {Vector2}
|
|
180
|
-
* @param {Vector2}
|
|
181
|
-
* @param {Vector2}
|
|
182
|
-
* @param {Vector2}
|
|
193
|
+
* @param {Vector2} posA
|
|
194
|
+
* @param {Vector2} sizeA
|
|
195
|
+
* @param {Vector2} posB
|
|
196
|
+
* @param {Vector2} sizeB
|
|
183
197
|
* @param {string} [color]
|
|
184
198
|
* @memberof Debug */
|
|
185
|
-
export function debugOverlap(
|
|
199
|
+
export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: string): void;
|
|
186
200
|
/** Draw a debug axis aligned bounding box in world space
|
|
187
201
|
* @param {string} text
|
|
188
202
|
* @param {Vector2} pos
|
|
@@ -200,11 +214,11 @@ declare module "littlejsengine" {
|
|
|
200
214
|
* @memberof Debug */
|
|
201
215
|
export function debugScreenshot(): void;
|
|
202
216
|
/** Save a canvas to disk
|
|
203
|
-
* @param {HTMLCanvasElement} canvas
|
|
204
|
-
* @param {string}
|
|
205
|
-
* @param {string}
|
|
217
|
+
* @param {HTMLCanvasElement|OffscreenCanvas} canvas
|
|
218
|
+
* @param {string} [filename]
|
|
219
|
+
* @param {string} [type]
|
|
206
220
|
* @memberof Debug */
|
|
207
|
-
export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string): void;
|
|
221
|
+
export function debugSaveCanvas(canvas: HTMLCanvasElement | OffscreenCanvas, filename?: string, type?: string): void;
|
|
208
222
|
/** Save a text file to disk
|
|
209
223
|
* @param {string} text
|
|
210
224
|
* @param {string} [filename]
|
|
@@ -238,6 +252,11 @@ declare module "littlejsengine" {
|
|
|
238
252
|
* @default Vector2()
|
|
239
253
|
* @memberof Settings */
|
|
240
254
|
export let cameraPos: Vector2;
|
|
255
|
+
/** Rotation angle of camera in world space
|
|
256
|
+
* @type {number}
|
|
257
|
+
* @default
|
|
258
|
+
* @memberof Settings */
|
|
259
|
+
export let cameraAngle: number;
|
|
241
260
|
/** Scale of camera in world space
|
|
242
261
|
* @type {number}
|
|
243
262
|
* @default
|
|
@@ -316,7 +335,7 @@ declare module "littlejsengine" {
|
|
|
316
335
|
* @type {number}
|
|
317
336
|
* @default
|
|
318
337
|
* @memberof Settings */
|
|
319
|
-
export let
|
|
338
|
+
export let objectDefaultRestitution: number;
|
|
320
339
|
/** How much to slow when touching (0-1)
|
|
321
340
|
* @type {number}
|
|
322
341
|
* @default
|
|
@@ -343,12 +362,6 @@ declare module "littlejsengine" {
|
|
|
343
362
|
* @default
|
|
344
363
|
* @memberof Settings */
|
|
345
364
|
export let glEnable: boolean;
|
|
346
|
-
/** Fixes slow rendering in some browsers by not compositing the WebGL canvas
|
|
347
|
-
* - Must be set before startup to take effect
|
|
348
|
-
* @type {boolean}
|
|
349
|
-
* @default
|
|
350
|
-
* @memberof Settings */
|
|
351
|
-
export let glOverlay: boolean;
|
|
352
365
|
/** Should gamepads be allowed
|
|
353
366
|
* @type {boolean}
|
|
354
367
|
* @default
|
|
@@ -430,6 +443,10 @@ declare module "littlejsengine" {
|
|
|
430
443
|
* @param {Vector2} pos
|
|
431
444
|
* @memberof Settings */
|
|
432
445
|
export function setCameraPos(pos: Vector2): void;
|
|
446
|
+
/** Set angle of camera in world space
|
|
447
|
+
* @param {number} angle
|
|
448
|
+
* @memberof Settings */
|
|
449
|
+
export function setCameraAngle(angle: number): void;
|
|
433
450
|
/** Set scale of camera in world space
|
|
434
451
|
* @param {number} scale
|
|
435
452
|
* @memberof Settings */
|
|
@@ -465,11 +482,7 @@ declare module "littlejsengine" {
|
|
|
465
482
|
/** Set if webgl rendering is enabled
|
|
466
483
|
* @param {boolean} enable
|
|
467
484
|
* @memberof Settings */
|
|
468
|
-
export function
|
|
469
|
-
/** Set to not composite the WebGL canvas
|
|
470
|
-
* @param {boolean} overlay
|
|
471
|
-
* @memberof Settings */
|
|
472
|
-
export function setGlOverlay(overlay: boolean): void;
|
|
485
|
+
export function setGLEnable(enable: boolean): void;
|
|
473
486
|
/** Set default size of tiles in pixels
|
|
474
487
|
* @param {Vector2} size
|
|
475
488
|
* @memberof Settings */
|
|
@@ -495,9 +508,9 @@ declare module "littlejsengine" {
|
|
|
495
508
|
* @memberof Settings */
|
|
496
509
|
export function setObjectDefaultAngleDamping(damp: number): void;
|
|
497
510
|
/** Set how much to bounce when a collision occur
|
|
498
|
-
* @param {number}
|
|
511
|
+
* @param {number} restitution
|
|
499
512
|
* @memberof Settings */
|
|
500
|
-
export function
|
|
513
|
+
export function setObjectDefaultRestitution(restitution: number): void;
|
|
501
514
|
/** Set how much to slow when touching
|
|
502
515
|
* @param {number} friction
|
|
503
516
|
* @memberof Settings */
|
|
@@ -609,18 +622,16 @@ declare module "littlejsengine" {
|
|
|
609
622
|
* @return {number}
|
|
610
623
|
* @memberof Utilities */
|
|
611
624
|
export function abs(value: number): number;
|
|
612
|
-
/** Returns lowest
|
|
613
|
-
* @param {number}
|
|
614
|
-
* @param {number} valueB
|
|
625
|
+
/** Returns lowest value passed in
|
|
626
|
+
* @param {...number} values
|
|
615
627
|
* @return {number}
|
|
616
628
|
* @memberof Utilities */
|
|
617
|
-
export function min(
|
|
618
|
-
/** Returns highest
|
|
619
|
-
* @param {number}
|
|
620
|
-
* @param {number} valueB
|
|
629
|
+
export function min(...values: number[]): number;
|
|
630
|
+
/** Returns highest value passed in
|
|
631
|
+
* @param {...number} values
|
|
621
632
|
* @return {number}
|
|
622
633
|
* @memberof Utilities */
|
|
623
|
-
export function max(
|
|
634
|
+
export function max(...values: number[]): number;
|
|
624
635
|
/** Returns the sign of value passed in
|
|
625
636
|
* @param {number} value
|
|
626
637
|
* @return {number}
|
|
@@ -654,13 +665,13 @@ declare module "littlejsengine" {
|
|
|
654
665
|
* @memberof Utilities */
|
|
655
666
|
export function distanceWrap(valueA: number, valueB: number, wrapSize?: number): number;
|
|
656
667
|
/** Linearly interpolates between values passed in with wrapping
|
|
657
|
-
* @param {number} percent
|
|
658
668
|
* @param {number} valueA
|
|
659
669
|
* @param {number} valueB
|
|
670
|
+
* @param {number} percent
|
|
660
671
|
* @param {number} [wrapSize]
|
|
661
672
|
* @returns {number}
|
|
662
673
|
* @memberof Utilities */
|
|
663
|
-
export function lerpWrap(
|
|
674
|
+
export function lerpWrap(valueA: number, valueB: number, percent: number, wrapSize?: number): number;
|
|
664
675
|
/** Returns signed wrapped distance between the two angles passed in
|
|
665
676
|
* @param {number} angleA
|
|
666
677
|
* @param {number} angleB
|
|
@@ -668,19 +679,19 @@ declare module "littlejsengine" {
|
|
|
668
679
|
* @memberof Utilities */
|
|
669
680
|
export function distanceAngle(angleA: number, angleB: number): number;
|
|
670
681
|
/** Linearly interpolates between the angles passed in with wrapping
|
|
671
|
-
* @param {number} percent
|
|
672
682
|
* @param {number} angleA
|
|
673
683
|
* @param {number} angleB
|
|
684
|
+
* @param {number} percent
|
|
674
685
|
* @returns {number}
|
|
675
686
|
* @memberof Utilities */
|
|
676
|
-
export function lerpAngle(
|
|
687
|
+
export function lerpAngle(angleA: number, angleB: number, percent: number): number;
|
|
677
688
|
/** Linearly interpolates between values passed in using percent
|
|
678
|
-
* @param {number} percent
|
|
679
689
|
* @param {number} valueA
|
|
680
690
|
* @param {number} valueB
|
|
691
|
+
* @param {number} percent
|
|
681
692
|
* @return {number}
|
|
682
693
|
* @memberof Utilities */
|
|
683
|
-
export function lerp(
|
|
694
|
+
export function lerp(valueA: number, valueB: number, percent: number): number;
|
|
684
695
|
/** Applies smoothstep function to the percentage value
|
|
685
696
|
* @param {number} percent
|
|
686
697
|
* @return {number}
|
|
@@ -719,6 +730,11 @@ declare module "littlejsengine" {
|
|
|
719
730
|
* @return {string}
|
|
720
731
|
* @memberof Utilities */
|
|
721
732
|
export function formatTime(t: number): string;
|
|
733
|
+
/** Fetches a JSON file from a URL and returns the parsed JSON object. Must be used with await!
|
|
734
|
+
* @param {string} url - URL of JSON file
|
|
735
|
+
* @return {Promise<object>}
|
|
736
|
+
* @memberof Utilities */
|
|
737
|
+
export function fetchJSON(url: string): Promise<object>;
|
|
722
738
|
/** Random global functions
|
|
723
739
|
* @namespace Random */
|
|
724
740
|
/** Returns a random value between the two values passed in
|
|
@@ -748,7 +764,7 @@ declare module "littlejsengine" {
|
|
|
748
764
|
* @param {number} [length]
|
|
749
765
|
* @return {Vector2}
|
|
750
766
|
* @memberof Random */
|
|
751
|
-
export function
|
|
767
|
+
export function randVec2(length?: number): Vector2;
|
|
752
768
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
753
769
|
* @param {Color} [colorA=(1,1,1,1)]
|
|
754
770
|
* @param {Color} [colorB=(0,0,0,1)]
|
|
@@ -768,8 +784,8 @@ declare module "littlejsengine" {
|
|
|
768
784
|
*/
|
|
769
785
|
export class RandomGenerator {
|
|
770
786
|
/** Create a random number generator with the seed passed in
|
|
771
|
-
* @param {number} seed - Starting seed */
|
|
772
|
-
constructor(seed
|
|
787
|
+
* @param {number} [seed] - Starting seed or engine default seed */
|
|
788
|
+
constructor(seed?: number);
|
|
773
789
|
/** @property {number} - random seed */
|
|
774
790
|
seed: number;
|
|
775
791
|
/** Returns a seeded random value between the two values passed in
|
|
@@ -782,9 +798,26 @@ declare module "littlejsengine" {
|
|
|
782
798
|
* @param {number} [valueB]
|
|
783
799
|
* @return {number} */
|
|
784
800
|
int(valueA: number, valueB?: number): number;
|
|
801
|
+
/** Randomly returns true or false given the chance of true passed in
|
|
802
|
+
* @param {number} [chance]
|
|
803
|
+
* @return {boolean} */
|
|
804
|
+
bool(chance?: number): boolean;
|
|
785
805
|
/** Randomly returns either -1 or 1 deterministically
|
|
786
806
|
* @return {number} */
|
|
787
807
|
sign(): number;
|
|
808
|
+
/** Returns a seeded random value between the two values passed in with a random sign
|
|
809
|
+
* @param {number} [valueA]
|
|
810
|
+
* @param {number} [valueB]
|
|
811
|
+
* @return {number} */
|
|
812
|
+
floatSign(valueA?: number, valueB?: number): number;
|
|
813
|
+
/** Returns a random angle between -PI and PI
|
|
814
|
+
* @return {number} */
|
|
815
|
+
angle(): number;
|
|
816
|
+
/** Returns a seeded vec2 with size between the two values passed in
|
|
817
|
+
* @param {number} valueA
|
|
818
|
+
* @param {number} [valueB]
|
|
819
|
+
* @return {Vector2} */
|
|
820
|
+
vec2(valueA?: number, valueB?: number): Vector2;
|
|
788
821
|
}
|
|
789
822
|
/**
|
|
790
823
|
* 2D Vector object with vector math library
|
|
@@ -862,6 +895,11 @@ declare module "littlejsengine" {
|
|
|
862
895
|
* @param {Vector2} v - other vector
|
|
863
896
|
* @return {number} */
|
|
864
897
|
cross(v: Vector2): number;
|
|
898
|
+
/** Returns a copy this vector reflected by the surface normal
|
|
899
|
+
* @param {Vector2} normal - surface normal (should be normalized)
|
|
900
|
+
* @param {number} restitution - how much to bounce, 1 is perfect bounce, 0 is no bounce
|
|
901
|
+
* @return {Vector2} */
|
|
902
|
+
reflect(normal: Vector2, restitution?: number): Vector2;
|
|
865
903
|
/** Returns the clockwise angle of this vector, up is angle 0
|
|
866
904
|
* @return {number} */
|
|
867
905
|
angle(): number;
|
|
@@ -884,9 +922,16 @@ declare module "littlejsengine" {
|
|
|
884
922
|
/** Returns a copy of this vector that has been inverted
|
|
885
923
|
* @return {Vector2} */
|
|
886
924
|
invert(): Vector2;
|
|
925
|
+
/** Returns a copy of this vector absolute values
|
|
926
|
+
* @return {Vector2} */
|
|
927
|
+
abs(): Vector2;
|
|
887
928
|
/** Returns a copy of this vector with each axis floored
|
|
888
929
|
* @return {Vector2} */
|
|
889
930
|
floor(): Vector2;
|
|
931
|
+
/** Returns new vec2 with modded values
|
|
932
|
+
* @param {number} [divisor]
|
|
933
|
+
* @return {Vector2} */
|
|
934
|
+
mod(divisor?: number): Vector2;
|
|
890
935
|
/** Returns the area this vector covers as a rectangle
|
|
891
936
|
* @return {number} */
|
|
892
937
|
area(): number;
|
|
@@ -913,7 +958,7 @@ declare module "littlejsengine" {
|
|
|
913
958
|
* let a = new Color; // white
|
|
914
959
|
* let b = new Color(1, 0, 0); // red
|
|
915
960
|
* let c = new Color(0, 0, 0, 0); // transparent black
|
|
916
|
-
* let d = rgb(0, 0, 1);
|
|
961
|
+
* let d = rgb(0, 0, 1); // blue using rgb color
|
|
917
962
|
* let e = hsl(.3, 1, .5); // green using hsl color
|
|
918
963
|
*/
|
|
919
964
|
export class Color {
|
|
@@ -1085,10 +1130,18 @@ declare module "littlejsengine" {
|
|
|
1085
1130
|
* @type {Color}
|
|
1086
1131
|
* @memberof Utilities */
|
|
1087
1132
|
export const WHITE: Color;
|
|
1133
|
+
/** Color - Clear White #ffffff with 0 alpha
|
|
1134
|
+
* @type {Color}
|
|
1135
|
+
* @memberof Utilities */
|
|
1136
|
+
export const CLEAR_WHITE: Color;
|
|
1088
1137
|
/** Color - Black #000000
|
|
1089
1138
|
* @type {Color}
|
|
1090
1139
|
* @memberof Utilities */
|
|
1091
1140
|
export const BLACK: Color;
|
|
1141
|
+
/** Color - Clear Black #000000 with 0 alpha
|
|
1142
|
+
* @type {Color}
|
|
1143
|
+
* @memberof Utilities */
|
|
1144
|
+
export const CLEAR_BLACK: Color;
|
|
1092
1145
|
/** Color - Gray #808080
|
|
1093
1146
|
* @type {Color}
|
|
1094
1147
|
* @memberof Utilities */
|
|
@@ -1165,6 +1218,8 @@ declare module "littlejsengine" {
|
|
|
1165
1218
|
textureIndex: number;
|
|
1166
1219
|
/** @property {number} - How many pixels padding around tiles */
|
|
1167
1220
|
padding: number;
|
|
1221
|
+
/** @property {TextureInfo} - The texture info for this tile */
|
|
1222
|
+
textureInfo: TextureInfo;
|
|
1168
1223
|
/** Returns a copy of this tile offset by a vector
|
|
1169
1224
|
* @param {Vector2} offset - Offset to apply in pixels
|
|
1170
1225
|
* @return {TileInfo}
|
|
@@ -1175,26 +1230,31 @@ declare module "littlejsengine" {
|
|
|
1175
1230
|
* @return {TileInfo}
|
|
1176
1231
|
*/
|
|
1177
1232
|
frame(frame: number): TileInfo;
|
|
1178
|
-
/**
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1233
|
+
/**
|
|
1234
|
+
* Set this tile to use a full image
|
|
1235
|
+
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1236
|
+
* @param {WebGLTexture} [glTexture] - webgl texture
|
|
1237
|
+
* @return {TileInfo}
|
|
1238
|
+
*/
|
|
1239
|
+
setFullImage(image: HTMLImageElement | OffscreenCanvas, glTexture?: WebGLTexture): TileInfo;
|
|
1182
1240
|
}
|
|
1183
1241
|
/** Texture Info - Stores info about each texture */
|
|
1184
1242
|
export class TextureInfo {
|
|
1185
1243
|
/**
|
|
1186
1244
|
* Create a TextureInfo, called automatically by the engine
|
|
1187
|
-
* @param {HTMLImageElement} image
|
|
1245
|
+
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1246
|
+
* @param {WebGLTexture} [glTexture] - webgl texture
|
|
1188
1247
|
*/
|
|
1189
|
-
constructor(image: HTMLImageElement);
|
|
1248
|
+
constructor(image: HTMLImageElement | OffscreenCanvas, glTexture?: WebGLTexture);
|
|
1190
1249
|
/** @property {HTMLImageElement} - image source */
|
|
1191
|
-
image: HTMLImageElement;
|
|
1250
|
+
image: OffscreenCanvas | HTMLImageElement;
|
|
1192
1251
|
/** @property {Vector2} - size of the image */
|
|
1193
1252
|
size: Vector2;
|
|
1194
1253
|
/** @property {Vector2} - inverse of the size, cached for rendering */
|
|
1195
1254
|
sizeInverse: Vector2;
|
|
1196
1255
|
/** @property {WebGLTexture} - webgl texture */
|
|
1197
1256
|
glTexture: WebGLTexture;
|
|
1257
|
+
createWebGLTexture(): void;
|
|
1198
1258
|
}
|
|
1199
1259
|
/**
|
|
1200
1260
|
* LittleJS Drawing System
|
|
@@ -1286,9 +1346,9 @@ declare module "littlejsengine" {
|
|
|
1286
1346
|
* @param {number} [lineWidth=0]
|
|
1287
1347
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1288
1348
|
* @param {boolean} [screenSpace=false]
|
|
1289
|
-
* @param {CanvasRenderingContext2D} [context=
|
|
1349
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1290
1350
|
* @memberof Draw */
|
|
1291
|
-
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1351
|
+
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1292
1352
|
/** Draw colored ellipse using passed in point
|
|
1293
1353
|
* @param {Vector2} pos
|
|
1294
1354
|
* @param {number} [width=1]
|
|
@@ -1298,9 +1358,9 @@ declare module "littlejsengine" {
|
|
|
1298
1358
|
* @param {number} [lineWidth=0]
|
|
1299
1359
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1300
1360
|
* @param {boolean} [screenSpace=false]
|
|
1301
|
-
* @param {CanvasRenderingContext2D} [context=
|
|
1361
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1302
1362
|
* @memberof Draw */
|
|
1303
|
-
export function drawEllipse(pos: Vector2, width?: number, height?: number, angle?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1363
|
+
export function drawEllipse(pos: Vector2, width?: number, height?: number, angle?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1304
1364
|
/** Draw colored circle using passed in point
|
|
1305
1365
|
* @param {Vector2} pos
|
|
1306
1366
|
* @param {number} [radius=1]
|
|
@@ -1308,19 +1368,19 @@ declare module "littlejsengine" {
|
|
|
1308
1368
|
* @param {number} [lineWidth=0]
|
|
1309
1369
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1310
1370
|
* @param {boolean} [screenSpace=false]
|
|
1311
|
-
* @param {CanvasRenderingContext2D} [context=
|
|
1371
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1312
1372
|
* @memberof Draw */
|
|
1313
|
-
export function drawCircle(pos: Vector2, radius?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1373
|
+
export function drawCircle(pos: Vector2, radius?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1314
1374
|
/** Draw directly to a 2d canvas context in world space
|
|
1315
1375
|
* @param {Vector2} pos
|
|
1316
1376
|
* @param {Vector2} size
|
|
1317
1377
|
* @param {number} angle
|
|
1318
|
-
* @param {boolean} mirror
|
|
1319
|
-
* @param {Function} drawFunction
|
|
1378
|
+
* @param {boolean} [mirror]
|
|
1379
|
+
* @param {Function} [drawFunction]
|
|
1320
1380
|
* @param {boolean} [screenSpace=false]
|
|
1321
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=
|
|
1381
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1322
1382
|
* @memberof Draw */
|
|
1323
|
-
export function drawCanvas2D(pos: Vector2, size: Vector2, angle
|
|
1383
|
+
export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1324
1384
|
/** Draw text on main canvas in world space
|
|
1325
1385
|
* Automatically splits new lines into rows
|
|
1326
1386
|
* @param {string} text
|
|
@@ -1332,7 +1392,7 @@ declare module "littlejsengine" {
|
|
|
1332
1392
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1333
1393
|
* @param {string} [font=fontDefault]
|
|
1334
1394
|
* @param {number} [maxWidth]
|
|
1335
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=
|
|
1395
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1336
1396
|
* @memberof Draw */
|
|
1337
1397
|
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1338
1398
|
/** Draw text on overlay canvas in world space
|
|
@@ -1365,7 +1425,7 @@ declare module "littlejsengine" {
|
|
|
1365
1425
|
/** Enable normal or additive blend mode
|
|
1366
1426
|
* @param {boolean} [additive]
|
|
1367
1427
|
* @param {boolean} [useWebGL=glEnable]
|
|
1368
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context
|
|
1428
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1369
1429
|
* @memberof Draw */
|
|
1370
1430
|
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1371
1431
|
/** Combines all LittleJS canvases onto the main canvas and clears them
|
|
@@ -1452,11 +1512,10 @@ declare module "littlejsengine" {
|
|
|
1452
1512
|
* @return {WebGLShader}
|
|
1453
1513
|
* @memberof WebGL */
|
|
1454
1514
|
export function glCompileShader(source: string, type: number): WebGLShader;
|
|
1455
|
-
/**
|
|
1515
|
+
/** Flush any sprites still in the buffer and copy to main canvas
|
|
1456
1516
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1457
|
-
* @param {boolean} [forceDraw]
|
|
1458
1517
|
* @memberof WebGL */
|
|
1459
|
-
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
|
|
1518
|
+
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1460
1519
|
/** Create WebGL program with given shaders
|
|
1461
1520
|
* @param {String} vsSource
|
|
1462
1521
|
* @param {String} fsSource
|
|
@@ -1464,37 +1523,42 @@ declare module "littlejsengine" {
|
|
|
1464
1523
|
* @memberof WebGL */
|
|
1465
1524
|
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
|
|
1466
1525
|
/** Create WebGL texture from an image and init the texture settings
|
|
1467
|
-
* @param {HTMLImageElement} image
|
|
1526
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} [image]
|
|
1468
1527
|
* @return {WebGLTexture}
|
|
1469
1528
|
* @memberof WebGL */
|
|
1470
|
-
export function glCreateTexture(image
|
|
1529
|
+
export function glCreateTexture(image?: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas): WebGLTexture;
|
|
1530
|
+
/** Deletes a WebGL texture
|
|
1531
|
+
* @param {WebGLTexture} [texture]
|
|
1532
|
+
* @memberof WebGL */
|
|
1533
|
+
export function glDeleteTexture(texture?: WebGLTexture): void;
|
|
1471
1534
|
/** Set WebGL texture data from an image
|
|
1472
1535
|
* @param {WebGLTexture} texture
|
|
1473
|
-
* @param {HTMLImageElement} image
|
|
1536
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} image
|
|
1474
1537
|
* @memberof WebGL */
|
|
1475
|
-
export function glSetTextureData(texture: WebGLTexture, image: HTMLImageElement): void;
|
|
1538
|
+
export function glSetTextureData(texture: WebGLTexture, image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas): void;
|
|
1476
1539
|
/** Add a sprite to the gl draw list, used by all gl draw functions
|
|
1477
1540
|
* @param {Number} x
|
|
1478
1541
|
* @param {Number} y
|
|
1479
1542
|
* @param {Number} sizeX
|
|
1480
1543
|
* @param {Number} sizeY
|
|
1481
|
-
* @param {Number} angle
|
|
1482
|
-
* @param {Number} uv0X
|
|
1483
|
-
* @param {Number} uv0Y
|
|
1484
|
-
* @param {Number} uv1X
|
|
1485
|
-
* @param {Number} uv1Y
|
|
1544
|
+
* @param {Number} [angle]
|
|
1545
|
+
* @param {Number} [uv0X]
|
|
1546
|
+
* @param {Number} [uv0Y]
|
|
1547
|
+
* @param {Number} [uv1X]
|
|
1548
|
+
* @param {Number} [uv1Y]
|
|
1486
1549
|
* @param {Number} [rgba=-1] - white is -1
|
|
1487
1550
|
* @param {Number} [rgbaAdditive=0] - black is 0
|
|
1488
1551
|
* @memberof WebGL */
|
|
1489
|
-
export function glDraw(x: number, y: number, sizeX: number, sizeY: number, angle
|
|
1552
|
+
export function glDraw(x: number, y: number, sizeX: number, sizeY: number, angle?: number, uv0X?: number, uv0Y?: number, uv1X?: number, uv1Y?: number, rgba?: number, rgbaAdditive?: number): void;
|
|
1490
1553
|
/** Draw all sprites and clear out the buffer, called automatically by the system whenever necessary
|
|
1491
1554
|
* @memberof WebGL */
|
|
1492
1555
|
export function glFlush(): void;
|
|
1493
1556
|
/** Set the WebGl texture, called automatically if using multiple textures
|
|
1494
1557
|
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1495
1558
|
* @param {WebGLTexture} texture
|
|
1559
|
+
* @param {boolean} wrap - Should the texture wrap or clamp
|
|
1496
1560
|
* @memberof WebGL */
|
|
1497
|
-
export function glSetTexture(texture: WebGLTexture): void;
|
|
1561
|
+
export function glSetTexture(texture: WebGLTexture, wrap?: boolean): void;
|
|
1498
1562
|
/** Set anti-aliasing for webgl canvas
|
|
1499
1563
|
* @param {boolean} [antialias]
|
|
1500
1564
|
* @memberof WebGL */
|
|
@@ -1548,34 +1612,33 @@ declare module "littlejsengine" {
|
|
|
1548
1612
|
export function keyDirection(up?: string, down?: string, left?: string, right?: string): Vector2;
|
|
1549
1613
|
/** Clears all input
|
|
1550
1614
|
* @memberof Input */
|
|
1551
|
-
export function
|
|
1552
|
-
/**
|
|
1553
|
-
* LittleJS Input System
|
|
1554
|
-
* - Tracks keyboard down, pressed, and released
|
|
1555
|
-
* - Tracks mouse buttons, position, and wheel
|
|
1556
|
-
* - Tracks multiple analog gamepads
|
|
1557
|
-
* - Touch input is handled as mouse input
|
|
1558
|
-
* - Virtual gamepad for touch devices
|
|
1559
|
-
* @namespace Input
|
|
1560
|
-
*/
|
|
1561
|
-
/** Returns true if device key is down
|
|
1615
|
+
export function inputClear(): void;
|
|
1616
|
+
/** Clears an input key state
|
|
1562
1617
|
* @param {string|number} key
|
|
1563
1618
|
* @param {number} [device]
|
|
1619
|
+
* @param {boolean} [clearDown=true]
|
|
1620
|
+
* @param {boolean} [clearPressed=true]
|
|
1621
|
+
* @param {boolean} [clearReleased=true]
|
|
1622
|
+
* @memberof Input */
|
|
1623
|
+
export function inputClearKey(key: string | number, device?: number, clearDown?: boolean, clearPressed?: boolean, clearReleased?: boolean): void;
|
|
1624
|
+
/** Returns true if mouse button is down
|
|
1625
|
+
* @function
|
|
1626
|
+
* @param {number} button
|
|
1564
1627
|
* @return {boolean}
|
|
1565
1628
|
* @memberof Input */
|
|
1566
|
-
export function mouseIsDown(
|
|
1567
|
-
/** Returns true if
|
|
1568
|
-
* @
|
|
1569
|
-
* @param {number}
|
|
1629
|
+
export function mouseIsDown(button: number): boolean;
|
|
1630
|
+
/** Returns true if mouse button was pressed
|
|
1631
|
+
* @function
|
|
1632
|
+
* @param {number} button
|
|
1570
1633
|
* @return {boolean}
|
|
1571
1634
|
* @memberof Input */
|
|
1572
|
-
export function mouseWasPressed(
|
|
1573
|
-
/** Returns true if
|
|
1574
|
-
* @
|
|
1575
|
-
* @param {number}
|
|
1635
|
+
export function mouseWasPressed(button: number): boolean;
|
|
1636
|
+
/** Returns true if mouse button was released
|
|
1637
|
+
* @function
|
|
1638
|
+
* @param {number} button
|
|
1576
1639
|
* @return {boolean}
|
|
1577
1640
|
* @memberof Input */
|
|
1578
|
-
export function mouseWasReleased(
|
|
1641
|
+
export function mouseWasReleased(button: number): boolean;
|
|
1579
1642
|
/** Mouse pos in world space
|
|
1580
1643
|
* @type {Vector2}
|
|
1581
1644
|
* @memberof Input */
|
|
@@ -1584,6 +1647,14 @@ declare module "littlejsengine" {
|
|
|
1584
1647
|
* @type {Vector2}
|
|
1585
1648
|
* @memberof Input */
|
|
1586
1649
|
export let mousePosScreen: Vector2;
|
|
1650
|
+
/** Mouse movement delta in world space
|
|
1651
|
+
* @type {Vector2}
|
|
1652
|
+
* @memberof Input */
|
|
1653
|
+
export let mouseDelta: Vector2;
|
|
1654
|
+
/** Mouse movement delta in screen space
|
|
1655
|
+
* @type {Vector2}
|
|
1656
|
+
* @memberof Input */
|
|
1657
|
+
export let mouseDeltaScreen: Vector2;
|
|
1587
1658
|
/** Mouse wheel delta this frame
|
|
1588
1659
|
* @type {number}
|
|
1589
1660
|
* @memberof Input */
|
|
@@ -1636,6 +1707,16 @@ declare module "littlejsengine" {
|
|
|
1636
1707
|
/** True if a touch device has been detected
|
|
1637
1708
|
* @memberof Input */
|
|
1638
1709
|
export const isTouchDevice: boolean;
|
|
1710
|
+
/** Request to lock the pointer, does not work on touch devices
|
|
1711
|
+
* @memberof Input */
|
|
1712
|
+
export function pointerLockRequest(): void;
|
|
1713
|
+
/** Request to unlock the pointer
|
|
1714
|
+
* @memberof Input */
|
|
1715
|
+
export function pointerLockExit(): void;
|
|
1716
|
+
/** Check if pointer is locked (true if locked)
|
|
1717
|
+
* @return {boolean}
|
|
1718
|
+
* @memberof Input */
|
|
1719
|
+
export function pointerLockIsActive(): boolean;
|
|
1639
1720
|
/**
|
|
1640
1721
|
* Sound Object - Stores a sound for later use and can be played positionally
|
|
1641
1722
|
*
|
|
@@ -1650,13 +1731,13 @@ declare module "littlejsengine" {
|
|
|
1650
1731
|
export class Sound {
|
|
1651
1732
|
/** Create a sound object and cache the zzfx samples for later use
|
|
1652
1733
|
* @param {Array} zzfxSound - Array of zzfx parameters, ex. [.5,.5]
|
|
1653
|
-
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
1734
|
+
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
1654
1735
|
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
1655
1736
|
*/
|
|
1656
1737
|
constructor(zzfxSound: any[], range?: number, taper?: number);
|
|
1657
|
-
/** @property {number} - World space max range of sound
|
|
1738
|
+
/** @property {number} - World space max range of sound */
|
|
1658
1739
|
range: number;
|
|
1659
|
-
/** @property {number} - At what percentage of range should it start tapering
|
|
1740
|
+
/** @property {number} - At what percentage of range should it start tapering */
|
|
1660
1741
|
taper: number;
|
|
1661
1742
|
/** @property {number} - How much to randomize frequency each time sound plays */
|
|
1662
1743
|
randomness: any;
|
|
@@ -1677,8 +1758,10 @@ declare module "littlejsengine" {
|
|
|
1677
1758
|
* @param {number} [volume] - How much to scale volume by
|
|
1678
1759
|
*/
|
|
1679
1760
|
setVolume(volume?: number): void;
|
|
1680
|
-
/** Stop the last instance of this sound that was played
|
|
1681
|
-
|
|
1761
|
+
/** Stop the last instance of this sound that was played
|
|
1762
|
+
* @param {number} [fadeTime] - How long to fade out (seconds)
|
|
1763
|
+
*/
|
|
1764
|
+
stop(fadeTime?: number): void;
|
|
1682
1765
|
/** Get source of most recent instance of this sound that was played
|
|
1683
1766
|
* @return {AudioBufferSourceNode}
|
|
1684
1767
|
*/
|
|
@@ -1713,11 +1796,17 @@ declare module "littlejsengine" {
|
|
|
1713
1796
|
/** Create a sound object and cache the wave file for later use
|
|
1714
1797
|
* @param {string} filename - Filename of audio file to load
|
|
1715
1798
|
* @param {number} [randomness] - How much to randomize frequency each time sound plays
|
|
1716
|
-
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
1717
|
-
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
1799
|
+
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
1800
|
+
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
1718
1801
|
* @param {Function} [onloadCallback] - callback function to call when sound is loaded
|
|
1719
1802
|
*/
|
|
1720
1803
|
constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: Function);
|
|
1804
|
+
/** @property {Function} - callback function to call when sound is loaded */
|
|
1805
|
+
onloadCallback: Function;
|
|
1806
|
+
/** Loads a sound from a URL and decodes it into sample data. Must be used with await!
|
|
1807
|
+
* @param {string} filename
|
|
1808
|
+
* @return {Promise<void>} */
|
|
1809
|
+
loadSound(filename: string): Promise<void>;
|
|
1721
1810
|
}
|
|
1722
1811
|
/** Play an mp3, ogg, or wav audio from a local file or url
|
|
1723
1812
|
* @param {string} filename - Location of sound file to play
|
|
@@ -1852,45 +1941,45 @@ declare module "littlejsengine" {
|
|
|
1852
1941
|
drawSize: any;
|
|
1853
1942
|
/** @property {TileInfo} - Tile info to render object (undefined is untextured) */
|
|
1854
1943
|
tileInfo: TileInfo;
|
|
1855
|
-
/** @property {number}
|
|
1944
|
+
/** @property {number} - Angle to rotate the object */
|
|
1856
1945
|
angle: number;
|
|
1857
|
-
/** @property {Color}
|
|
1946
|
+
/** @property {Color} - Color to apply when rendered */
|
|
1858
1947
|
color: Color;
|
|
1859
|
-
/** @property {Color}
|
|
1948
|
+
/** @property {Color} - Additive color to apply when rendered */
|
|
1860
1949
|
additiveColor: any;
|
|
1861
1950
|
/** @property {boolean} - Should it flip along y axis when rendered */
|
|
1862
1951
|
mirror: boolean;
|
|
1863
|
-
/** @property {number} [mass=objectDefaultMass]
|
|
1952
|
+
/** @property {number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
|
|
1864
1953
|
mass: number;
|
|
1865
|
-
/** @property {number} [damping=objectDefaultDamping]
|
|
1954
|
+
/** @property {number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
|
|
1866
1955
|
damping: number;
|
|
1867
1956
|
/** @property {number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
|
|
1868
1957
|
angleDamping: number;
|
|
1869
|
-
/** @property {number} [
|
|
1870
|
-
|
|
1871
|
-
/** @property {number} [friction=objectDefaultFriction]
|
|
1958
|
+
/** @property {number} [restitution=objectDefaultRestitution] - How bouncy the object is when colliding (0-1) */
|
|
1959
|
+
restitution: number;
|
|
1960
|
+
/** @property {number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
|
|
1872
1961
|
friction: number;
|
|
1873
|
-
/** @property {number}
|
|
1962
|
+
/** @property {number} - How much to scale gravity by for this object */
|
|
1874
1963
|
gravityScale: number;
|
|
1875
|
-
/** @property {number}
|
|
1964
|
+
/** @property {number} - Objects are sorted by render order */
|
|
1876
1965
|
renderOrder: number;
|
|
1877
1966
|
/** @property {Vector2} - Velocity of the object */
|
|
1878
1967
|
velocity: Vector2;
|
|
1879
|
-
/** @property {number}
|
|
1968
|
+
/** @property {number} - Angular velocity of the object */
|
|
1880
1969
|
angleVelocity: number;
|
|
1881
|
-
/** @property {number}
|
|
1970
|
+
/** @property {number} - Track when object was created */
|
|
1882
1971
|
spawnTime: number;
|
|
1883
|
-
/** @property {Array<EngineObject>}
|
|
1972
|
+
/** @property {Array<EngineObject>} - List of children of this object */
|
|
1884
1973
|
children: any[];
|
|
1885
|
-
/** @property {boolean}
|
|
1886
|
-
|
|
1974
|
+
/** @property {boolean} - Limit object speed along x and y axis */
|
|
1975
|
+
clampSpeed: boolean;
|
|
1887
1976
|
/** @property {EngineObject} - Object we are standing on, if any */
|
|
1888
1977
|
groundObject: EngineObject | TileCollisionLayer;
|
|
1889
1978
|
/** @property {EngineObject} - Parent of object if in local space */
|
|
1890
1979
|
parent: any;
|
|
1891
|
-
/** @property {Vector2}
|
|
1980
|
+
/** @property {Vector2} - Local position if child */
|
|
1892
1981
|
localPos: Vector2;
|
|
1893
|
-
/** @property {number}
|
|
1982
|
+
/** @property {number} - Local angle if child */
|
|
1894
1983
|
localAngle: number;
|
|
1895
1984
|
/** @property {boolean} - Object collides with the tile collision */
|
|
1896
1985
|
collideTiles: boolean;
|
|
@@ -1906,7 +1995,7 @@ declare module "littlejsengine" {
|
|
|
1906
1995
|
update(): void;
|
|
1907
1996
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
1908
1997
|
render(): void;
|
|
1909
|
-
/** Destroy this object, destroy
|
|
1998
|
+
/** Destroy this object, destroy its children, detach it's parent, and mark it for removal */
|
|
1910
1999
|
destroy(): void;
|
|
1911
2000
|
destroyed: number;
|
|
1912
2001
|
/** Convert from local space to world space
|
|
@@ -1937,6 +2026,9 @@ declare module "littlejsengine" {
|
|
|
1937
2026
|
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
1938
2027
|
* @param {Vector2} acceleration */
|
|
1939
2028
|
applyAcceleration(acceleration: Vector2): void;
|
|
2029
|
+
/** Apply angular acceleration to this object
|
|
2030
|
+
* @param {number} acceleration */
|
|
2031
|
+
applyAngularAcceleration(acceleration: number): void;
|
|
1940
2032
|
/** Apply force to this object (adjust velocity, affected by mass)
|
|
1941
2033
|
* @param {Vector2} force */
|
|
1942
2034
|
applyForce(force: Vector2): void;
|
|
@@ -1980,22 +2072,34 @@ declare module "littlejsengine" {
|
|
|
1980
2072
|
* @param {Vector2} pos
|
|
1981
2073
|
* @return {number}
|
|
1982
2074
|
* @memberof TileCollision */
|
|
1983
|
-
export function
|
|
2075
|
+
export function tileCollisionGetData(pos: Vector2): number;
|
|
1984
2076
|
/** Check if a tile layer collides with another object
|
|
1985
2077
|
* @param {Vector2} pos
|
|
1986
2078
|
* @param {Vector2} [size=(0,0)]
|
|
1987
|
-
* @param {EngineObject} [object]
|
|
2079
|
+
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2080
|
+
* @param {boolean} [solidOnly] - Only check solid layers if true
|
|
1988
2081
|
* @return {TileCollisionLayer}
|
|
1989
2082
|
* @memberof TileCollision */
|
|
1990
|
-
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): TileCollisionLayer;
|
|
2083
|
+
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
|
|
1991
2084
|
/** Return the center of first tile hit, undefined if nothing was hit.
|
|
1992
2085
|
* This does not return the exact intersection, but the center of the tile hit.
|
|
1993
2086
|
* @param {Vector2} posStart
|
|
1994
2087
|
* @param {Vector2} posEnd
|
|
1995
|
-
* @param {EngineObject} [object]
|
|
2088
|
+
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2089
|
+
* @param {boolean} [solidOnly=true] - Only check solid layers if true
|
|
1996
2090
|
* @return {Vector2}
|
|
1997
2091
|
* @memberof TileCollision */
|
|
1998
|
-
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject): Vector2;
|
|
2092
|
+
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, solidOnly?: boolean): Vector2;
|
|
2093
|
+
/**
|
|
2094
|
+
* Load tile layers from exported data
|
|
2095
|
+
* @param {Object} tileMapData - Level data from exported data
|
|
2096
|
+
* @param {TileInfo} [tileInfo] - Default tile info (used for size and texture)
|
|
2097
|
+
* @param {number} [renderOrder] - Render order of the top layer
|
|
2098
|
+
* @param {number} [collisionLayer] - Layer to use for collision if any
|
|
2099
|
+
* @param {boolean} [draw] - Should the layer be drawn automatically
|
|
2100
|
+
* @return {Array<TileCollisionLayer>}
|
|
2101
|
+
* @memberof TileCollision */
|
|
2102
|
+
export function tileCollisionLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: number, draw?: boolean): Array<TileCollisionLayer>;
|
|
1999
2103
|
/**
|
|
2000
2104
|
* Tile layer data object stores info about how to draw a tile
|
|
2001
2105
|
* @example
|
|
@@ -2024,33 +2128,85 @@ declare module "littlejsengine" {
|
|
|
2024
2128
|
/** Set this tile to clear, it will not be rendered */
|
|
2025
2129
|
clear(): void;
|
|
2026
2130
|
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Canvas Layer - cached off screen rendering system
|
|
2133
|
+
* - Contains an offscreen canvas that can be rendered to
|
|
2134
|
+
* - Webgl rendering is optional, call useWebGL to enable
|
|
2135
|
+
* @extends EngineObject
|
|
2136
|
+
* @example
|
|
2137
|
+
* const canvasLayer = new CanvasLayer(vec2(), vec2(200,100));
|
|
2138
|
+
*/
|
|
2139
|
+
export class CanvasLayer extends EngineObject {
|
|
2140
|
+
/** Create a canvas layer object
|
|
2141
|
+
* @param {Vector2} [position] - World space position of the layer
|
|
2142
|
+
* @param {Vector2} [size] - World space size of the layer
|
|
2143
|
+
* @param {number} [angle] - Angle the layer is rotated by
|
|
2144
|
+
* @param {number} [renderOrder] - Objects sorted by renderOrder
|
|
2145
|
+
* @param {Vector2} [canvasSize] - Default size of canvas, can be changed later
|
|
2146
|
+
*/
|
|
2147
|
+
constructor(position?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2);
|
|
2148
|
+
/** @property {HTMLCanvasElement} - The canvas used by this layer */
|
|
2149
|
+
canvas: OffscreenCanvas;
|
|
2150
|
+
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2151
|
+
context: OffscreenCanvasRenderingContext2D;
|
|
2152
|
+
/** @property {WebGLTexture} - Texture if using webgl for this layer, call useWebGL to enable */
|
|
2153
|
+
glTexture: WebGLTexture;
|
|
2154
|
+
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2155
|
+
* @param {Vector2} pos - Center in world space
|
|
2156
|
+
* @param {Vector2} [size] - Size in world space
|
|
2157
|
+
* @param {Color} [color] - Color to modulate with
|
|
2158
|
+
* @param {number} [angle] - Angle to rotate by
|
|
2159
|
+
* @param {boolean} [mirror] - If true image is flipped along the Y axis
|
|
2160
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any
|
|
2161
|
+
* @param {boolean} [screenSpace] - If true the pos and size are in screen space
|
|
2162
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2163
|
+
* @memberof Draw */
|
|
2164
|
+
draw(pos: Vector2, size?: Vector2, angle?: number, color?: Color, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2165
|
+
/** Draw onto the layer canvas in world space (bypass webgl)
|
|
2166
|
+
* @param {Vector2} pos
|
|
2167
|
+
* @param {Vector2} size
|
|
2168
|
+
* @param {number} angle
|
|
2169
|
+
* @param {boolean} mirror
|
|
2170
|
+
* @param {Function} drawFunction */
|
|
2171
|
+
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
2172
|
+
/** Draw a tile onto the layer canvas in world space
|
|
2173
|
+
* @param {Vector2} pos
|
|
2174
|
+
* @param {Vector2} [size=(1,1)]
|
|
2175
|
+
* @param {TileInfo} [tileInfo]
|
|
2176
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
2177
|
+
* @param {number} [angle=0]
|
|
2178
|
+
* @param {boolean} [mirror=0] */
|
|
2179
|
+
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2180
|
+
/** Draw a rectangle onto the layer canvas in world space
|
|
2181
|
+
* @param {Vector2} pos
|
|
2182
|
+
* @param {Vector2} [size=(1,1)]
|
|
2183
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
2184
|
+
* @param {number} [angle=0] */
|
|
2185
|
+
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2186
|
+
/** Create or update the webgl texture for this layer
|
|
2187
|
+
* @param {boolean} [enable] - enable webgl rendering and update the texture */
|
|
2188
|
+
useWebGL(enable?: boolean): void;
|
|
2189
|
+
}
|
|
2027
2190
|
/**
|
|
2028
2191
|
* Tile Layer - cached rendering system for tile layers
|
|
2029
2192
|
* - Each Tile layer is rendered to an off screen canvas
|
|
2030
2193
|
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
2031
2194
|
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
2032
2195
|
* - For with 16x16 tiles this limits layers to 256x256 on mobile devices
|
|
2033
|
-
* @extends
|
|
2196
|
+
* @extends CanvasLayer
|
|
2034
2197
|
* @example
|
|
2035
2198
|
* const tileLayer = new TileLayer(vec2(), vec2(200,100));
|
|
2036
2199
|
*/
|
|
2037
|
-
export class TileLayer extends
|
|
2200
|
+
export class TileLayer extends CanvasLayer {
|
|
2038
2201
|
/** Create a tile layer object
|
|
2039
|
-
* @param {Vector2}
|
|
2040
|
-
* @param {Vector2}
|
|
2041
|
-
* @param {TileInfo} [tileInfo]
|
|
2042
|
-
* @param {Vector2} [scale=(1,1)]
|
|
2043
|
-
* @param {number} [renderOrder]
|
|
2202
|
+
* @param {Vector2} position - World space position
|
|
2203
|
+
* @param {Vector2} size - World space size
|
|
2204
|
+
* @param {TileInfo} [tileInfo] - Default tile info for layer (used for size and texture)
|
|
2205
|
+
* @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
|
|
2206
|
+
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2207
|
+
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
2044
2208
|
*/
|
|
2045
|
-
constructor(position
|
|
2046
|
-
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
2047
|
-
canvas: HTMLCanvasElement;
|
|
2048
|
-
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
|
|
2049
|
-
context: CanvasRenderingContext2D;
|
|
2050
|
-
/** @property {Vector2} - How much to scale this layer when rendered */
|
|
2051
|
-
scale: Vector2;
|
|
2052
|
-
/** @property {boolean} - If true this layer will render to overlay canvas and appear above all objects */
|
|
2053
|
-
isOverlay: boolean;
|
|
2209
|
+
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number, useWebGL?: boolean);
|
|
2054
2210
|
data: TileLayerData[];
|
|
2055
2211
|
/** Draw all the tile data to an offscreen canvas
|
|
2056
2212
|
* - This may be slow in some browsers but only needs to be done once */
|
|
@@ -2068,13 +2224,6 @@ declare module "littlejsengine" {
|
|
|
2068
2224
|
* @param {boolean} [clear] - should the old tile be cleared out
|
|
2069
2225
|
*/
|
|
2070
2226
|
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2071
|
-
/** Draw directly to the 2D canvas in world space (bypass webgl)
|
|
2072
|
-
* @param {Vector2} pos
|
|
2073
|
-
* @param {Vector2} size
|
|
2074
|
-
* @param {number} angle
|
|
2075
|
-
* @param {boolean} mirror
|
|
2076
|
-
* @param {Function} drawFunction */
|
|
2077
|
-
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
2078
2227
|
/** Set data at a given position in the array
|
|
2079
2228
|
* @param {Vector2} layerPos - Local position in array
|
|
2080
2229
|
* @param {TileLayerData} data - Data to set
|
|
@@ -2084,22 +2233,8 @@ declare module "littlejsengine" {
|
|
|
2084
2233
|
* @param {Vector2} layerPos - Local position in array
|
|
2085
2234
|
* @return {TileLayerData} */
|
|
2086
2235
|
getData(layerPos: Vector2): TileLayerData;
|
|
2087
|
-
/** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
2088
|
-
savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
|
|
2089
|
-
/** Draw a tile directly onto the layer canvas in world space
|
|
2090
|
-
* @param {Vector2} pos
|
|
2091
|
-
* @param {Vector2} [size=(1,1)]
|
|
2092
|
-
* @param {TileInfo} [tileInfo]
|
|
2093
|
-
* @param {Color} [color=(1,1,1,1)]
|
|
2094
|
-
* @param {number} [angle=0]
|
|
2095
|
-
* @param {boolean} [mirror=0] */
|
|
2096
|
-
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2097
|
-
/** Draw a rectangle directly onto the layer canvas in world space
|
|
2098
|
-
* @param {Vector2} pos
|
|
2099
|
-
* @param {Vector2} [size=(1,1)]
|
|
2100
|
-
* @param {Color} [color=(1,1,1,1)]
|
|
2101
|
-
* @param {number} [angle=0] */
|
|
2102
|
-
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2236
|
+
/** @type {[HTMLCanvasElement|OffscreenCanvas, CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
2237
|
+
savedRenderSettings: [HTMLCanvasElement | OffscreenCanvas, CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number];
|
|
2103
2238
|
}
|
|
2104
2239
|
/**
|
|
2105
2240
|
* Tile Collision Layer - a tile layer with collision
|
|
@@ -2110,25 +2245,26 @@ declare module "littlejsengine" {
|
|
|
2110
2245
|
*/
|
|
2111
2246
|
export class TileCollisionLayer extends TileLayer {
|
|
2112
2247
|
/** Create a tile layer object
|
|
2113
|
-
* @param {Vector2}
|
|
2114
|
-
* @param {Vector2}
|
|
2115
|
-
* @param {TileInfo} [tileInfo]
|
|
2116
|
-
* @param {number} [renderOrder]
|
|
2248
|
+
* @param {Vector2} position - World space position
|
|
2249
|
+
* @param {Vector2} size - World space size
|
|
2250
|
+
* @param {TileInfo} [tileInfo] - Tile info for layer
|
|
2251
|
+
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2252
|
+
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
2117
2253
|
*/
|
|
2118
|
-
constructor(position
|
|
2254
|
+
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number, useWebGL?: boolean);
|
|
2119
2255
|
/** @property {Array<number>} - The tile collision grid */
|
|
2120
2256
|
collisionData: any[];
|
|
2121
2257
|
/** Clear and initialize tile collision to new size
|
|
2122
2258
|
* @param {Vector2} size - width and height of tile collision 2d grid */
|
|
2123
2259
|
initCollision(size: Vector2): void;
|
|
2124
2260
|
/** Set tile collision data for a given cell in the grid
|
|
2125
|
-
* @param {Vector2}
|
|
2261
|
+
* @param {Vector2} gridPos
|
|
2126
2262
|
* @param {number} [data] */
|
|
2127
|
-
setCollisionData(
|
|
2263
|
+
setCollisionData(gridPos: Vector2, data?: number): void;
|
|
2128
2264
|
/** Get tile collision data for a given cell in the grid
|
|
2129
|
-
* @param {Vector2}
|
|
2265
|
+
* @param {Vector2} gridPos
|
|
2130
2266
|
* @return {number} */
|
|
2131
|
-
getCollisionData(
|
|
2267
|
+
getCollisionData(gridPos: Vector2): number;
|
|
2132
2268
|
/** Check if collision with another object should occur
|
|
2133
2269
|
* @param {Vector2} pos
|
|
2134
2270
|
* @param {Vector2} [size=(0,0)]
|
|
@@ -2156,7 +2292,7 @@ declare module "littlejsengine" {
|
|
|
2156
2292
|
* (
|
|
2157
2293
|
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitCone
|
|
2158
2294
|
* tile(0, 16), // tileInfo
|
|
2159
|
-
* rgb(1,1,1),
|
|
2295
|
+
* rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
|
|
2160
2296
|
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
2161
2297
|
* 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
2162
2298
|
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
@@ -2528,10 +2664,20 @@ declare module "littlejsengine" {
|
|
|
2528
2664
|
defaultButtonColor: Color;
|
|
2529
2665
|
/** @property {Color} - Default hover color for UI elements */
|
|
2530
2666
|
defaultHoverColor: Color;
|
|
2667
|
+
/** @property {Color} - Default color for disabled UI elements */
|
|
2668
|
+
defaultDisabledColor: Color;
|
|
2531
2669
|
/** @property {number} - Default line width for UI elements */
|
|
2532
2670
|
defaultLineWidth: number;
|
|
2671
|
+
/** @property {number} - Default rounded rect corner radius for UI elements */
|
|
2672
|
+
defaultCornerRadius: number;
|
|
2533
2673
|
/** @property {string} - Default font for UI elements */
|
|
2534
2674
|
defaultFont: string;
|
|
2675
|
+
/** @property {Sound} - Default sound when interactive UI element is pressed */
|
|
2676
|
+
defaultSoundPress: any;
|
|
2677
|
+
/** @property {Sound} - Default sound when interactive UI element is released */
|
|
2678
|
+
defaultSoundRelease: any;
|
|
2679
|
+
/** @property {Sound} - Default sound when interactive UI element is clicked */
|
|
2680
|
+
defaultSoundClick: any;
|
|
2535
2681
|
/** @property {Array<UIObject>} - List of all UI elements */
|
|
2536
2682
|
uiObjects: any[];
|
|
2537
2683
|
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
|
|
@@ -2541,8 +2687,9 @@ declare module "littlejsengine" {
|
|
|
2541
2687
|
* @param {Vector2} size
|
|
2542
2688
|
* @param {Color} [color=uiSystem.defaultColor]
|
|
2543
2689
|
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2544
|
-
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2545
|
-
|
|
2690
|
+
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2691
|
+
* @param {number} [lineWidth=uiSystem.defaultCornerRadius] */
|
|
2692
|
+
drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, cornerRadius?: number): void;
|
|
2546
2693
|
/** Draw a line to the UI context
|
|
2547
2694
|
* @param {Vector2} posA
|
|
2548
2695
|
* @param {Vector2} posB
|
|
@@ -2583,24 +2730,40 @@ declare module "littlejsengine" {
|
|
|
2583
2730
|
pos: Vector2;
|
|
2584
2731
|
/** @property {Vector2} - Screen space size of the object */
|
|
2585
2732
|
size: Vector2;
|
|
2586
|
-
/** @property {Color} */
|
|
2733
|
+
/** @property {Color} - color of the object */
|
|
2587
2734
|
color: Color;
|
|
2588
|
-
/** @property {Color} */
|
|
2589
|
-
lineColor: Color;
|
|
2590
|
-
/** @property {Color} */
|
|
2735
|
+
/** @property {Color} - color for text */
|
|
2591
2736
|
textColor: Color;
|
|
2592
|
-
/** @property {Color} */
|
|
2737
|
+
/** @property {Color} - color used when hovering over the object */
|
|
2593
2738
|
hoverColor: Color;
|
|
2594
|
-
/** @property {
|
|
2739
|
+
/** @property {Color} - color for line drawing */
|
|
2740
|
+
lineColor: Color;
|
|
2741
|
+
/** @property {number} - width for line drawing */
|
|
2595
2742
|
lineWidth: number;
|
|
2596
|
-
/** @property {string} */
|
|
2743
|
+
/** @property {string} - font for this objecct */
|
|
2597
2744
|
font: string;
|
|
2598
|
-
/** @property {
|
|
2745
|
+
/** @property {number} - override for text height */
|
|
2746
|
+
textHeight: any;
|
|
2747
|
+
/** @property {boolean} - should this object be drawn */
|
|
2599
2748
|
visible: boolean;
|
|
2600
|
-
/** @property {Array<UIObject>} */
|
|
2749
|
+
/** @property {Array<UIObject>} - a list of this object's children */
|
|
2601
2750
|
children: any[];
|
|
2602
|
-
/** @property {UIObject} */
|
|
2751
|
+
/** @property {UIObject} - this object's parent, position is in parent space */
|
|
2603
2752
|
parent: any;
|
|
2753
|
+
/** @property {number} - Extra size added when checking if element is touched */
|
|
2754
|
+
extraTouchSize: number;
|
|
2755
|
+
/** @property {Sound} - Sound when interactive element is pressed */
|
|
2756
|
+
soundPress: any;
|
|
2757
|
+
/** @property {Sound} - Sound when interactive element is released */
|
|
2758
|
+
soundRelease: any;
|
|
2759
|
+
/** @property {Sound} - Sound when interactive element is clicked */
|
|
2760
|
+
soundClick: any;
|
|
2761
|
+
/** @property {boolean} - Is the mouse over this element */
|
|
2762
|
+
mouseIsOver: boolean;
|
|
2763
|
+
/** @property {boolean} - Is this element interactive */
|
|
2764
|
+
interactive: boolean;
|
|
2765
|
+
/** @property {boolean} - Is the mouse held on this element (was pressed while over and hasn't been released) */
|
|
2766
|
+
mouseIsHeld: boolean;
|
|
2604
2767
|
/** Add a child UIObject to this object
|
|
2605
2768
|
* @param {UIObject} child
|
|
2606
2769
|
*/
|
|
@@ -2611,10 +2774,10 @@ declare module "littlejsengine" {
|
|
|
2611
2774
|
removeChild(child: UIObject): void;
|
|
2612
2775
|
/** Update the object, called automatically by plugin once each frame */
|
|
2613
2776
|
update(): void;
|
|
2614
|
-
mouseIsOver: boolean;
|
|
2615
|
-
mouseIsHeld: boolean;
|
|
2616
2777
|
/** Render the object, called automatically by plugin once each frame */
|
|
2617
2778
|
render(): void;
|
|
2779
|
+
/** Special update for when object is invisible */
|
|
2780
|
+
updateInvisible(): void;
|
|
2618
2781
|
/** Called when the mouse enters the object */
|
|
2619
2782
|
onEnter(): void;
|
|
2620
2783
|
/** Called when the mouse leaves the object */
|
|
@@ -2623,6 +2786,8 @@ declare module "littlejsengine" {
|
|
|
2623
2786
|
onPress(): void;
|
|
2624
2787
|
/** Called when the mouse is released while over the object */
|
|
2625
2788
|
onRelease(): void;
|
|
2789
|
+
/** Called when user clicks on this object */
|
|
2790
|
+
onClick(): void;
|
|
2626
2791
|
/** Called when the state of this object changes */
|
|
2627
2792
|
onChange(): void;
|
|
2628
2793
|
}
|
|
@@ -2679,6 +2844,10 @@ declare module "littlejsengine" {
|
|
|
2679
2844
|
constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
|
|
2680
2845
|
/** @property {string} */
|
|
2681
2846
|
text: string;
|
|
2847
|
+
/** @property {Color} */
|
|
2848
|
+
disabledColor: Color;
|
|
2849
|
+
/** @property {boolean} */
|
|
2850
|
+
disabled: boolean;
|
|
2682
2851
|
}
|
|
2683
2852
|
/**
|
|
2684
2853
|
* UICheckbox - A UI object that acts as a checkbox
|
|
@@ -2712,41 +2881,41 @@ declare module "littlejsengine" {
|
|
|
2712
2881
|
value: number;
|
|
2713
2882
|
/** @property {string} */
|
|
2714
2883
|
text: string;
|
|
2884
|
+
/** @property {Color} */
|
|
2715
2885
|
handleColor: Color;
|
|
2716
2886
|
}
|
|
2717
2887
|
/**
|
|
2718
2888
|
* LittleJS Box2D Physics Plugin
|
|
2719
2889
|
* - Box2dObject extends EngineObject with Box2D physics
|
|
2720
|
-
* - Call
|
|
2890
|
+
* - Call box2dInit() before engineInit() to enable
|
|
2721
2891
|
* - You will also need to include box2d.wasm.js
|
|
2722
|
-
* - Uses
|
|
2892
|
+
* - Uses a super fast web assembly port of Box2D
|
|
2723
2893
|
* - More info: https://github.com/kripken/box2d.js
|
|
2724
|
-
* - Fully wraps everything in Box2d
|
|
2725
2894
|
* - Functions to create polygon, circle, and edge shapes
|
|
2726
|
-
* - Raycasting and querying
|
|
2727
|
-
* - Joint creation
|
|
2728
2895
|
* - Contact begin and end callbacks
|
|
2896
|
+
* - Wraps b2Vec2 type to/from Vector2
|
|
2897
|
+
* - Raycasting and querying
|
|
2898
|
+
* - Every type of joint
|
|
2729
2899
|
* - Debug physics drawing
|
|
2900
|
+
* @namespace Box2D
|
|
2730
2901
|
*/
|
|
2731
2902
|
/** Global Box2d Plugin object
|
|
2732
|
-
* @type {Box2dPlugin}
|
|
2903
|
+
* @type {Box2dPlugin}
|
|
2904
|
+
* @memberof Box2D */
|
|
2733
2905
|
export let box2d: Box2dPlugin;
|
|
2734
2906
|
/** Enable Box2D debug drawing
|
|
2735
2907
|
* @type {boolean}
|
|
2736
|
-
* @default
|
|
2908
|
+
* @default
|
|
2909
|
+
* @memberof Box2D */
|
|
2737
2910
|
export let box2dDebug: boolean;
|
|
2738
2911
|
/** Enable Box2D debug drawing
|
|
2739
|
-
* @param {boolean} enable
|
|
2912
|
+
* @param {boolean} enable
|
|
2913
|
+
* @memberof Box2D */
|
|
2740
2914
|
export function box2dSetDebug(enable: boolean): void;
|
|
2741
|
-
/** Box2d Init -
|
|
2742
|
-
* @
|
|
2743
|
-
* @
|
|
2744
|
-
|
|
2745
|
-
* @param {Function} gameRender - Called before objects are rendered, for drawing the background
|
|
2746
|
-
* @param {Function} gameRenderPost - Called after objects are rendered, useful for drawing UI
|
|
2747
|
-
* @param {Array<string>} [imageSources=[]] - List of images to load
|
|
2748
|
-
* @param {HTMLElement} [rootElement] - Root element to attach to, the document body by default */
|
|
2749
|
-
export function box2dEngineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: Array<string>, rootElement?: HTMLElement): void;
|
|
2915
|
+
/** Box2d Init - Call with await before starting LittleJS to init box2d
|
|
2916
|
+
* @return {Promise<Box2dPlugin>}
|
|
2917
|
+
* @memberof Box2D */
|
|
2918
|
+
export function box2dInit(): Promise<Box2dPlugin>;
|
|
2750
2919
|
/**
|
|
2751
2920
|
* Box2D Global Object
|
|
2752
2921
|
* - Wraps Box2d world and provides global functions
|
|
@@ -3050,9 +3219,6 @@ declare module "littlejsengine" {
|
|
|
3050
3219
|
/** Apply torque to this object
|
|
3051
3220
|
* @param {number} torque */
|
|
3052
3221
|
applyTorque(torque: number): void;
|
|
3053
|
-
/** Apply angular acceleration to this object
|
|
3054
|
-
* @param {number} acceleration */
|
|
3055
|
-
applyAngularAcceleration(acceleration: number): void;
|
|
3056
3222
|
/** Check if this object has any fixtures
|
|
3057
3223
|
* @return {boolean} */
|
|
3058
3224
|
hasFixtures(): boolean;
|
|
@@ -3625,4 +3791,56 @@ declare module "littlejsengine" {
|
|
|
3625
3791
|
* @return {number} */
|
|
3626
3792
|
getCorrectionFactor(): number;
|
|
3627
3793
|
}
|
|
3794
|
+
/** Draw a scalable nine-slice UI element in world space
|
|
3795
|
+
* This function can apply color and additive color if webgl is enabled
|
|
3796
|
+
* @param {Vector2} pos - World space position
|
|
3797
|
+
* @param {Vector2} size - World space size
|
|
3798
|
+
* @param {TileInfo} startTile - Starting tile for the nine-slice pattern
|
|
3799
|
+
* @param {Color} [color] - Color to modulate with
|
|
3800
|
+
* @param {number} [borderSize=1] - Width of the border sections
|
|
3801
|
+
* @param {Color} [additiveColor] - Additive color
|
|
3802
|
+
* @param {number} [extraSpace=.01] - Extra spacing adjustment
|
|
3803
|
+
* @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
|
|
3804
|
+
* @param {boolean} [screenSpace] - Use screen space coordinates
|
|
3805
|
+
* @param {CanvasRenderingContext2D} [context] - Canvas context to use
|
|
3806
|
+
* @memberof DrawUtilities */
|
|
3807
|
+
export function drawNineSlice(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3808
|
+
/**
|
|
3809
|
+
* LittleJS Drawing Utilities Plugin
|
|
3810
|
+
* - Extra drawing functions for LittleJS
|
|
3811
|
+
* - Nine slice and three slice drawing
|
|
3812
|
+
* @namespace DrawUtilities
|
|
3813
|
+
*/
|
|
3814
|
+
/** Draw a scalable nine-slice UI element to the overlay canvas in screen space
|
|
3815
|
+
* This function can not apply color because it draws using the overlay 2d context
|
|
3816
|
+
* @param {Vector2} pos - Screen space position
|
|
3817
|
+
* @param {Vector2} size - Screen space size
|
|
3818
|
+
* @param {TileInfo} startTile - Starting tile for the nine-slice pattern
|
|
3819
|
+
* @param {number} [borderSize=1] - Width of the border sections
|
|
3820
|
+
* @param {number} [extraSpace=.01] - Extra spacing adjustment
|
|
3821
|
+
* @memberof DrawUtilities */
|
|
3822
|
+
export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number): void;
|
|
3823
|
+
/** Draw a scalable three-slice UI element in world space
|
|
3824
|
+
* This function can apply color and additive color if webgl is enabled
|
|
3825
|
+
* @param {Vector2} pos - World space position
|
|
3826
|
+
* @param {Vector2} size - World space size
|
|
3827
|
+
* @param {TileInfo} startTile - Starting tile for the three-slice pattern
|
|
3828
|
+
* @param {Color} [color] - Color to modulate with
|
|
3829
|
+
* @param {number} [borderSize=1] - Width of the border sections
|
|
3830
|
+
* @param {Color} [additiveColor] - Additive color
|
|
3831
|
+
* @param {number} [extraSpace=.01] - Extra spacing adjustment
|
|
3832
|
+
* @param {boolean} [useWebGL=glEnable] - Use WebGL for rendering
|
|
3833
|
+
* @param {boolean} [screenSpace] - Use screen space coordinates
|
|
3834
|
+
* @param {CanvasRenderingContext2D} [context] - Canvas context to use
|
|
3835
|
+
* @memberof DrawUtilities */
|
|
3836
|
+
export function drawThreeSlice(pos: Vector2, size: Vector2, startTile: TileInfo, color?: Color, borderSize?: number, additiveColor?: Color, extraSpace?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3837
|
+
/** Draw a scalable three-slice UI element to the overlay canvas in screen space
|
|
3838
|
+
* This function can not apply color because it draws using the overlay 2d context
|
|
3839
|
+
* @param {Vector2} pos - Screen space position
|
|
3840
|
+
* @param {Vector2} size - Screen space size
|
|
3841
|
+
* @param {TileInfo} startTile - Starting tile for the three-slice pattern
|
|
3842
|
+
* @param {number} [borderSize=1] - Width of the border sections
|
|
3843
|
+
* @param {number} [extraSpace=.01] - Extra spacing adjustment
|
|
3844
|
+
* @memberof DrawUtilities */
|
|
3845
|
+
export function drawThreeSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number): void;
|
|
3628
3846
|
}
|