littlejsengine 1.14.16 → 1.14.23
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 +173 -50
- package/dist/littlejs.esm.js +892 -419
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +879 -419
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +854 -420
- package/examples/box2d/game.js +3 -2
- package/examples/box2d/tiles.png +0 -0
- package/examples/breakout/game.js +5 -5
- package/examples/electron/game.js +1 -41
- package/examples/electron/index.html +2 -2
- package/examples/htmlMenu/game.js +1 -1
- package/examples/index.html +69 -55
- package/examples/module/game.js +6 -8
- package/examples/particles/index.html +6 -9
- package/examples/platformer/gameCharacter.js +1 -1
- package/examples/platformer/gameEffects.js +8 -3
- package/examples/platformer/gameObjects.js +3 -3
- package/examples/shorts/animation.js +2 -2
- package/examples/shorts/base.html +4 -1
- package/examples/shorts/cameraDrag.js +22 -0
- package/examples/shorts/debugDraw.js +38 -0
- package/examples/shorts/fps.js +90 -0
- package/examples/shorts/helloWorld.js +1 -1
- package/examples/shorts/hillGlideGame.js +1 -1
- package/examples/shorts/landerGame.js +1 -1
- package/examples/shorts/musicPlayer.js +1 -0
- package/examples/shorts/parallax.js +1 -1
- package/examples/shorts/postProcess.js +1 -1
- package/examples/shorts/sequencer.js +5 -5
- package/examples/shorts/shader.js +29 -0
- package/examples/shorts/spaceGame.js +1 -1
- package/examples/shorts/spriteAtlas.js +6 -6
- package/examples/shorts/starfield.js +1 -1
- package/examples/shorts/tileLayer.js +1 -1
- package/examples/shorts/tileRaycast.js +39 -0
- package/examples/shorts/tiles.png +0 -0
- package/examples/shorts/tiltedView.js +14 -6
- package/examples/shorts/topDown.js +1 -1
- package/examples/starter/game.js +6 -8
- package/examples/starter/index.html +2 -2
- package/examples/style.css +1 -0
- package/examples/typescript/game.js +5 -4
- package/examples/typescript/game.ts +5 -7
- package/examples/uiSystem/game.js +3 -2
- package/package.json +1 -1
- package/plugins/postProcess.js +71 -51
- package/plugins/uiSystem.js +76 -23
- package/src/engine.js +30 -16
- package/src/engineAudio.js +33 -23
- package/src/engineDebug.js +27 -0
- package/src/engineDraw.js +103 -49
- package/src/engineExport.js +13 -0
- package/src/engineInput.js +14 -16
- package/src/engineObject.js +31 -6
- package/src/engineParticles.js +37 -16
- package/src/engineRelease.js +2 -1
- package/src/engineSettings.js +20 -1
- package/src/engineTileLayer.js +89 -94
- package/src/engineUtilities.js +206 -58
- package/src/engineWebGL.js +145 -69
- package/examples/shorts/raycasting.js +0 -79
package/dist/littlejs.d.ts
CHANGED
|
@@ -14,7 +14,11 @@ declare module "littlejsengine" {
|
|
|
14
14
|
/**
|
|
15
15
|
* - Function that processes an object
|
|
16
16
|
*/
|
|
17
|
-
export type ObjectCallbackFunction = (
|
|
17
|
+
export type ObjectCallbackFunction = (object: EngineObject) => any;
|
|
18
|
+
/**
|
|
19
|
+
* - Checks if a position is colliding
|
|
20
|
+
*/
|
|
21
|
+
export type LineTestFunction = (pos: Vector2) => any;
|
|
18
22
|
/**
|
|
19
23
|
* - A function that draws to a 2D canvas context
|
|
20
24
|
*/
|
|
@@ -143,7 +147,7 @@ declare module "littlejsengine" {
|
|
|
143
147
|
export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>): Array<EngineObject>;
|
|
144
148
|
/**
|
|
145
149
|
* @callback ObjectCallbackFunction - Function that processes an object
|
|
146
|
-
* @param {EngineObject}
|
|
150
|
+
* @param {EngineObject} object
|
|
147
151
|
* @memberof Engine
|
|
148
152
|
*/
|
|
149
153
|
/** Triggers a callback for each object within a given area
|
|
@@ -165,10 +169,12 @@ declare module "littlejsengine" {
|
|
|
165
169
|
* @memberof Engine
|
|
166
170
|
*/
|
|
167
171
|
/** Add a new update function for a plugin
|
|
168
|
-
* @param {PluginCallback} [
|
|
169
|
-
* @param {PluginCallback} [
|
|
172
|
+
* @param {PluginCallback} [update]
|
|
173
|
+
* @param {PluginCallback} [render]
|
|
174
|
+
* @param {PluginCallback} [glContextLost]
|
|
175
|
+
* @param {PluginCallback} [glContextRestored]
|
|
170
176
|
* @memberof Engine */
|
|
171
|
-
export function engineAddPlugin(
|
|
177
|
+
export function engineAddPlugin(update?: PluginCallback, render?: PluginCallback, glContextLost?: PluginCallback, glContextRestored?: PluginCallback): void;
|
|
172
178
|
/**
|
|
173
179
|
* LittleJS Debug System
|
|
174
180
|
* - Press Esc to show debug overlay with mouse pick
|
|
@@ -454,6 +460,13 @@ declare module "littlejsengine" {
|
|
|
454
460
|
* @default
|
|
455
461
|
* @memberof Settings */
|
|
456
462
|
export let touchGamepadEnable: boolean;
|
|
463
|
+
/** True if touch gamepad should have start button in the center
|
|
464
|
+
* - When the game is paused, any touch will press the button
|
|
465
|
+
* - This can function as a way to pause/unpause the game
|
|
466
|
+
* @type {boolean}
|
|
467
|
+
* @default
|
|
468
|
+
* @memberof Settings */
|
|
469
|
+
export let touchGamepadCenterButton: boolean;
|
|
457
470
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
458
471
|
* @type {boolean}
|
|
459
472
|
* @default
|
|
@@ -635,6 +648,11 @@ declare module "littlejsengine" {
|
|
|
635
648
|
* @param {boolean} enable
|
|
636
649
|
* @memberof Settings */
|
|
637
650
|
export function setTouchGamepadEnable(enable: boolean): void;
|
|
651
|
+
/** True if touch gamepad should have start button in the center
|
|
652
|
+
* - This can function as a way to pause/unpause the game
|
|
653
|
+
* @param {boolean} enable
|
|
654
|
+
* @memberof Settings */
|
|
655
|
+
export function setTouchGamepadCenterButton(enable: boolean): void;
|
|
638
656
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
639
657
|
* @param {boolean} analog
|
|
640
658
|
* @memberof Settings */
|
|
@@ -700,7 +718,7 @@ declare module "littlejsengine" {
|
|
|
700
718
|
* - RandomGenerator - seeded random number generator
|
|
701
719
|
* @namespace Utilities
|
|
702
720
|
*/
|
|
703
|
-
/**
|
|
721
|
+
/** The value of PI
|
|
704
722
|
* @type {number}
|
|
705
723
|
* @default Math.PI
|
|
706
724
|
* @memberof Utilities */
|
|
@@ -709,22 +727,68 @@ declare module "littlejsengine" {
|
|
|
709
727
|
* @param {number} value
|
|
710
728
|
* @return {number}
|
|
711
729
|
* @memberof Utilities */
|
|
712
|
-
export
|
|
730
|
+
export const abs: (x: number) => number;
|
|
731
|
+
/** Returns floored value of value passed in
|
|
732
|
+
* @param {number} value
|
|
733
|
+
* @return {number}
|
|
734
|
+
* @memberof Utilities */
|
|
735
|
+
export const floor: (x: number) => number;
|
|
736
|
+
/** Returns ceiled value of value passed in
|
|
737
|
+
* @param {number} value
|
|
738
|
+
* @return {number}
|
|
739
|
+
* @memberof Utilities */
|
|
740
|
+
export const ceil: (x: number) => number;
|
|
741
|
+
/** Returns rounded value passed in
|
|
742
|
+
* @param {number} value
|
|
743
|
+
* @return {number}
|
|
744
|
+
* @memberof Utilities */
|
|
745
|
+
export const round: (x: number) => number;
|
|
713
746
|
/** Returns lowest value passed in
|
|
714
747
|
* @param {...number} values
|
|
715
748
|
* @return {number}
|
|
716
749
|
* @memberof Utilities */
|
|
717
|
-
export
|
|
750
|
+
export const min: (...values: number[]) => number;
|
|
718
751
|
/** Returns highest value passed in
|
|
719
752
|
* @param {...number} values
|
|
720
753
|
* @return {number}
|
|
721
754
|
* @memberof Utilities */
|
|
722
|
-
export
|
|
755
|
+
export const max: (...values: number[]) => number;
|
|
723
756
|
/** Returns the sign of value passed in
|
|
724
757
|
* @param {number} value
|
|
725
758
|
* @return {number}
|
|
726
759
|
* @memberof Utilities */
|
|
727
|
-
export
|
|
760
|
+
export const sign: (x: number) => number;
|
|
761
|
+
/** Returns hypotenuse of values passed in
|
|
762
|
+
* @param {...number} values
|
|
763
|
+
* @return {number}
|
|
764
|
+
* @memberof Utilities */
|
|
765
|
+
export const hypot: (...values: number[]) => number;
|
|
766
|
+
/** Returns log2 of value passed in
|
|
767
|
+
* @param {number} value
|
|
768
|
+
* @return {number}
|
|
769
|
+
* @memberof Utilities */
|
|
770
|
+
export const log2: (x: number) => number;
|
|
771
|
+
/** Returns sin of value passed in
|
|
772
|
+
* @param {number} value
|
|
773
|
+
* @return {number}
|
|
774
|
+
* @memberof Utilities */
|
|
775
|
+
export const sin: (x: number) => number;
|
|
776
|
+
/** Returns cos of value passed in
|
|
777
|
+
* @param {number} value
|
|
778
|
+
* @return {number}
|
|
779
|
+
* @memberof Utilities */
|
|
780
|
+
export const cos: (x: number) => number;
|
|
781
|
+
/** Returns tan of value passed in
|
|
782
|
+
* @param {number} value
|
|
783
|
+
* @return {number}
|
|
784
|
+
* @memberof Utilities */
|
|
785
|
+
export const tan: (x: number) => number;
|
|
786
|
+
/** Returns atan2 of values passed in
|
|
787
|
+
* @param {number} y
|
|
788
|
+
* @param {number} x
|
|
789
|
+
* @return {number}
|
|
790
|
+
* @memberof Utilities */
|
|
791
|
+
export const atan2: (y: number, x: number) => number;
|
|
728
792
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
729
793
|
* @param {number} dividend
|
|
730
794
|
* @param {number} [divisor]
|
|
@@ -909,6 +973,18 @@ declare module "littlejsengine" {
|
|
|
909
973
|
* @param {number} [valueB]
|
|
910
974
|
* @return {Vector2} */
|
|
911
975
|
vec2(valueA?: number, valueB?: number): Vector2;
|
|
976
|
+
/** Returns a random color between the two passed in colors, combine components if linear
|
|
977
|
+
* @param {Color} [colorA=(1,1,1,1)]
|
|
978
|
+
* @param {Color} [colorB=(0,0,0,1)]
|
|
979
|
+
* @param {boolean} [linear]
|
|
980
|
+
* @return {Color} */
|
|
981
|
+
randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
982
|
+
/** Returns a new color that has each component randomly adjusted
|
|
983
|
+
* @param {Color} color
|
|
984
|
+
* @param {number} [amount]
|
|
985
|
+
* @param {number} [alphaAmount]
|
|
986
|
+
* @return {Color} */
|
|
987
|
+
mutateColor(color: Color, amount?: number, alphaAmount?: number): Color;
|
|
912
988
|
}
|
|
913
989
|
/**
|
|
914
990
|
* 2D Vector object with vector math library
|
|
@@ -1340,12 +1416,11 @@ declare module "littlejsengine" {
|
|
|
1340
1416
|
*/
|
|
1341
1417
|
frame(frame: number): TileInfo;
|
|
1342
1418
|
/**
|
|
1343
|
-
* Set this tile to use a full image
|
|
1344
|
-
* @param {
|
|
1345
|
-
* @param {WebGLTexture} [glTexture] - WebGL texture
|
|
1419
|
+
* Set this tile to use a full image in a texture info
|
|
1420
|
+
* @param {TextureInfo} textureInfo
|
|
1346
1421
|
* @return {TileInfo}
|
|
1347
1422
|
*/
|
|
1348
|
-
setFullImage(
|
|
1423
|
+
setFullImage(textureInfo: TextureInfo): TileInfo;
|
|
1349
1424
|
}
|
|
1350
1425
|
/**
|
|
1351
1426
|
* Tile Info - Stores info about each texture
|
|
@@ -1355,18 +1430,24 @@ declare module "littlejsengine" {
|
|
|
1355
1430
|
/**
|
|
1356
1431
|
* Create a TextureInfo, called automatically by the engine
|
|
1357
1432
|
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1358
|
-
* @param {
|
|
1433
|
+
* @param {boolean} [useWebGL] - Should use WebGL if available?
|
|
1359
1434
|
*/
|
|
1360
|
-
constructor(image: HTMLImageElement | OffscreenCanvas,
|
|
1361
|
-
/** @property {HTMLImageElement} - image source */
|
|
1435
|
+
constructor(image: HTMLImageElement | OffscreenCanvas, useWebGL?: boolean);
|
|
1436
|
+
/** @property {HTMLImageElement|OffscreenCanvas} - image source */
|
|
1362
1437
|
image: OffscreenCanvas | HTMLImageElement;
|
|
1363
1438
|
/** @property {Vector2} - size of the image */
|
|
1364
1439
|
size: Vector2;
|
|
1365
1440
|
/** @property {Vector2} - inverse of the size, cached for rendering */
|
|
1366
1441
|
sizeInverse: Vector2;
|
|
1367
1442
|
/** @property {WebGLTexture} - WebGL texture */
|
|
1368
|
-
glTexture:
|
|
1443
|
+
glTexture: any;
|
|
1444
|
+
/** Creates the WebGL texture, updates if already created */
|
|
1369
1445
|
createWebGLTexture(): void;
|
|
1446
|
+
/** Destroys the WebGL texture */
|
|
1447
|
+
destroyWebGLTexture(): void;
|
|
1448
|
+
/** Check if the texture is webgl enabled
|
|
1449
|
+
* @return {boolean} */
|
|
1450
|
+
hasWebGL(): boolean;
|
|
1370
1451
|
}
|
|
1371
1452
|
/**
|
|
1372
1453
|
* LittleJS Drawing System
|
|
@@ -1435,6 +1516,16 @@ declare module "littlejsengine" {
|
|
|
1435
1516
|
* @return {Vector2}
|
|
1436
1517
|
* @memberof Draw */
|
|
1437
1518
|
export function worldToScreen(worldPos: Vector2): Vector2;
|
|
1519
|
+
/** Convert from screen to world space coordinates for a directional vector (no translation)
|
|
1520
|
+
* @param {Vector2} screenDelta
|
|
1521
|
+
* @return {Vector2}
|
|
1522
|
+
* @memberof Draw */
|
|
1523
|
+
export function screenToWorldDelta(screenDelta: Vector2): Vector2;
|
|
1524
|
+
/** Convert from screen to world space coordinates for a directional vector (no translation)
|
|
1525
|
+
* @param {Vector2} worldDelta
|
|
1526
|
+
* @return {Vector2}
|
|
1527
|
+
* @memberof Draw */
|
|
1528
|
+
export function worldToScreenDelta(worldDelta: Vector2): Vector2;
|
|
1438
1529
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1439
1530
|
* @param {Vector2} pos - Center of the tile in world space
|
|
1440
1531
|
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
|
|
@@ -1553,10 +1644,11 @@ declare module "littlejsengine" {
|
|
|
1553
1644
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1554
1645
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1555
1646
|
* @param {string} [font=fontDefault]
|
|
1647
|
+
* @param {string} [fontStyle]
|
|
1556
1648
|
* @param {number} [maxWidth]
|
|
1557
1649
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1558
1650
|
* @memberof Draw */
|
|
1559
|
-
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;
|
|
1651
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1560
1652
|
/** Draw text on overlay canvas in world space
|
|
1561
1653
|
* Automatically splits new lines into rows
|
|
1562
1654
|
* @param {string} text
|
|
@@ -1567,9 +1659,10 @@ declare module "littlejsengine" {
|
|
|
1567
1659
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1568
1660
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1569
1661
|
* @param {string} [font=fontDefault]
|
|
1662
|
+
* @param {string} [fontStyle]
|
|
1570
1663
|
* @param {number} [maxWidth]
|
|
1571
1664
|
* @memberof Draw */
|
|
1572
|
-
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number): void;
|
|
1665
|
+
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number): void;
|
|
1573
1666
|
/** Draw text on overlay canvas in screen space
|
|
1574
1667
|
* Automatically splits new lines into rows
|
|
1575
1668
|
* @param {string} text
|
|
@@ -1580,10 +1673,11 @@ declare module "littlejsengine" {
|
|
|
1580
1673
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1581
1674
|
* @param {CanvasTextAlign} [textAlign]
|
|
1582
1675
|
* @param {string} [font=fontDefault]
|
|
1676
|
+
* @param {string} [fontStyle]
|
|
1583
1677
|
* @param {number} [maxWidth]
|
|
1584
1678
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1585
1679
|
* @memberof Draw */
|
|
1586
|
-
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1680
|
+
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1587
1681
|
/** Enable normal or additive blend mode
|
|
1588
1682
|
* @param {boolean} [additive]
|
|
1589
1683
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1609,11 +1703,11 @@ declare module "littlejsengine" {
|
|
|
1609
1703
|
*/
|
|
1610
1704
|
export class FontImage {
|
|
1611
1705
|
/** Create an image font
|
|
1612
|
-
* @param {HTMLImageElement} [image]
|
|
1613
|
-
* @param {Vector2} [tileSize=(8,8)]
|
|
1614
|
-
* @param {Vector2} [paddingSize=(0,1)] - How much
|
|
1706
|
+
* @param {HTMLImageElement} [image] - Image for the font, default if undefined
|
|
1707
|
+
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1708
|
+
* @param {Vector2} [paddingSize=(0,1)] - How much space between characters
|
|
1615
1709
|
*/
|
|
1616
|
-
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2
|
|
1710
|
+
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2);
|
|
1617
1711
|
image: any;
|
|
1618
1712
|
tileSize: Vector2;
|
|
1619
1713
|
paddingSize: Vector2;
|
|
@@ -2154,7 +2248,7 @@ declare module "littlejsengine" {
|
|
|
2154
2248
|
* @param {GainNode} [gainNode] - Optional gain node for volume control while playing
|
|
2155
2249
|
* @param {number} [offset] - Offset in seconds to start playback from
|
|
2156
2250
|
* @param {AudioEndedCallback} [onended] - Callback for when the sound ends
|
|
2157
|
-
* @return {AudioBufferSourceNode} - The
|
|
2251
|
+
* @return {AudioBufferSourceNode} - The source node of the sound played, may be undefined if play fails
|
|
2158
2252
|
* @memberof Audio */
|
|
2159
2253
|
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode, offset?: number, onended?: AudioEndedCallback): AudioBufferSourceNode;
|
|
2160
2254
|
/** Generate and play a ZzFX sound
|
|
@@ -2315,6 +2409,14 @@ declare module "littlejsengine" {
|
|
|
2315
2409
|
* @return {boolean} - true if the collision should be resolved
|
|
2316
2410
|
*/
|
|
2317
2411
|
collideWithObject(object: EngineObject): boolean;
|
|
2412
|
+
/** Get this object's up vector
|
|
2413
|
+
* @param {number} [scale] - length of the vector
|
|
2414
|
+
* @return {Vector2} */
|
|
2415
|
+
getUp(scale?: number): Vector2;
|
|
2416
|
+
/** Get this object's right vector
|
|
2417
|
+
* @param {number} [scale] - length of the vector
|
|
2418
|
+
* @return {Vector2} */
|
|
2419
|
+
getRight(scale?: number): Vector2;
|
|
2318
2420
|
/** How long since the object was created
|
|
2319
2421
|
* @return {number} */
|
|
2320
2422
|
getAliveTime(): number;
|
|
@@ -2375,15 +2477,15 @@ declare module "littlejsengine" {
|
|
|
2375
2477
|
* @return {TileCollisionLayer}
|
|
2376
2478
|
* @memberof TileLayers */
|
|
2377
2479
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
|
|
2378
|
-
/** Return the
|
|
2379
|
-
* This does not return the exact intersection, but the center of the tile hit.
|
|
2480
|
+
/** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
|
|
2380
2481
|
* @param {Vector2} posStart
|
|
2381
2482
|
* @param {Vector2} posEnd
|
|
2382
2483
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2484
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2383
2485
|
* @param {boolean} [solidOnly=true] - Only check solid layers if true
|
|
2384
|
-
* @return {Vector2}
|
|
2486
|
+
* @return {Vector2|undefined} - position of the center of the tile hit or undefined if no hit
|
|
2385
2487
|
* @memberof TileLayers */
|
|
2386
|
-
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, solidOnly?: boolean): Vector2;
|
|
2488
|
+
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
|
|
2387
2489
|
/**
|
|
2388
2490
|
* Load tile layers from exported data
|
|
2389
2491
|
* @param {Object} tileMapData - Level data from exported data
|
|
@@ -2445,8 +2547,9 @@ declare module "littlejsengine" {
|
|
|
2445
2547
|
canvas: OffscreenCanvas;
|
|
2446
2548
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2447
2549
|
context: OffscreenCanvasRenderingContext2D;
|
|
2448
|
-
|
|
2449
|
-
|
|
2550
|
+
textureInfo: TextureInfo;
|
|
2551
|
+
/** @property {boolean} - True if WebGL texture needs to be refreshed */
|
|
2552
|
+
refreshWebGL: boolean;
|
|
2450
2553
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2451
2554
|
* @param {Vector2} pos - Center in world space
|
|
2452
2555
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2485,8 +2588,10 @@ declare module "littlejsengine" {
|
|
|
2485
2588
|
* @param {number} [angle=0] */
|
|
2486
2589
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2487
2590
|
/** Create or update the WebGL texture for this layer
|
|
2488
|
-
* @param {boolean} [enable] - enable WebGL rendering and update the texture
|
|
2489
|
-
|
|
2591
|
+
* @param {boolean} [enable] - enable WebGL rendering and update the texture
|
|
2592
|
+
* @param {boolean} [immediate] - shoulkd the texture be updated immediately
|
|
2593
|
+
*/
|
|
2594
|
+
useWebGL(enable?: boolean, immediate?: boolean): void;
|
|
2490
2595
|
}
|
|
2491
2596
|
/**
|
|
2492
2597
|
* Tile Layer - cached rendering system for tile layers
|
|
@@ -2506,9 +2611,8 @@ declare module "littlejsengine" {
|
|
|
2506
2611
|
* @param {Vector2} size - World space size
|
|
2507
2612
|
* @param {TileInfo} [tileInfo] - Default tile info for layer (used for size and texture)
|
|
2508
2613
|
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2509
|
-
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
2510
2614
|
*/
|
|
2511
|
-
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number
|
|
2615
|
+
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number);
|
|
2512
2616
|
data: TileLayerData[];
|
|
2513
2617
|
/** Draw all the tile data to an offscreen canvas
|
|
2514
2618
|
* - This may be slow in some browsers but only needs to be done once */
|
|
@@ -2566,13 +2670,13 @@ declare module "littlejsengine" {
|
|
|
2566
2670
|
* @param {EngineObject} [object]
|
|
2567
2671
|
* @return {boolean} */
|
|
2568
2672
|
collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
2569
|
-
/** Return the
|
|
2570
|
-
* This does not return the exact intersection, but the center of the tile hit.
|
|
2673
|
+
/** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
|
|
2571
2674
|
* @param {Vector2} posStart
|
|
2572
2675
|
* @param {Vector2} posEnd
|
|
2573
|
-
* @param {EngineObject} [object]
|
|
2574
|
-
* @
|
|
2575
|
-
|
|
2676
|
+
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2677
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2678
|
+
* @return {Vector2|undefined} */
|
|
2679
|
+
collisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, normal?: Vector2): Vector2 | undefined;
|
|
2576
2680
|
}
|
|
2577
2681
|
/**
|
|
2578
2682
|
* LittleJS Particle System
|
|
@@ -2595,7 +2699,7 @@ declare module "littlejsengine" {
|
|
|
2595
2699
|
* tile(0, 16), // tileInfo
|
|
2596
2700
|
* rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
|
|
2597
2701
|
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
2598
|
-
*
|
|
2702
|
+
* 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
2599
2703
|
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
2600
2704
|
* .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
2601
2705
|
* );
|
|
@@ -2677,6 +2781,10 @@ declare module "littlejsengine" {
|
|
|
2677
2781
|
particleCreateCallback: any;
|
|
2678
2782
|
/** @property {number} - Track particle emit time */
|
|
2679
2783
|
emitTimeBuffer: number;
|
|
2784
|
+
/** @property {number} - Percentage of velocity to pass to particles (0-1) */
|
|
2785
|
+
velocityInheritance: number;
|
|
2786
|
+
previousAngle: number;
|
|
2787
|
+
previousPos: Vector2;
|
|
2680
2788
|
/** Spawn one particle
|
|
2681
2789
|
* @return {Particle} */
|
|
2682
2790
|
emitParticle(): Particle;
|
|
@@ -2881,17 +2989,16 @@ declare module "littlejsengine" {
|
|
|
2881
2989
|
/** Create global post processing shader
|
|
2882
2990
|
* @param {string} shaderCode
|
|
2883
2991
|
* @param {boolean} [includeOverlay]
|
|
2992
|
+
* @param {boolean} [includeMainCanvas]
|
|
2884
2993
|
* @example
|
|
2885
2994
|
* // create the post process plugin object
|
|
2886
2995
|
* new PostProcessPlugin(shaderCode);
|
|
2887
2996
|
*/
|
|
2888
|
-
constructor(shaderCode: string, includeOverlay?: boolean);
|
|
2997
|
+
constructor(shaderCode: string, includeOverlay?: boolean, includeMainCanvas?: boolean);
|
|
2889
2998
|
/** @property {WebGLProgram} - Shader for post processing */
|
|
2890
|
-
shader:
|
|
2999
|
+
shader: any;
|
|
2891
3000
|
/** @property {WebGLTexture} - Texture for post processing */
|
|
2892
|
-
texture:
|
|
2893
|
-
/** @property {boolean} - Should overlay canvas be included in post processing */
|
|
2894
|
-
includeOverlay: boolean;
|
|
3001
|
+
texture: any;
|
|
2895
3002
|
}
|
|
2896
3003
|
/**
|
|
2897
3004
|
* LittleJS ZzFXM Plugin
|
|
@@ -2980,6 +3087,8 @@ declare module "littlejsengine" {
|
|
|
2980
3087
|
defaultHoverColor: Color;
|
|
2981
3088
|
/** @property {Color} - Default color for disabled UI elements */
|
|
2982
3089
|
defaultDisabledColor: Color;
|
|
3090
|
+
/** @property {Color} - Uses a gradient fill combined with color */
|
|
3091
|
+
defaultGradientColor: any;
|
|
2983
3092
|
/** @property {number} - Default line width for UI elements */
|
|
2984
3093
|
defaultLineWidth: number;
|
|
2985
3094
|
/** @property {number} - Default rounded rect corner radius for UI elements */
|
|
@@ -3004,14 +3113,17 @@ declare module "littlejsengine" {
|
|
|
3004
3113
|
hoverObject: any;
|
|
3005
3114
|
/** @property {UIObject} - Hover object at start of update */
|
|
3006
3115
|
lastHoverObject: any;
|
|
3116
|
+
/** @property {number} - If set ui coords will be renormalized to this canvas height */
|
|
3117
|
+
nativeHeight: number;
|
|
3007
3118
|
/** Draw a rectangle to the UI context
|
|
3008
3119
|
* @param {Vector2} pos
|
|
3009
3120
|
* @param {Vector2} size
|
|
3010
3121
|
* @param {Color} [color=uiSystem.defaultColor]
|
|
3011
3122
|
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
3012
3123
|
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
3013
|
-
* @param {number} [cornerRadius=uiSystem.defaultCornerRadius]
|
|
3014
|
-
|
|
3124
|
+
* @param {number} [cornerRadius=uiSystem.defaultCornerRadius]
|
|
3125
|
+
* @param {Color} [gradientColor=uiSystem.defaultGradientColor] */
|
|
3126
|
+
drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, cornerRadius?: number, gradientColor?: Color): void;
|
|
3015
3127
|
/** Draw a line to the UI context
|
|
3016
3128
|
* @param {Vector2} posA
|
|
3017
3129
|
* @param {Vector2} posB
|
|
@@ -3035,8 +3147,9 @@ declare module "littlejsengine" {
|
|
|
3035
3147
|
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
3036
3148
|
* @param {string} [align]
|
|
3037
3149
|
* @param {string} [font=uiSystem.defaultFont]
|
|
3150
|
+
* @param {string} [fontStyle]
|
|
3038
3151
|
* @param {boolean} [applyMaxWidth=true] */
|
|
3039
|
-
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, applyMaxWidth?: boolean): void;
|
|
3152
|
+
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean): void;
|
|
3040
3153
|
/**
|
|
3041
3154
|
* @callback DragAndDropCallback - Callback for drag and drop events
|
|
3042
3155
|
* @param {DragEvent} event - The drag event
|
|
@@ -3081,12 +3194,16 @@ declare module "littlejsengine" {
|
|
|
3081
3194
|
hoverColor: Color;
|
|
3082
3195
|
/** @property {Color} - Color for line drawing */
|
|
3083
3196
|
lineColor: Color;
|
|
3197
|
+
/** @property {Color} - Uses a gradient fill combined with color */
|
|
3198
|
+
gradientColor: any;
|
|
3084
3199
|
/** @property {number} - Width for line drawing */
|
|
3085
3200
|
lineWidth: number;
|
|
3086
3201
|
/** @property {number} - Corner radius for rounded rects */
|
|
3087
3202
|
cornerRadius: number;
|
|
3088
3203
|
/** @property {string} - Font for this objecct */
|
|
3089
3204
|
font: string;
|
|
3205
|
+
/** @property {string} - Font style for this object or undefined */
|
|
3206
|
+
fontStyle: any;
|
|
3090
3207
|
/** @property {number} - Override for text width */
|
|
3091
3208
|
textWidth: any;
|
|
3092
3209
|
/** @property {number} - Override for text height */
|
|
@@ -3111,6 +3228,8 @@ declare module "littlejsengine" {
|
|
|
3111
3228
|
interactive: boolean;
|
|
3112
3229
|
/** @property {boolean} - Activate when dragged over with mouse held down */
|
|
3113
3230
|
dragActivate: boolean;
|
|
3231
|
+
/** @property {boolean} - True if this can be a hover object */
|
|
3232
|
+
canBeHover: boolean;
|
|
3114
3233
|
/** Add a child UIObject to this object
|
|
3115
3234
|
* @param {UIObject} child
|
|
3116
3235
|
*/
|
|
@@ -3119,6 +3238,10 @@ declare module "littlejsengine" {
|
|
|
3119
3238
|
* @param {UIObject} child
|
|
3120
3239
|
*/
|
|
3121
3240
|
removeChild(child: UIObject): void;
|
|
3241
|
+
/** Check if the mouse is overlapping a box in screen space
|
|
3242
|
+
* @return {boolean} - True if overlapping
|
|
3243
|
+
*/
|
|
3244
|
+
isMouseOverlapping(): boolean;
|
|
3122
3245
|
/** Update the object, called automatically by plugin once each frame */
|
|
3123
3246
|
update(): void;
|
|
3124
3247
|
/** Render the object, called automatically by plugin once each frame */
|