littlejsengine 1.12.6 → 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/littlejs.d.ts +387 -177
- package/dist/littlejs.esm.js +5934 -5294
- package/dist/littlejs.esm.min.js +4 -1
- package/dist/littlejs.js +5887 -5263
- package/dist/littlejs.min.js +4 -1
- package/dist/littlejs.release.js +5426 -4829
- package/examples/box2d/game.js +1 -1
- package/examples/box2d/gameObjects.js +7 -6
- package/examples/box2d/index.html +1 -1
- package/examples/box2d/scenes.js +7 -7
- 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 +396 -153
- package/examples/module/game.js +1 -1
- package/examples/module/index.html +1 -1
- package/examples/platformer/game.js +4 -4
- 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 +23 -3
- package/examples/shorts/box2dCar.js +8 -12
- 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/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 +4 -7
- package/examples/starter/build.bat +6 -1
- package/examples/starter/game.js +2 -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 +8 -24
- package/examples/uiSystem/index.html +1 -1
- package/package.json +1 -1
- package/plugins/box2d.js +8 -8
- package/plugins/drawUtilities.js +126 -0
- package/plugins/newgrounds.js +1 -1
- package/plugins/pluginExport.js +7 -1
- package/plugins/postProcess.js +2 -2
- package/plugins/uiSystem.js +153 -65
- package/plugins/zzfxm.js +1 -1
- package/reference.md +10 -10
- package/src/engine.js +50 -29
- package/src/engineAudio.js +14 -5
- package/src/engineBuild.bat +6 -1
- package/src/engineBuild.js +20 -5
- package/src/engineDebug.js +53 -26
- package/src/engineDraw.js +108 -57
- package/src/engineExport.js +21 -9
- package/src/engineInput.js +109 -37
- 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 +182 -130
- package/src/engineWebGL.js +47 -36
package/dist/littlejs.d.ts
CHANGED
|
@@ -59,18 +59,32 @@ 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
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
|
|
@@ -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}
|
|
@@ -753,7 +764,7 @@ declare module "littlejsengine" {
|
|
|
753
764
|
* @param {number} [length]
|
|
754
765
|
* @return {Vector2}
|
|
755
766
|
* @memberof Random */
|
|
756
|
-
export function
|
|
767
|
+
export function randVec2(length?: number): Vector2;
|
|
757
768
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
758
769
|
* @param {Color} [colorA=(1,1,1,1)]
|
|
759
770
|
* @param {Color} [colorB=(0,0,0,1)]
|
|
@@ -773,8 +784,8 @@ declare module "littlejsengine" {
|
|
|
773
784
|
*/
|
|
774
785
|
export class RandomGenerator {
|
|
775
786
|
/** Create a random number generator with the seed passed in
|
|
776
|
-
* @param {number} seed - Starting seed */
|
|
777
|
-
constructor(seed
|
|
787
|
+
* @param {number} [seed] - Starting seed or engine default seed */
|
|
788
|
+
constructor(seed?: number);
|
|
778
789
|
/** @property {number} - random seed */
|
|
779
790
|
seed: number;
|
|
780
791
|
/** Returns a seeded random value between the two values passed in
|
|
@@ -787,6 +798,10 @@ declare module "littlejsengine" {
|
|
|
787
798
|
* @param {number} [valueB]
|
|
788
799
|
* @return {number} */
|
|
789
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;
|
|
790
805
|
/** Randomly returns either -1 or 1 deterministically
|
|
791
806
|
* @return {number} */
|
|
792
807
|
sign(): number;
|
|
@@ -795,6 +810,14 @@ declare module "littlejsengine" {
|
|
|
795
810
|
* @param {number} [valueB]
|
|
796
811
|
* @return {number} */
|
|
797
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;
|
|
798
821
|
}
|
|
799
822
|
/**
|
|
800
823
|
* 2D Vector object with vector math library
|
|
@@ -872,6 +895,11 @@ declare module "littlejsengine" {
|
|
|
872
895
|
* @param {Vector2} v - other vector
|
|
873
896
|
* @return {number} */
|
|
874
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;
|
|
875
903
|
/** Returns the clockwise angle of this vector, up is angle 0
|
|
876
904
|
* @return {number} */
|
|
877
905
|
angle(): number;
|
|
@@ -894,9 +922,16 @@ declare module "littlejsengine" {
|
|
|
894
922
|
/** Returns a copy of this vector that has been inverted
|
|
895
923
|
* @return {Vector2} */
|
|
896
924
|
invert(): Vector2;
|
|
925
|
+
/** Returns a copy of this vector absolute values
|
|
926
|
+
* @return {Vector2} */
|
|
927
|
+
abs(): Vector2;
|
|
897
928
|
/** Returns a copy of this vector with each axis floored
|
|
898
929
|
* @return {Vector2} */
|
|
899
930
|
floor(): Vector2;
|
|
931
|
+
/** Returns new vec2 with modded values
|
|
932
|
+
* @param {number} [divisor]
|
|
933
|
+
* @return {Vector2} */
|
|
934
|
+
mod(divisor?: number): Vector2;
|
|
900
935
|
/** Returns the area this vector covers as a rectangle
|
|
901
936
|
* @return {number} */
|
|
902
937
|
area(): number;
|
|
@@ -923,7 +958,7 @@ declare module "littlejsengine" {
|
|
|
923
958
|
* let a = new Color; // white
|
|
924
959
|
* let b = new Color(1, 0, 0); // red
|
|
925
960
|
* let c = new Color(0, 0, 0, 0); // transparent black
|
|
926
|
-
* let d = rgb(0, 0, 1);
|
|
961
|
+
* let d = rgb(0, 0, 1); // blue using rgb color
|
|
927
962
|
* let e = hsl(.3, 1, .5); // green using hsl color
|
|
928
963
|
*/
|
|
929
964
|
export class Color {
|
|
@@ -1095,10 +1130,18 @@ declare module "littlejsengine" {
|
|
|
1095
1130
|
* @type {Color}
|
|
1096
1131
|
* @memberof Utilities */
|
|
1097
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;
|
|
1098
1137
|
/** Color - Black #000000
|
|
1099
1138
|
* @type {Color}
|
|
1100
1139
|
* @memberof Utilities */
|
|
1101
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;
|
|
1102
1145
|
/** Color - Gray #808080
|
|
1103
1146
|
* @type {Color}
|
|
1104
1147
|
* @memberof Utilities */
|
|
@@ -1175,6 +1218,8 @@ declare module "littlejsengine" {
|
|
|
1175
1218
|
textureIndex: number;
|
|
1176
1219
|
/** @property {number} - How many pixels padding around tiles */
|
|
1177
1220
|
padding: number;
|
|
1221
|
+
/** @property {TextureInfo} - The texture info for this tile */
|
|
1222
|
+
textureInfo: TextureInfo;
|
|
1178
1223
|
/** Returns a copy of this tile offset by a vector
|
|
1179
1224
|
* @param {Vector2} offset - Offset to apply in pixels
|
|
1180
1225
|
* @return {TileInfo}
|
|
@@ -1185,26 +1230,31 @@ declare module "littlejsengine" {
|
|
|
1185
1230
|
* @return {TileInfo}
|
|
1186
1231
|
*/
|
|
1187
1232
|
frame(frame: number): TileInfo;
|
|
1188
|
-
/**
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
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;
|
|
1192
1240
|
}
|
|
1193
1241
|
/** Texture Info - Stores info about each texture */
|
|
1194
1242
|
export class TextureInfo {
|
|
1195
1243
|
/**
|
|
1196
1244
|
* Create a TextureInfo, called automatically by the engine
|
|
1197
|
-
* @param {HTMLImageElement} image
|
|
1245
|
+
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1246
|
+
* @param {WebGLTexture} [glTexture] - webgl texture
|
|
1198
1247
|
*/
|
|
1199
|
-
constructor(image: HTMLImageElement);
|
|
1248
|
+
constructor(image: HTMLImageElement | OffscreenCanvas, glTexture?: WebGLTexture);
|
|
1200
1249
|
/** @property {HTMLImageElement} - image source */
|
|
1201
|
-
image: HTMLImageElement;
|
|
1250
|
+
image: OffscreenCanvas | HTMLImageElement;
|
|
1202
1251
|
/** @property {Vector2} - size of the image */
|
|
1203
1252
|
size: Vector2;
|
|
1204
1253
|
/** @property {Vector2} - inverse of the size, cached for rendering */
|
|
1205
1254
|
sizeInverse: Vector2;
|
|
1206
1255
|
/** @property {WebGLTexture} - webgl texture */
|
|
1207
1256
|
glTexture: WebGLTexture;
|
|
1257
|
+
createWebGLTexture(): void;
|
|
1208
1258
|
}
|
|
1209
1259
|
/**
|
|
1210
1260
|
* LittleJS Drawing System
|
|
@@ -1296,9 +1346,9 @@ declare module "littlejsengine" {
|
|
|
1296
1346
|
* @param {number} [lineWidth=0]
|
|
1297
1347
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1298
1348
|
* @param {boolean} [screenSpace=false]
|
|
1299
|
-
* @param {CanvasRenderingContext2D} [context=
|
|
1349
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1300
1350
|
* @memberof Draw */
|
|
1301
|
-
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;
|
|
1302
1352
|
/** Draw colored ellipse using passed in point
|
|
1303
1353
|
* @param {Vector2} pos
|
|
1304
1354
|
* @param {number} [width=1]
|
|
@@ -1308,9 +1358,9 @@ declare module "littlejsengine" {
|
|
|
1308
1358
|
* @param {number} [lineWidth=0]
|
|
1309
1359
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1310
1360
|
* @param {boolean} [screenSpace=false]
|
|
1311
|
-
* @param {CanvasRenderingContext2D} [context=
|
|
1361
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1312
1362
|
* @memberof Draw */
|
|
1313
|
-
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;
|
|
1314
1364
|
/** Draw colored circle using passed in point
|
|
1315
1365
|
* @param {Vector2} pos
|
|
1316
1366
|
* @param {number} [radius=1]
|
|
@@ -1318,19 +1368,19 @@ declare module "littlejsengine" {
|
|
|
1318
1368
|
* @param {number} [lineWidth=0]
|
|
1319
1369
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1320
1370
|
* @param {boolean} [screenSpace=false]
|
|
1321
|
-
* @param {CanvasRenderingContext2D} [context=
|
|
1371
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1322
1372
|
* @memberof Draw */
|
|
1323
|
-
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;
|
|
1324
1374
|
/** Draw directly to a 2d canvas context in world space
|
|
1325
1375
|
* @param {Vector2} pos
|
|
1326
1376
|
* @param {Vector2} size
|
|
1327
1377
|
* @param {number} angle
|
|
1328
|
-
* @param {boolean} mirror
|
|
1329
|
-
* @param {Function} drawFunction
|
|
1378
|
+
* @param {boolean} [mirror]
|
|
1379
|
+
* @param {Function} [drawFunction]
|
|
1330
1380
|
* @param {boolean} [screenSpace=false]
|
|
1331
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=
|
|
1381
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1332
1382
|
* @memberof Draw */
|
|
1333
|
-
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;
|
|
1334
1384
|
/** Draw text on main canvas in world space
|
|
1335
1385
|
* Automatically splits new lines into rows
|
|
1336
1386
|
* @param {string} text
|
|
@@ -1342,7 +1392,7 @@ declare module "littlejsengine" {
|
|
|
1342
1392
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1343
1393
|
* @param {string} [font=fontDefault]
|
|
1344
1394
|
* @param {number} [maxWidth]
|
|
1345
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=
|
|
1395
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1346
1396
|
* @memberof Draw */
|
|
1347
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;
|
|
1348
1398
|
/** Draw text on overlay canvas in world space
|
|
@@ -1375,7 +1425,7 @@ declare module "littlejsengine" {
|
|
|
1375
1425
|
/** Enable normal or additive blend mode
|
|
1376
1426
|
* @param {boolean} [additive]
|
|
1377
1427
|
* @param {boolean} [useWebGL=glEnable]
|
|
1378
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context
|
|
1428
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1379
1429
|
* @memberof Draw */
|
|
1380
1430
|
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1381
1431
|
/** Combines all LittleJS canvases onto the main canvas and clears them
|
|
@@ -1462,11 +1512,10 @@ declare module "littlejsengine" {
|
|
|
1462
1512
|
* @return {WebGLShader}
|
|
1463
1513
|
* @memberof WebGL */
|
|
1464
1514
|
export function glCompileShader(source: string, type: number): WebGLShader;
|
|
1465
|
-
/**
|
|
1515
|
+
/** Flush any sprites still in the buffer and copy to main canvas
|
|
1466
1516
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1467
|
-
* @param {boolean} [forceDraw]
|
|
1468
1517
|
* @memberof WebGL */
|
|
1469
|
-
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D
|
|
1518
|
+
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1470
1519
|
/** Create WebGL program with given shaders
|
|
1471
1520
|
* @param {String} vsSource
|
|
1472
1521
|
* @param {String} fsSource
|
|
@@ -1474,37 +1523,42 @@ declare module "littlejsengine" {
|
|
|
1474
1523
|
* @memberof WebGL */
|
|
1475
1524
|
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
|
|
1476
1525
|
/** Create WebGL texture from an image and init the texture settings
|
|
1477
|
-
* @param {HTMLImageElement} image
|
|
1526
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} [image]
|
|
1478
1527
|
* @return {WebGLTexture}
|
|
1479
1528
|
* @memberof WebGL */
|
|
1480
|
-
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;
|
|
1481
1534
|
/** Set WebGL texture data from an image
|
|
1482
1535
|
* @param {WebGLTexture} texture
|
|
1483
|
-
* @param {HTMLImageElement} image
|
|
1536
|
+
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} image
|
|
1484
1537
|
* @memberof WebGL */
|
|
1485
|
-
export function glSetTextureData(texture: WebGLTexture, image: HTMLImageElement): void;
|
|
1538
|
+
export function glSetTextureData(texture: WebGLTexture, image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas): void;
|
|
1486
1539
|
/** Add a sprite to the gl draw list, used by all gl draw functions
|
|
1487
1540
|
* @param {Number} x
|
|
1488
1541
|
* @param {Number} y
|
|
1489
1542
|
* @param {Number} sizeX
|
|
1490
1543
|
* @param {Number} sizeY
|
|
1491
|
-
* @param {Number} angle
|
|
1492
|
-
* @param {Number} uv0X
|
|
1493
|
-
* @param {Number} uv0Y
|
|
1494
|
-
* @param {Number} uv1X
|
|
1495
|
-
* @param {Number} uv1Y
|
|
1544
|
+
* @param {Number} [angle]
|
|
1545
|
+
* @param {Number} [uv0X]
|
|
1546
|
+
* @param {Number} [uv0Y]
|
|
1547
|
+
* @param {Number} [uv1X]
|
|
1548
|
+
* @param {Number} [uv1Y]
|
|
1496
1549
|
* @param {Number} [rgba=-1] - white is -1
|
|
1497
1550
|
* @param {Number} [rgbaAdditive=0] - black is 0
|
|
1498
1551
|
* @memberof WebGL */
|
|
1499
|
-
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;
|
|
1500
1553
|
/** Draw all sprites and clear out the buffer, called automatically by the system whenever necessary
|
|
1501
1554
|
* @memberof WebGL */
|
|
1502
1555
|
export function glFlush(): void;
|
|
1503
1556
|
/** Set the WebGl texture, called automatically if using multiple textures
|
|
1504
1557
|
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1505
1558
|
* @param {WebGLTexture} texture
|
|
1559
|
+
* @param {boolean} wrap - Should the texture wrap or clamp
|
|
1506
1560
|
* @memberof WebGL */
|
|
1507
|
-
export function glSetTexture(texture: WebGLTexture): void;
|
|
1561
|
+
export function glSetTexture(texture: WebGLTexture, wrap?: boolean): void;
|
|
1508
1562
|
/** Set anti-aliasing for webgl canvas
|
|
1509
1563
|
* @param {boolean} [antialias]
|
|
1510
1564
|
* @memberof WebGL */
|
|
@@ -1558,7 +1612,15 @@ declare module "littlejsengine" {
|
|
|
1558
1612
|
export function keyDirection(up?: string, down?: string, left?: string, right?: string): Vector2;
|
|
1559
1613
|
/** Clears all input
|
|
1560
1614
|
* @memberof Input */
|
|
1561
|
-
export function
|
|
1615
|
+
export function inputClear(): void;
|
|
1616
|
+
/** Clears an input key state
|
|
1617
|
+
* @param {string|number} key
|
|
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;
|
|
1562
1624
|
/** Returns true if mouse button is down
|
|
1563
1625
|
* @function
|
|
1564
1626
|
* @param {number} button
|
|
@@ -1585,6 +1647,14 @@ declare module "littlejsengine" {
|
|
|
1585
1647
|
* @type {Vector2}
|
|
1586
1648
|
* @memberof Input */
|
|
1587
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;
|
|
1588
1658
|
/** Mouse wheel delta this frame
|
|
1589
1659
|
* @type {number}
|
|
1590
1660
|
* @memberof Input */
|
|
@@ -1637,6 +1707,16 @@ declare module "littlejsengine" {
|
|
|
1637
1707
|
/** True if a touch device has been detected
|
|
1638
1708
|
* @memberof Input */
|
|
1639
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;
|
|
1640
1720
|
/**
|
|
1641
1721
|
* Sound Object - Stores a sound for later use and can be played positionally
|
|
1642
1722
|
*
|
|
@@ -1678,8 +1758,10 @@ declare module "littlejsengine" {
|
|
|
1678
1758
|
* @param {number} [volume] - How much to scale volume by
|
|
1679
1759
|
*/
|
|
1680
1760
|
setVolume(volume?: number): void;
|
|
1681
|
-
/** Stop the last instance of this sound that was played
|
|
1682
|
-
|
|
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;
|
|
1683
1765
|
/** Get source of most recent instance of this sound that was played
|
|
1684
1766
|
* @return {AudioBufferSourceNode}
|
|
1685
1767
|
*/
|
|
@@ -1859,45 +1941,45 @@ declare module "littlejsengine" {
|
|
|
1859
1941
|
drawSize: any;
|
|
1860
1942
|
/** @property {TileInfo} - Tile info to render object (undefined is untextured) */
|
|
1861
1943
|
tileInfo: TileInfo;
|
|
1862
|
-
/** @property {number}
|
|
1944
|
+
/** @property {number} - Angle to rotate the object */
|
|
1863
1945
|
angle: number;
|
|
1864
|
-
/** @property {Color}
|
|
1946
|
+
/** @property {Color} - Color to apply when rendered */
|
|
1865
1947
|
color: Color;
|
|
1866
|
-
/** @property {Color}
|
|
1948
|
+
/** @property {Color} - Additive color to apply when rendered */
|
|
1867
1949
|
additiveColor: any;
|
|
1868
1950
|
/** @property {boolean} - Should it flip along y axis when rendered */
|
|
1869
1951
|
mirror: boolean;
|
|
1870
|
-
/** @property {number} [mass=objectDefaultMass]
|
|
1952
|
+
/** @property {number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
|
|
1871
1953
|
mass: number;
|
|
1872
|
-
/** @property {number} [damping=objectDefaultDamping]
|
|
1954
|
+
/** @property {number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
|
|
1873
1955
|
damping: number;
|
|
1874
1956
|
/** @property {number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
|
|
1875
1957
|
angleDamping: number;
|
|
1876
|
-
/** @property {number} [
|
|
1877
|
-
|
|
1878
|
-
/** @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) */
|
|
1879
1961
|
friction: number;
|
|
1880
|
-
/** @property {number}
|
|
1962
|
+
/** @property {number} - How much to scale gravity by for this object */
|
|
1881
1963
|
gravityScale: number;
|
|
1882
|
-
/** @property {number}
|
|
1964
|
+
/** @property {number} - Objects are sorted by render order */
|
|
1883
1965
|
renderOrder: number;
|
|
1884
1966
|
/** @property {Vector2} - Velocity of the object */
|
|
1885
1967
|
velocity: Vector2;
|
|
1886
|
-
/** @property {number}
|
|
1968
|
+
/** @property {number} - Angular velocity of the object */
|
|
1887
1969
|
angleVelocity: number;
|
|
1888
|
-
/** @property {number}
|
|
1970
|
+
/** @property {number} - Track when object was created */
|
|
1889
1971
|
spawnTime: number;
|
|
1890
|
-
/** @property {Array<EngineObject>}
|
|
1972
|
+
/** @property {Array<EngineObject>} - List of children of this object */
|
|
1891
1973
|
children: any[];
|
|
1892
|
-
/** @property {boolean}
|
|
1893
|
-
|
|
1974
|
+
/** @property {boolean} - Limit object speed along x and y axis */
|
|
1975
|
+
clampSpeed: boolean;
|
|
1894
1976
|
/** @property {EngineObject} - Object we are standing on, if any */
|
|
1895
1977
|
groundObject: EngineObject | TileCollisionLayer;
|
|
1896
1978
|
/** @property {EngineObject} - Parent of object if in local space */
|
|
1897
1979
|
parent: any;
|
|
1898
|
-
/** @property {Vector2}
|
|
1980
|
+
/** @property {Vector2} - Local position if child */
|
|
1899
1981
|
localPos: Vector2;
|
|
1900
|
-
/** @property {number}
|
|
1982
|
+
/** @property {number} - Local angle if child */
|
|
1901
1983
|
localAngle: number;
|
|
1902
1984
|
/** @property {boolean} - Object collides with the tile collision */
|
|
1903
1985
|
collideTiles: boolean;
|
|
@@ -1913,7 +1995,7 @@ declare module "littlejsengine" {
|
|
|
1913
1995
|
update(): void;
|
|
1914
1996
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
1915
1997
|
render(): void;
|
|
1916
|
-
/** Destroy this object, destroy
|
|
1998
|
+
/** Destroy this object, destroy its children, detach it's parent, and mark it for removal */
|
|
1917
1999
|
destroy(): void;
|
|
1918
2000
|
destroyed: number;
|
|
1919
2001
|
/** Convert from local space to world space
|
|
@@ -1944,6 +2026,9 @@ declare module "littlejsengine" {
|
|
|
1944
2026
|
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
1945
2027
|
* @param {Vector2} acceleration */
|
|
1946
2028
|
applyAcceleration(acceleration: Vector2): void;
|
|
2029
|
+
/** Apply angular acceleration to this object
|
|
2030
|
+
* @param {number} acceleration */
|
|
2031
|
+
applyAngularAcceleration(acceleration: number): void;
|
|
1947
2032
|
/** Apply force to this object (adjust velocity, affected by mass)
|
|
1948
2033
|
* @param {Vector2} force */
|
|
1949
2034
|
applyForce(force: Vector2): void;
|
|
@@ -1987,22 +2072,34 @@ declare module "littlejsengine" {
|
|
|
1987
2072
|
* @param {Vector2} pos
|
|
1988
2073
|
* @return {number}
|
|
1989
2074
|
* @memberof TileCollision */
|
|
1990
|
-
export function
|
|
2075
|
+
export function tileCollisionGetData(pos: Vector2): number;
|
|
1991
2076
|
/** Check if a tile layer collides with another object
|
|
1992
2077
|
* @param {Vector2} pos
|
|
1993
2078
|
* @param {Vector2} [size=(0,0)]
|
|
1994
|
-
* @param {EngineObject} [object]
|
|
2079
|
+
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2080
|
+
* @param {boolean} [solidOnly] - Only check solid layers if true
|
|
1995
2081
|
* @return {TileCollisionLayer}
|
|
1996
2082
|
* @memberof TileCollision */
|
|
1997
|
-
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): TileCollisionLayer;
|
|
2083
|
+
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
|
|
1998
2084
|
/** Return the center of first tile hit, undefined if nothing was hit.
|
|
1999
2085
|
* This does not return the exact intersection, but the center of the tile hit.
|
|
2000
2086
|
* @param {Vector2} posStart
|
|
2001
2087
|
* @param {Vector2} posEnd
|
|
2002
|
-
* @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
|
|
2003
2090
|
* @return {Vector2}
|
|
2004
2091
|
* @memberof TileCollision */
|
|
2005
|
-
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>;
|
|
2006
2103
|
/**
|
|
2007
2104
|
* Tile layer data object stores info about how to draw a tile
|
|
2008
2105
|
* @example
|
|
@@ -2031,33 +2128,85 @@ declare module "littlejsengine" {
|
|
|
2031
2128
|
/** Set this tile to clear, it will not be rendered */
|
|
2032
2129
|
clear(): void;
|
|
2033
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
|
+
}
|
|
2034
2190
|
/**
|
|
2035
2191
|
* Tile Layer - cached rendering system for tile layers
|
|
2036
2192
|
* - Each Tile layer is rendered to an off screen canvas
|
|
2037
2193
|
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
2038
2194
|
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
2039
2195
|
* - For with 16x16 tiles this limits layers to 256x256 on mobile devices
|
|
2040
|
-
* @extends
|
|
2196
|
+
* @extends CanvasLayer
|
|
2041
2197
|
* @example
|
|
2042
2198
|
* const tileLayer = new TileLayer(vec2(), vec2(200,100));
|
|
2043
2199
|
*/
|
|
2044
|
-
export class TileLayer extends
|
|
2200
|
+
export class TileLayer extends CanvasLayer {
|
|
2045
2201
|
/** Create a tile layer object
|
|
2046
|
-
* @param {Vector2}
|
|
2047
|
-
* @param {Vector2}
|
|
2048
|
-
* @param {TileInfo} [tileInfo]
|
|
2049
|
-
* @param {Vector2} [scale=(1,1)]
|
|
2050
|
-
* @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
|
|
2051
2208
|
*/
|
|
2052
|
-
constructor(position
|
|
2053
|
-
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
2054
|
-
canvas: HTMLCanvasElement;
|
|
2055
|
-
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this tile layer */
|
|
2056
|
-
context: CanvasRenderingContext2D;
|
|
2057
|
-
/** @property {Vector2} - How much to scale this layer when rendered */
|
|
2058
|
-
scale: Vector2;
|
|
2059
|
-
/** @property {boolean} - If true this layer will render to overlay canvas and appear above all objects */
|
|
2060
|
-
isOverlay: boolean;
|
|
2209
|
+
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number, useWebGL?: boolean);
|
|
2061
2210
|
data: TileLayerData[];
|
|
2062
2211
|
/** Draw all the tile data to an offscreen canvas
|
|
2063
2212
|
* - This may be slow in some browsers but only needs to be done once */
|
|
@@ -2075,13 +2224,6 @@ declare module "littlejsengine" {
|
|
|
2075
2224
|
* @param {boolean} [clear] - should the old tile be cleared out
|
|
2076
2225
|
*/
|
|
2077
2226
|
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2078
|
-
/** Draw directly to the 2D canvas in world space (bypass webgl)
|
|
2079
|
-
* @param {Vector2} pos
|
|
2080
|
-
* @param {Vector2} size
|
|
2081
|
-
* @param {number} angle
|
|
2082
|
-
* @param {boolean} mirror
|
|
2083
|
-
* @param {Function} drawFunction */
|
|
2084
|
-
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
2085
2227
|
/** Set data at a given position in the array
|
|
2086
2228
|
* @param {Vector2} layerPos - Local position in array
|
|
2087
2229
|
* @param {TileLayerData} data - Data to set
|
|
@@ -2091,22 +2233,8 @@ declare module "littlejsengine" {
|
|
|
2091
2233
|
* @param {Vector2} layerPos - Local position in array
|
|
2092
2234
|
* @return {TileLayerData} */
|
|
2093
2235
|
getData(layerPos: Vector2): TileLayerData;
|
|
2094
|
-
/** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
2095
|
-
savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
|
|
2096
|
-
/** Draw a tile directly onto the layer canvas in world space
|
|
2097
|
-
* @param {Vector2} pos
|
|
2098
|
-
* @param {Vector2} [size=(1,1)]
|
|
2099
|
-
* @param {TileInfo} [tileInfo]
|
|
2100
|
-
* @param {Color} [color=(1,1,1,1)]
|
|
2101
|
-
* @param {number} [angle=0]
|
|
2102
|
-
* @param {boolean} [mirror=0] */
|
|
2103
|
-
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2104
|
-
/** Draw a rectangle directly onto the layer canvas in world space
|
|
2105
|
-
* @param {Vector2} pos
|
|
2106
|
-
* @param {Vector2} [size=(1,1)]
|
|
2107
|
-
* @param {Color} [color=(1,1,1,1)]
|
|
2108
|
-
* @param {number} [angle=0] */
|
|
2109
|
-
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];
|
|
2110
2238
|
}
|
|
2111
2239
|
/**
|
|
2112
2240
|
* Tile Collision Layer - a tile layer with collision
|
|
@@ -2117,25 +2245,26 @@ declare module "littlejsengine" {
|
|
|
2117
2245
|
*/
|
|
2118
2246
|
export class TileCollisionLayer extends TileLayer {
|
|
2119
2247
|
/** Create a tile layer object
|
|
2120
|
-
* @param {Vector2}
|
|
2121
|
-
* @param {Vector2}
|
|
2122
|
-
* @param {TileInfo} [tileInfo]
|
|
2123
|
-
* @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
|
|
2124
2253
|
*/
|
|
2125
|
-
constructor(position
|
|
2254
|
+
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number, useWebGL?: boolean);
|
|
2126
2255
|
/** @property {Array<number>} - The tile collision grid */
|
|
2127
2256
|
collisionData: any[];
|
|
2128
2257
|
/** Clear and initialize tile collision to new size
|
|
2129
2258
|
* @param {Vector2} size - width and height of tile collision 2d grid */
|
|
2130
2259
|
initCollision(size: Vector2): void;
|
|
2131
2260
|
/** Set tile collision data for a given cell in the grid
|
|
2132
|
-
* @param {Vector2}
|
|
2261
|
+
* @param {Vector2} gridPos
|
|
2133
2262
|
* @param {number} [data] */
|
|
2134
|
-
setCollisionData(
|
|
2263
|
+
setCollisionData(gridPos: Vector2, data?: number): void;
|
|
2135
2264
|
/** Get tile collision data for a given cell in the grid
|
|
2136
|
-
* @param {Vector2}
|
|
2265
|
+
* @param {Vector2} gridPos
|
|
2137
2266
|
* @return {number} */
|
|
2138
|
-
getCollisionData(
|
|
2267
|
+
getCollisionData(gridPos: Vector2): number;
|
|
2139
2268
|
/** Check if collision with another object should occur
|
|
2140
2269
|
* @param {Vector2} pos
|
|
2141
2270
|
* @param {Vector2} [size=(0,0)]
|
|
@@ -2163,7 +2292,7 @@ declare module "littlejsengine" {
|
|
|
2163
2292
|
* (
|
|
2164
2293
|
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emitCone
|
|
2165
2294
|
* tile(0, 16), // tileInfo
|
|
2166
|
-
* rgb(1,1,1),
|
|
2295
|
+
* rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
|
|
2167
2296
|
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
2168
2297
|
* 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
2169
2298
|
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
@@ -2535,10 +2664,20 @@ declare module "littlejsengine" {
|
|
|
2535
2664
|
defaultButtonColor: Color;
|
|
2536
2665
|
/** @property {Color} - Default hover color for UI elements */
|
|
2537
2666
|
defaultHoverColor: Color;
|
|
2667
|
+
/** @property {Color} - Default color for disabled UI elements */
|
|
2668
|
+
defaultDisabledColor: Color;
|
|
2538
2669
|
/** @property {number} - Default line width for UI elements */
|
|
2539
2670
|
defaultLineWidth: number;
|
|
2671
|
+
/** @property {number} - Default rounded rect corner radius for UI elements */
|
|
2672
|
+
defaultCornerRadius: number;
|
|
2540
2673
|
/** @property {string} - Default font for UI elements */
|
|
2541
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;
|
|
2542
2681
|
/** @property {Array<UIObject>} - List of all UI elements */
|
|
2543
2682
|
uiObjects: any[];
|
|
2544
2683
|
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
|
|
@@ -2548,8 +2687,9 @@ declare module "littlejsengine" {
|
|
|
2548
2687
|
* @param {Vector2} size
|
|
2549
2688
|
* @param {Color} [color=uiSystem.defaultColor]
|
|
2550
2689
|
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2551
|
-
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2552
|
-
|
|
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;
|
|
2553
2693
|
/** Draw a line to the UI context
|
|
2554
2694
|
* @param {Vector2} posA
|
|
2555
2695
|
* @param {Vector2} posB
|
|
@@ -2590,26 +2730,40 @@ declare module "littlejsengine" {
|
|
|
2590
2730
|
pos: Vector2;
|
|
2591
2731
|
/** @property {Vector2} - Screen space size of the object */
|
|
2592
2732
|
size: Vector2;
|
|
2593
|
-
/** @property {Color} */
|
|
2733
|
+
/** @property {Color} - color of the object */
|
|
2594
2734
|
color: Color;
|
|
2595
|
-
/** @property {Color} */
|
|
2596
|
-
lineColor: Color;
|
|
2597
|
-
/** @property {Color} */
|
|
2735
|
+
/** @property {Color} - color for text */
|
|
2598
2736
|
textColor: Color;
|
|
2599
|
-
/** @property {Color} */
|
|
2737
|
+
/** @property {Color} - color used when hovering over the object */
|
|
2600
2738
|
hoverColor: Color;
|
|
2601
|
-
/** @property {
|
|
2739
|
+
/** @property {Color} - color for line drawing */
|
|
2740
|
+
lineColor: Color;
|
|
2741
|
+
/** @property {number} - width for line drawing */
|
|
2602
2742
|
lineWidth: number;
|
|
2603
|
-
/** @property {string} */
|
|
2743
|
+
/** @property {string} - font for this objecct */
|
|
2604
2744
|
font: string;
|
|
2605
2745
|
/** @property {number} - override for text height */
|
|
2606
2746
|
textHeight: any;
|
|
2607
|
-
/** @property {boolean} */
|
|
2747
|
+
/** @property {boolean} - should this object be drawn */
|
|
2608
2748
|
visible: boolean;
|
|
2609
|
-
/** @property {Array<UIObject>} */
|
|
2749
|
+
/** @property {Array<UIObject>} - a list of this object's children */
|
|
2610
2750
|
children: any[];
|
|
2611
|
-
/** @property {UIObject} */
|
|
2751
|
+
/** @property {UIObject} - this object's parent, position is in parent space */
|
|
2612
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;
|
|
2613
2767
|
/** Add a child UIObject to this object
|
|
2614
2768
|
* @param {UIObject} child
|
|
2615
2769
|
*/
|
|
@@ -2620,10 +2774,10 @@ declare module "littlejsengine" {
|
|
|
2620
2774
|
removeChild(child: UIObject): void;
|
|
2621
2775
|
/** Update the object, called automatically by plugin once each frame */
|
|
2622
2776
|
update(): void;
|
|
2623
|
-
mouseIsOver: boolean;
|
|
2624
|
-
mouseIsHeld: boolean;
|
|
2625
2777
|
/** Render the object, called automatically by plugin once each frame */
|
|
2626
2778
|
render(): void;
|
|
2779
|
+
/** Special update for when object is invisible */
|
|
2780
|
+
updateInvisible(): void;
|
|
2627
2781
|
/** Called when the mouse enters the object */
|
|
2628
2782
|
onEnter(): void;
|
|
2629
2783
|
/** Called when the mouse leaves the object */
|
|
@@ -2632,6 +2786,8 @@ declare module "littlejsengine" {
|
|
|
2632
2786
|
onPress(): void;
|
|
2633
2787
|
/** Called when the mouse is released while over the object */
|
|
2634
2788
|
onRelease(): void;
|
|
2789
|
+
/** Called when user clicks on this object */
|
|
2790
|
+
onClick(): void;
|
|
2635
2791
|
/** Called when the state of this object changes */
|
|
2636
2792
|
onChange(): void;
|
|
2637
2793
|
}
|
|
@@ -2688,6 +2844,10 @@ declare module "littlejsengine" {
|
|
|
2688
2844
|
constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
|
|
2689
2845
|
/** @property {string} */
|
|
2690
2846
|
text: string;
|
|
2847
|
+
/** @property {Color} */
|
|
2848
|
+
disabledColor: Color;
|
|
2849
|
+
/** @property {boolean} */
|
|
2850
|
+
disabled: boolean;
|
|
2691
2851
|
}
|
|
2692
2852
|
/**
|
|
2693
2853
|
* UICheckbox - A UI object that acts as a checkbox
|
|
@@ -2721,6 +2881,7 @@ declare module "littlejsengine" {
|
|
|
2721
2881
|
value: number;
|
|
2722
2882
|
/** @property {string} */
|
|
2723
2883
|
text: string;
|
|
2884
|
+
/** @property {Color} */
|
|
2724
2885
|
handleColor: Color;
|
|
2725
2886
|
}
|
|
2726
2887
|
/**
|
|
@@ -3058,9 +3219,6 @@ declare module "littlejsengine" {
|
|
|
3058
3219
|
/** Apply torque to this object
|
|
3059
3220
|
* @param {number} torque */
|
|
3060
3221
|
applyTorque(torque: number): void;
|
|
3061
|
-
/** Apply angular acceleration to this object
|
|
3062
|
-
* @param {number} acceleration */
|
|
3063
|
-
applyAngularAcceleration(acceleration: number): void;
|
|
3064
3222
|
/** Check if this object has any fixtures
|
|
3065
3223
|
* @return {boolean} */
|
|
3066
3224
|
hasFixtures(): boolean;
|
|
@@ -3633,4 +3791,56 @@ declare module "littlejsengine" {
|
|
|
3633
3791
|
* @return {number} */
|
|
3634
3792
|
getCorrectionFactor(): number;
|
|
3635
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;
|
|
3636
3846
|
}
|