littlejsengine 1.18.8 → 1.18.15
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/FAQ.md +197 -15
- package/README.md +30 -11
- package/dist/littlejs.d.ts +166 -74
- package/dist/littlejs.esm.js +610 -234
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +597 -229
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +590 -220
- package/package.json +4 -1
- package/plugins/box2d.js +17 -6
- package/plugins/medalSystem.js +2 -1
- package/plugins/newgrounds.js +22 -3
- package/plugins/pathFinder.js +40 -9
- package/plugins/pluginExport.js +4 -3
- package/plugins/postProcess.js +8 -1
- package/plugins/tweenSystem.js +33 -20
- package/plugins/uiSystem.js +21 -3
- package/src/engine.js +16 -4
- package/src/engineAudio.js +30 -15
- package/src/engineBuild.mjs +1 -1
- package/src/engineDebug.js +7 -9
- package/src/engineDraw.js +144 -33
- package/src/engineExport.js +9 -2
- package/src/engineInput.js +17 -12
- package/src/engineLogo.js +1 -1
- package/src/engineMath.js +21 -7
- package/src/engineObject.js +19 -11
- package/src/engineParticles.js +26 -27
- package/src/engineSettings.js +3 -2
- package/src/engineTileLayer.js +62 -43
- package/src/engineUtilities.js +67 -11
- package/src/engineWebGL.js +37 -7
package/dist/littlejs.d.ts
CHANGED
|
@@ -291,7 +291,7 @@ declare module "littlejsengine" {
|
|
|
291
291
|
* @param {boolean} [screenSpace]
|
|
292
292
|
* @memberof Debug */
|
|
293
293
|
export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: Color | string, time?: number, screenSpace?: boolean): void;
|
|
294
|
-
/** Draw
|
|
294
|
+
/** Draw debug text in world space
|
|
295
295
|
* @param {string|number} text
|
|
296
296
|
* @param {Vector2} pos
|
|
297
297
|
* @param {number} [size]
|
|
@@ -358,7 +358,7 @@ declare module "littlejsengine" {
|
|
|
358
358
|
export let canvasColorTiles: boolean;
|
|
359
359
|
/** Color to clear the canvas to before render, does not clear if alpha is 0
|
|
360
360
|
* @type {Color}
|
|
361
|
-
* @memberof
|
|
361
|
+
* @memberof Settings */
|
|
362
362
|
export let canvasClearColor: Color;
|
|
363
363
|
/** The max size of the canvas, centered if window is larger
|
|
364
364
|
* @type {Vector2}
|
|
@@ -516,7 +516,8 @@ declare module "littlejsengine" {
|
|
|
516
516
|
* @memberof Settings */
|
|
517
517
|
export let touchGamepadEnable: boolean;
|
|
518
518
|
/** True if touch gamepad should have start button in the center
|
|
519
|
-
* - Prevents activating
|
|
519
|
+
* - Prevents activating within 2*touchGamepadSize of the virtual stick or face buttons
|
|
520
|
+
* (one radius for the visible control + one radius of buffer beyond its edge)
|
|
520
521
|
* - When the game is paused, any touch will press the button
|
|
521
522
|
* - Set size to enable the center button
|
|
522
523
|
* @type {number}
|
|
@@ -739,6 +740,10 @@ declare module "littlejsengine" {
|
|
|
739
740
|
* @param {number} alpha
|
|
740
741
|
* @memberof Settings */
|
|
741
742
|
export function setTouchGamepadAlpha(alpha: number): void;
|
|
743
|
+
/** Set how long to display the touch gamepad on screen in seconds, set to 0 to always display
|
|
744
|
+
* @param {number} time
|
|
745
|
+
* @memberof Settings */
|
|
746
|
+
export function setTouchGamepadDisplayTime(time: number): void;
|
|
742
747
|
/** Set to allow vibration hardware if it exists
|
|
743
748
|
* @param {boolean} enable
|
|
744
749
|
* @memberof Settings */
|
|
@@ -821,17 +826,17 @@ declare module "littlejsengine" {
|
|
|
821
826
|
* @param {number} x
|
|
822
827
|
* @return {number}
|
|
823
828
|
* @memberof Math */
|
|
824
|
-
export
|
|
829
|
+
export function sign(x: number): number;
|
|
825
830
|
/** Returns hypotenuse of values passed in
|
|
826
831
|
* @param {...number} values
|
|
827
832
|
* @return {number}
|
|
828
833
|
* @memberof Math */
|
|
829
|
-
export
|
|
834
|
+
export function hypot(...values: number[]): number;
|
|
830
835
|
/** Returns log2 of value passed in
|
|
831
836
|
* @param {number} x
|
|
832
837
|
* @return {number}
|
|
833
838
|
* @memberof Math */
|
|
834
|
-
export
|
|
839
|
+
export function log2(x: number): number;
|
|
835
840
|
/** Returns sin of value passed in
|
|
836
841
|
* @param {number} x
|
|
837
842
|
* @return {number}
|
|
@@ -1018,6 +1023,19 @@ declare module "littlejsengine" {
|
|
|
1018
1023
|
* @param {Object} saveData - object containing data to be saved
|
|
1019
1024
|
* @memberof Utilities */
|
|
1020
1025
|
export function writeSaveData(saveName: string, saveData: any): void;
|
|
1026
|
+
/** 1D gradient noise — returns a smooth value in [0, 1] for any real x.
|
|
1027
|
+
* Integer inputs land on deterministic lattice values; non-integer inputs
|
|
1028
|
+
* are interpolated with smoothStep for C1 continuity.
|
|
1029
|
+
* @param {number} x
|
|
1030
|
+
* @return {number}
|
|
1031
|
+
* @memberof Utilities */
|
|
1032
|
+
export function noise1D(x: number): number;
|
|
1033
|
+
/** 2D gradient noise — returns a smooth value in [0, 1] for any real (x, y).
|
|
1034
|
+
* @param {number} x
|
|
1035
|
+
* @param {number} y
|
|
1036
|
+
* @return {number}
|
|
1037
|
+
* @memberof Utilities */
|
|
1038
|
+
export function noise2D(x: number, y: number): number;
|
|
1021
1039
|
/** Random global functions
|
|
1022
1040
|
* @namespace Random */
|
|
1023
1041
|
/** Returns a random value between the two values passed in
|
|
@@ -1368,6 +1386,7 @@ declare module "littlejsengine" {
|
|
|
1368
1386
|
* - File saving (text, canvas, data URLs)
|
|
1369
1387
|
* - Native share dialog support
|
|
1370
1388
|
* - Local storage save data management
|
|
1389
|
+
* - Gradient noise (1D and 2D)
|
|
1371
1390
|
* @namespace Utilities
|
|
1372
1391
|
*/
|
|
1373
1392
|
/**
|
|
@@ -1408,7 +1427,8 @@ declare module "littlejsengine" {
|
|
|
1408
1427
|
/** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
|
|
1409
1428
|
* @return {number} */
|
|
1410
1429
|
get(): number;
|
|
1411
|
-
/** Get percentage elapsed based on time it was set to, returns 0 if not set
|
|
1430
|
+
/** Get percentage elapsed based on time it was set to, returns 0 if not set.
|
|
1431
|
+
* Zero-duration timers report 1 (already elapsed).
|
|
1412
1432
|
* @return {number} */
|
|
1413
1433
|
getPercent(): number;
|
|
1414
1434
|
/** Get the time this timer was set to, returns 0 if not set
|
|
@@ -1485,9 +1505,9 @@ declare module "littlejsengine" {
|
|
|
1485
1505
|
/**
|
|
1486
1506
|
* Check if object is an array
|
|
1487
1507
|
* @param {any} a
|
|
1488
|
-
* @return {
|
|
1508
|
+
* @return {a is Array<any>}
|
|
1489
1509
|
* @memberof Math */
|
|
1490
|
-
export function isArray(a: any):
|
|
1510
|
+
export function isArray(a: any): a is any[];
|
|
1491
1511
|
/** Color - White #ffffff
|
|
1492
1512
|
* @type {Color}
|
|
1493
1513
|
* @memberof Math */
|
|
@@ -1566,8 +1586,8 @@ declare module "littlejsengine" {
|
|
|
1566
1586
|
* @param {Vector2} [pos=vec2()] - Top left corner of tile in pixels
|
|
1567
1587
|
* @param {Vector2} [size] - Size of tile in pixels
|
|
1568
1588
|
* @param {TextureInfo} [textureInfo] - Texture info to use
|
|
1569
|
-
* @param {number} [padding] - How many pixels padding around
|
|
1570
|
-
* @param {number} [bleed] - How many pixels smaller to
|
|
1589
|
+
* @param {number} [padding] - How many pixels padding around all sides of each tile (increases grid size, does not affect tile size)
|
|
1590
|
+
* @param {number} [bleed] - How many pixels smaller to shrink UVS of tiles (does not affect grid size, only UVs)
|
|
1571
1591
|
*/
|
|
1572
1592
|
constructor(pos?: Vector2, size?: Vector2, textureInfo?: TextureInfo, padding?: number, bleed?: number);
|
|
1573
1593
|
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
@@ -1642,7 +1662,7 @@ declare module "littlejsengine" {
|
|
|
1642
1662
|
* - Optimized tile sheet sprite rendering using WebGL batching
|
|
1643
1663
|
* - Primitive drawing for polygons, ellipses, and lines
|
|
1644
1664
|
* - Tile-based rendering with TileInfo and TextureInfo classes
|
|
1645
|
-
* - Text rendering with custom fonts and
|
|
1665
|
+
* - Text rendering with custom fonts and ImageFont support
|
|
1646
1666
|
* - Color and additive color blending for effects
|
|
1647
1667
|
* - Rotation, mirroring, and scaling transformations
|
|
1648
1668
|
* - Camera system with position, scale, and rotation
|
|
@@ -1697,6 +1717,11 @@ declare module "littlejsengine" {
|
|
|
1697
1717
|
* @type {number}
|
|
1698
1718
|
* @memberof Draw */
|
|
1699
1719
|
export let drawCount: number;
|
|
1720
|
+
/** Keeps track of how many primitives were drawn each frame for debugging
|
|
1721
|
+
* A single draw call can render many primitives (e.g. a WebGL sprite batch).
|
|
1722
|
+
* @type {number}
|
|
1723
|
+
* @memberof Draw */
|
|
1724
|
+
export let primitiveCount: number;
|
|
1700
1725
|
/** Convert from screen to world space coordinates
|
|
1701
1726
|
* @param {Vector2} screenPos
|
|
1702
1727
|
* @return {Vector2}
|
|
@@ -1751,7 +1776,7 @@ declare module "littlejsengine" {
|
|
|
1751
1776
|
* @param {Vector2} pos
|
|
1752
1777
|
* @param {Vector2} [size=vec2(1)]
|
|
1753
1778
|
* @param {Color} [colorTop=WHITE]
|
|
1754
|
-
* @param {Color} [colorBottom=
|
|
1779
|
+
* @param {Color} [colorBottom=CLEAR_WHITE]
|
|
1755
1780
|
* @param {number} [angle]
|
|
1756
1781
|
* @param {boolean} [useWebGL=glEnable]
|
|
1757
1782
|
* @param {boolean} [screenSpace]
|
|
@@ -1814,9 +1839,9 @@ declare module "littlejsengine" {
|
|
|
1814
1839
|
* @param {Vector2} [size=vec2(1)]
|
|
1815
1840
|
* @param {number} [sides]
|
|
1816
1841
|
* @param {Color} [color=WHITE]
|
|
1817
|
-
* @param {number} [angle]
|
|
1818
1842
|
* @param {number} [lineWidth]
|
|
1819
1843
|
* @param {Color} [lineColor=BLACK]
|
|
1844
|
+
* @param {number} [angle]
|
|
1820
1845
|
* @param {boolean} [useWebGL=glEnable]
|
|
1821
1846
|
* @param {boolean} [screenSpace]
|
|
1822
1847
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1845,6 +1870,20 @@ declare module "littlejsengine" {
|
|
|
1845
1870
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1846
1871
|
* @memberof Draw */
|
|
1847
1872
|
export function drawCircle(pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1873
|
+
export function drawEllipseGradient(pos: any, size: Vector2, colorInner: Color, colorOuter: Color, angle: number, useWebGL: boolean, screenSpace: boolean, context: any): void;
|
|
1874
|
+
/** Draw a circle filled with a radial gradient from the center to the rim
|
|
1875
|
+
* - Best when batched with other untextured polys
|
|
1876
|
+
* - If drawing mostly textured sprites, bake the gradient into a texture and use drawTile instead
|
|
1877
|
+
* - Stacking gradients at the exact same position may show a faint vertical artifact
|
|
1878
|
+
* @param {Vector2} pos
|
|
1879
|
+
* @param {number} [size=1] - Diameter
|
|
1880
|
+
* @param {Color} [colorInner=WHITE]
|
|
1881
|
+
* @param {Color} [colorOuter=CLEAR_WHITE]
|
|
1882
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1883
|
+
* @param {boolean} [screenSpace]
|
|
1884
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1885
|
+
* @memberof Draw */
|
|
1886
|
+
export function drawCircleGradient(pos: Vector2, size?: number, colorInner?: Color, colorOuter?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1848
1887
|
/**
|
|
1849
1888
|
* @callback Canvas2DDrawFunction - A function that draws to a 2D canvas context
|
|
1850
1889
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
@@ -1902,11 +1941,11 @@ declare module "littlejsengine" {
|
|
|
1902
1941
|
* @memberof Draw */
|
|
1903
1942
|
export function combineCanvases(): void;
|
|
1904
1943
|
/** Engine font image, 8x8 font provided by the engine
|
|
1905
|
-
* @type {
|
|
1944
|
+
* @type {ImageFont}
|
|
1906
1945
|
* @memberof Draw */
|
|
1907
|
-
export let
|
|
1946
|
+
export let engineImageFont: ImageFont;
|
|
1908
1947
|
/**
|
|
1909
|
-
* Font
|
|
1948
|
+
* Image Font Object - Draw text by using tiles in an image
|
|
1910
1949
|
* - 96 characters (from space to tilde) are stored in an image
|
|
1911
1950
|
* - A 8x8 default engine font is supplied for general use
|
|
1912
1951
|
* - This system is WebGL enabled for fast text rendering
|
|
@@ -1915,12 +1954,12 @@ declare module "littlejsengine" {
|
|
|
1915
1954
|
* @memberof Draw
|
|
1916
1955
|
* @example
|
|
1917
1956
|
* // use built in font
|
|
1918
|
-
* const font =
|
|
1957
|
+
* const font = engineImageFont;
|
|
1919
1958
|
*
|
|
1920
1959
|
* // draw text
|
|
1921
1960
|
* font.drawTextScreen('LittleJS\nHello World!', vec2(200, 50));
|
|
1922
1961
|
*/
|
|
1923
|
-
export class
|
|
1962
|
+
export class ImageFont {
|
|
1924
1963
|
/** Create an image font
|
|
1925
1964
|
* @param {TileInfo} tileInfo - Tile info of first character in font
|
|
1926
1965
|
*/
|
|
@@ -2066,6 +2105,18 @@ declare module "littlejsengine" {
|
|
|
2066
2105
|
* @param {number} [rgbaAdditive=0] - black is 0
|
|
2067
2106
|
* @memberof WebGL */
|
|
2068
2107
|
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;
|
|
2108
|
+
/** Add an untextured rect to the gl draw list
|
|
2109
|
+
* Zeroes the uvs and rgba so the texture contribution multiplies to 0,
|
|
2110
|
+
* then carries the real color in the additive slot. Works regardless of
|
|
2111
|
+
* which texture is currently bound.
|
|
2112
|
+
* @param {number} x
|
|
2113
|
+
* @param {number} y
|
|
2114
|
+
* @param {number} sizeX
|
|
2115
|
+
* @param {number} sizeY
|
|
2116
|
+
* @param {number} angle
|
|
2117
|
+
* @param {number} rgba - color as 32-bit integer
|
|
2118
|
+
* @memberof WebGL */
|
|
2119
|
+
export function glDrawUntextured(x: number, y: number, sizeX: number, sizeY: number, angle: number, rgba: number): void;
|
|
2069
2120
|
/** Transform and add a polygon to the gl draw list
|
|
2070
2121
|
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
2071
2122
|
* @param {number} rgba - Color of the polygon as a 32-bit integer
|
|
@@ -2392,7 +2443,7 @@ declare module "littlejsengine" {
|
|
|
2392
2443
|
*/
|
|
2393
2444
|
playNote(semitoneOffset?: number, pos?: Vector2, volume?: number): SoundInstance;
|
|
2394
2445
|
/** Get how long this sound is in seconds
|
|
2395
|
-
* @return {number} - How long the sound is in seconds (
|
|
2446
|
+
* @return {number} - How long the sound is in seconds (0 if loading)
|
|
2396
2447
|
*/
|
|
2397
2448
|
getDuration(): number;
|
|
2398
2449
|
/** Check if sound is loaded, for sounds fetched from a url
|
|
@@ -2473,7 +2524,7 @@ declare module "littlejsengine" {
|
|
|
2473
2524
|
*/
|
|
2474
2525
|
getCurrentTime(): number;
|
|
2475
2526
|
/** Get the total duration of this sound
|
|
2476
|
-
* @return {number} - Total duration in seconds
|
|
2527
|
+
* @return {number} - Total duration in seconds (0 if loading)
|
|
2477
2528
|
*/
|
|
2478
2529
|
getDuration(): number;
|
|
2479
2530
|
/** Get source of this sound instance
|
|
@@ -2483,13 +2534,13 @@ declare module "littlejsengine" {
|
|
|
2483
2534
|
}
|
|
2484
2535
|
/** Speak text with passed in settings
|
|
2485
2536
|
* @param {string} text - The text to speak
|
|
2486
|
-
* @param {string} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
2487
2537
|
* @param {number} [volume] - How much to scale volume by
|
|
2488
2538
|
* @param {number} [rate] - How quickly to speak
|
|
2489
2539
|
* @param {number} [pitch] - How much to change the pitch by
|
|
2540
|
+
* @param {string} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
2490
2541
|
* @return {SpeechSynthesisUtterance} - The utterance that was spoken
|
|
2491
2542
|
* @memberof Audio */
|
|
2492
|
-
export function speak(text: string,
|
|
2543
|
+
export function speak(text: string, volume?: number, rate?: number, pitch?: number, language?: string): SpeechSynthesisUtterance;
|
|
2493
2544
|
/** Stop all queued speech
|
|
2494
2545
|
* @memberof Audio */
|
|
2495
2546
|
export function speakStop(): void;
|
|
@@ -2609,7 +2660,7 @@ declare module "littlejsengine" {
|
|
|
2609
2660
|
color: Color;
|
|
2610
2661
|
/** @property {Color} - Additive color to apply when rendered */
|
|
2611
2662
|
additiveColor: any;
|
|
2612
|
-
/** @property {boolean} - Should
|
|
2663
|
+
/** @property {boolean} - Should the rendered tile flip along the y axis. Affects rendering and the local→world transform of attached children (a mirrored parent flips its children's localPos.x and localAngle). Does not affect this object's own physics, collision, or localToWorld/worldToLocal. */
|
|
2613
2664
|
mirror: boolean;
|
|
2614
2665
|
/** @property {boolean} - Has object been destroyed? */
|
|
2615
2666
|
destroyed: boolean;
|
|
@@ -2866,20 +2917,6 @@ declare module "littlejsengine" {
|
|
|
2866
2917
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2867
2918
|
* @memberof Draw */
|
|
2868
2919
|
draw(pos: Vector2, size?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2869
|
-
/** Draw a tile onto the layer canvas in world space
|
|
2870
|
-
* @param {Vector2} pos
|
|
2871
|
-
* @param {Vector2} [size=vec2(1)]
|
|
2872
|
-
* @param {TileInfo} [tileInfo]
|
|
2873
|
-
* @param {Color} [color=WHITE]
|
|
2874
|
-
* @param {number} [angle]
|
|
2875
|
-
* @param {boolean} [mirror] */
|
|
2876
|
-
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2877
|
-
/** Draw a rectangle onto the layer canvas in world space
|
|
2878
|
-
* @param {Vector2} pos
|
|
2879
|
-
* @param {Vector2} [size=vec2(1)]
|
|
2880
|
-
* @param {Color} [color=WHITE]
|
|
2881
|
-
* @param {number} [angle] */
|
|
2882
|
-
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2883
2920
|
/** Create WebGL texture if necessary and copy layer canvas to it */
|
|
2884
2921
|
updateWebGL(): void;
|
|
2885
2922
|
/** Check if this layer is using WebGL
|
|
@@ -2950,6 +2987,20 @@ declare module "littlejsengine" {
|
|
|
2950
2987
|
* @param {number} [angle] - Angle to rotate by
|
|
2951
2988
|
*/
|
|
2952
2989
|
drawLayerRect(pos: Vector2, size: Vector2, color?: Color, angle?: number): void;
|
|
2990
|
+
/** Draw a tile onto the layer canvas in world space
|
|
2991
|
+
* @param {Vector2} pos
|
|
2992
|
+
* @param {Vector2} [size=vec2(1)]
|
|
2993
|
+
* @param {TileInfo} [tileInfo]
|
|
2994
|
+
* @param {Color} [color=WHITE]
|
|
2995
|
+
* @param {number} [angle]
|
|
2996
|
+
* @param {boolean} [mirror] */
|
|
2997
|
+
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2998
|
+
/** Draw a rectangle onto the layer canvas in world space
|
|
2999
|
+
* @param {Vector2} pos
|
|
3000
|
+
* @param {Vector2} [size=vec2(1)]
|
|
3001
|
+
* @param {Color} [color=WHITE]
|
|
3002
|
+
* @param {number} [angle] */
|
|
3003
|
+
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2953
3004
|
/** Clear a rectangle in layer space
|
|
2954
3005
|
* @param {Vector2} pos - position in pixel coordinates
|
|
2955
3006
|
* @param {Vector2} size
|
|
@@ -2966,8 +3017,8 @@ declare module "littlejsengine" {
|
|
|
2966
3017
|
clearData(layerPos: Vector2, redraw?: boolean): void;
|
|
2967
3018
|
/** Get data at a given position in the array
|
|
2968
3019
|
* @param {Vector2} layerPos - Local position in array
|
|
2969
|
-
* @return {TileLayerData} */
|
|
2970
|
-
getData(layerPos: Vector2): TileLayerData;
|
|
3020
|
+
* @return {TileLayerData|undefined} */
|
|
3021
|
+
getData(layerPos: Vector2): TileLayerData | undefined;
|
|
2971
3022
|
/** Called after this layer is redrawn, does nothing by default */
|
|
2972
3023
|
onRedraw(): void;
|
|
2973
3024
|
/** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color]} */
|
|
@@ -3076,7 +3127,7 @@ declare module "littlejsengine" {
|
|
|
3076
3127
|
* @param {number} [angleDamping] - How much to dampen particle angular speed
|
|
3077
3128
|
* @param {number} [gravityScale] - How much gravity effect particles
|
|
3078
3129
|
* @param {number} [particleConeAngle] - Cone for start particle angle
|
|
3079
|
-
* @param {number} [fadeRate] -
|
|
3130
|
+
* @param {number} [fadeRate] - Fraction of life spent fading: half at fade-in (start), half at fade-out (end). e.g. .2 = 10% fade-in, 80% full opacity, 10% fade-out
|
|
3080
3131
|
* @param {number} [randomness] - Apply extra randomness percent
|
|
3081
3132
|
* @param {boolean} [collideTiles] - Do particles collide against tiles
|
|
3082
3133
|
* @param {boolean} [additive] - Should particles use additive blend
|
|
@@ -3117,7 +3168,7 @@ declare module "littlejsengine" {
|
|
|
3117
3168
|
angleSpeed: number;
|
|
3118
3169
|
/** @property {number} - Cone for start particle angle */
|
|
3119
3170
|
particleConeAngle: number;
|
|
3120
|
-
/** @property {number} -
|
|
3171
|
+
/** @property {number} - Fraction of life spent fading, split half at start and half at end (e.g. .2 = 10% fade-in + 10% fade-out) */
|
|
3121
3172
|
fadeRate: number;
|
|
3122
3173
|
/** @property {number} - Apply extra randomness percent */
|
|
3123
3174
|
randomness: number;
|
|
@@ -3217,6 +3268,21 @@ declare module "littlejsengine" {
|
|
|
3217
3268
|
* @default
|
|
3218
3269
|
* @memberof Settings */
|
|
3219
3270
|
export let medalsPreventUnlock: boolean;
|
|
3271
|
+
/** How long to show medals for in seconds
|
|
3272
|
+
* @type {number}
|
|
3273
|
+
* @default
|
|
3274
|
+
* @memberof Settings */
|
|
3275
|
+
export let medalDisplayTime: number;
|
|
3276
|
+
/** How quickly to slide on/off medals in seconds
|
|
3277
|
+
* @type {number}
|
|
3278
|
+
* @default
|
|
3279
|
+
* @memberof Settings */
|
|
3280
|
+
export let medalDisplaySlideTime: number;
|
|
3281
|
+
/** Size of medal display
|
|
3282
|
+
* @type {Vector2}
|
|
3283
|
+
* @default Vector2(640,80)
|
|
3284
|
+
* @memberof Settings */
|
|
3285
|
+
export let medalDisplaySize: Vector2;
|
|
3220
3286
|
/** Initialize medals with a save name used for storage
|
|
3221
3287
|
* - Call this after creating all medals
|
|
3222
3288
|
* - Checks if medals are unlocked
|
|
@@ -3232,6 +3298,22 @@ declare module "littlejsengine" {
|
|
|
3232
3298
|
* @param {MedalCallbackFunction} callback
|
|
3233
3299
|
* @memberof Medals */
|
|
3234
3300
|
export function medalsForEach(callback: MedalCallbackFunction): void;
|
|
3301
|
+
/** Set how long to show medals for in seconds
|
|
3302
|
+
* @param {number} time
|
|
3303
|
+
* @memberof Settings */
|
|
3304
|
+
export function setMedalDisplayTime(time: number): void;
|
|
3305
|
+
/** Set how quickly to slide on/off medals in seconds
|
|
3306
|
+
* @param {number} time
|
|
3307
|
+
* @memberof Settings */
|
|
3308
|
+
export function setMedalDisplaySlideTime(time: number): void;
|
|
3309
|
+
/** Set size of medal display
|
|
3310
|
+
* @param {Vector2} size
|
|
3311
|
+
* @memberof Settings */
|
|
3312
|
+
export function setMedalDisplaySize(size: Vector2): void;
|
|
3313
|
+
/** Set to stop medals from being unlockable
|
|
3314
|
+
* @param {boolean} preventUnlock
|
|
3315
|
+
* @memberof Settings */
|
|
3316
|
+
export function setMedalsPreventUnlock(preventUnlock: boolean): void;
|
|
3235
3317
|
/**
|
|
3236
3318
|
* Medal - Tracks an unlockable medal
|
|
3237
3319
|
* @memberof Medals
|
|
@@ -3264,6 +3346,7 @@ declare module "littlejsengine" {
|
|
|
3264
3346
|
icon: string;
|
|
3265
3347
|
/** @property {boolean} - Is the medal unlocked? */
|
|
3266
3348
|
unlocked: boolean;
|
|
3349
|
+
/** @property {HTMLImageElement|undefined} - Source image for the medal icon, if any */
|
|
3267
3350
|
image: HTMLImageElement;
|
|
3268
3351
|
/** Unlocks a medal if not already unlocked */
|
|
3269
3352
|
unlock(): void;
|
|
@@ -3278,37 +3361,6 @@ declare module "littlejsengine" {
|
|
|
3278
3361
|
renderIcon(pos: Vector2, size: number): void;
|
|
3279
3362
|
storageKey(): string;
|
|
3280
3363
|
}
|
|
3281
|
-
/** How long to show medals for in seconds
|
|
3282
|
-
* @type {number}
|
|
3283
|
-
* @default
|
|
3284
|
-
* @memberof Settings */
|
|
3285
|
-
export let medalDisplayTime: number;
|
|
3286
|
-
/** How quickly to slide on/off medals in seconds
|
|
3287
|
-
* @type {number}
|
|
3288
|
-
* @default
|
|
3289
|
-
* @memberof Settings */
|
|
3290
|
-
export let medalDisplaySlideTime: number;
|
|
3291
|
-
/** Size of medal display
|
|
3292
|
-
* @type {Vector2}
|
|
3293
|
-
* @default Vector2(640,80)
|
|
3294
|
-
* @memberof Settings */
|
|
3295
|
-
export let medalDisplaySize: Vector2;
|
|
3296
|
-
/** Set how long to show medals for in seconds
|
|
3297
|
-
* @param {number} time
|
|
3298
|
-
* @memberof Settings */
|
|
3299
|
-
export function setMedalDisplayTime(time: number): void;
|
|
3300
|
-
/** Set how quickly to slide on/off medals in seconds
|
|
3301
|
-
* @param {number} time
|
|
3302
|
-
* @memberof Settings */
|
|
3303
|
-
export function setMedalDisplaySlideTime(time: number): void;
|
|
3304
|
-
/** Set size of medal display
|
|
3305
|
-
* @param {Vector2} size
|
|
3306
|
-
* @memberof Settings */
|
|
3307
|
-
export function setMedalDisplaySize(size: Vector2): void;
|
|
3308
|
-
/** Set to stop medals from being unlockable
|
|
3309
|
-
* @param {boolean} preventUnlock
|
|
3310
|
-
* @memberof Settings */
|
|
3311
|
-
export function setMedalsPreventUnlock(preventUnlock: boolean): void;
|
|
3312
3364
|
/**
|
|
3313
3365
|
* LittleJS Newgrounds Plugin
|
|
3314
3366
|
* - NewgroundsMedal extends Medal with Newgrounds API functionality
|
|
@@ -3337,10 +3389,15 @@ declare module "littlejsengine" {
|
|
|
3337
3389
|
* new NewgroundsPlugin(app_id);
|
|
3338
3390
|
*/
|
|
3339
3391
|
constructor(app_id: string, cipher?: string, cryptoJS?: any);
|
|
3392
|
+
/** @property {string} - The newgrounds App ID */
|
|
3340
3393
|
app_id: string;
|
|
3394
|
+
/** @property {string|undefined} - AES-128/Base64 encryption key, if any */
|
|
3341
3395
|
cipher: string;
|
|
3396
|
+
/** @property {Object|undefined} - CryptoJS instance used when cipher is set */
|
|
3342
3397
|
cryptoJS: any;
|
|
3398
|
+
/** @property {string} - Hostname used when logging views */
|
|
3343
3399
|
host: string;
|
|
3400
|
+
/** @property {string|null} - Newgrounds session id from the URL (null when not logged in) */
|
|
3344
3401
|
session_id: string;
|
|
3345
3402
|
medals: any;
|
|
3346
3403
|
scoreboards: any;
|
|
@@ -3458,6 +3515,14 @@ declare module "littlejsengine" {
|
|
|
3458
3515
|
*/
|
|
3459
3516
|
playMusic(volume?: number, loop?: boolean): SoundInstance;
|
|
3460
3517
|
}
|
|
3518
|
+
/** Generate samples for a ZzFM song with given parameters
|
|
3519
|
+
* @param {Array} instruments - Array of ZzFX sound parameters
|
|
3520
|
+
* @param {Array} patterns - Array of pattern data
|
|
3521
|
+
* @param {Array} sequence - Array of pattern indexes
|
|
3522
|
+
* @param {number} [BPM] - Playback speed of the song in BPM
|
|
3523
|
+
* @return {Array} - Left and right channel sample data
|
|
3524
|
+
* @memberof ZzFXM */
|
|
3525
|
+
export function zzfxM(instruments: any[], patterns: any[], sequence: any[], BPM?: number): any[];
|
|
3461
3526
|
/**
|
|
3462
3527
|
* LittleJS User Interface Plugin
|
|
3463
3528
|
* - call new UISystemPlugin() to setup the UI system
|
|
@@ -3619,6 +3684,7 @@ declare module "littlejsengine" {
|
|
|
3619
3684
|
* @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
|
|
3620
3685
|
* @param {DragAndDropCallback} [onDragOver] - continuously when dragging over */
|
|
3621
3686
|
setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
|
|
3687
|
+
_dragListeners: any[];
|
|
3622
3688
|
/** Convert a screen space position to native UI position
|
|
3623
3689
|
* @param {Vector2} pos
|
|
3624
3690
|
* @return {Vector2} */
|
|
@@ -4185,7 +4251,9 @@ declare module "littlejsengine" {
|
|
|
4185
4251
|
/** Add a box shape to the body
|
|
4186
4252
|
* @param {Vector2} [size]
|
|
4187
4253
|
* @param {Vector2} [offset]
|
|
4188
|
-
* @param {number} [angle]
|
|
4254
|
+
* @param {number} [angle] - LittleJS convention (clockwise positive).
|
|
4255
|
+
* Negated internally to match Box2D's CCW-positive convention so the
|
|
4256
|
+
* fixture aligns with the same angle passed to drawRect/drawTile.
|
|
4189
4257
|
* @param {number} [density]
|
|
4190
4258
|
* @param {number} [friction]
|
|
4191
4259
|
* @param {number} [restitution]
|
|
@@ -5074,13 +5142,21 @@ declare module "littlejsengine" {
|
|
|
5074
5142
|
useRealTime?: boolean;
|
|
5075
5143
|
paused?: boolean;
|
|
5076
5144
|
});
|
|
5145
|
+
/** @property {function(number|Vector2|Color):void} - Called with the interpolated value each frame */
|
|
5077
5146
|
callback: (arg0: number | Vector2 | Color) => void;
|
|
5147
|
+
/** @property {number|Vector2|Color} - Starting value */
|
|
5078
5148
|
start: number | Vector2 | Color;
|
|
5149
|
+
/** @property {number|Vector2|Color} - Ending value */
|
|
5079
5150
|
end: number | Vector2 | Color;
|
|
5151
|
+
/** @property {number} - Total duration in seconds */
|
|
5080
5152
|
duration: number;
|
|
5153
|
+
/** @property {number} - Remaining time in seconds (counts down from duration to 0) */
|
|
5081
5154
|
life: number;
|
|
5155
|
+
/** @property {function(number):number} - Easing curve mapping [0,1] -> [0,1] */
|
|
5082
5156
|
ease: (arg0: number) => number;
|
|
5157
|
+
/** @property {boolean} - If true, advance even when the game is paused */
|
|
5083
5158
|
useRealTime: boolean;
|
|
5159
|
+
/** @property {boolean} - If true, stop advancing until cleared */
|
|
5084
5160
|
paused: boolean;
|
|
5085
5161
|
/** @private completion callback set by then(), loop(), pingPong(). */
|
|
5086
5162
|
private thenCallback;
|
|
@@ -5222,13 +5298,21 @@ declare module "littlejsengine" {
|
|
|
5222
5298
|
* (size and walkability auto-derived) or a Vector2 grid size (user
|
|
5223
5299
|
* overrides isWalkable). */
|
|
5224
5300
|
constructor(source: TileCollisionLayer | Vector2);
|
|
5301
|
+
/** @property {Vector2} - Grid dimensions in tiles */
|
|
5225
5302
|
size: any;
|
|
5303
|
+
/** @property {TileCollisionLayer|undefined} - Tile layer driving walkability, if any */
|
|
5226
5304
|
tileLayer: Vector2 | TileCollisionLayer;
|
|
5305
|
+
/** @property {number} - A* heuristic multiplier (1 = admissible, higher = greedier) */
|
|
5227
5306
|
heuristicWeight: number;
|
|
5307
|
+
/** @property {number} - Maximum A* expansions before giving up */
|
|
5228
5308
|
maxLoop: number;
|
|
5309
|
+
/** @property {boolean} - If true, post-process paths with two-pass smoothing */
|
|
5229
5310
|
smoothPath: boolean;
|
|
5311
|
+
/** @property {boolean} - If true, draw debug visualization during findPath */
|
|
5230
5312
|
debug: boolean;
|
|
5313
|
+
/** @property {number} - Debug primitive lifetime in seconds (0 disables drawing) */
|
|
5231
5314
|
debugTime: number;
|
|
5315
|
+
/** @property {Array<PathFinderNode>} - Flat row-major array of size.x*size.y nodes */
|
|
5232
5316
|
nodes: any[];
|
|
5233
5317
|
collisionScratch: Vector2;
|
|
5234
5318
|
/** Default walkability: if a tile layer was provided, returns true when the
|
|
@@ -5308,6 +5392,14 @@ declare module "littlejsengine" {
|
|
|
5308
5392
|
* @param {PathFinderNode[]} path
|
|
5309
5393
|
* @private */
|
|
5310
5394
|
private smoothPathStringPull;
|
|
5395
|
+
/** Drop any middle node that lies exactly on the line through its two
|
|
5396
|
+
* neighbors. Backstop for the smoothing passes — the corners pass
|
|
5397
|
+
* intentionally keeps truly-straight runs, and the string-pulling pass
|
|
5398
|
+
* checks collinearity against the original path, not the in-progress
|
|
5399
|
+
* result, so it can leave 3+ collinear nodes in some edge cases.
|
|
5400
|
+
* @param {PathFinderNode[]} path
|
|
5401
|
+
* @private */
|
|
5402
|
+
private dropCollinearNodes;
|
|
5311
5403
|
/** Lookup helper: true when the node at tile coords (x, y) is in-bounds
|
|
5312
5404
|
* and clear (walkable, zero-cost). Used by isLineClear's hot path.
|
|
5313
5405
|
* @param {number} x
|