littlejsengine 1.14.10 → 1.14.16

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.
Files changed (76) hide show
  1. package/dist/littlejs.d.ts +264 -120
  2. package/dist/littlejs.esm.js +603 -288
  3. package/dist/littlejs.esm.min.js +1 -1
  4. package/dist/littlejs.js +600 -287
  5. package/dist/littlejs.min.js +1 -1
  6. package/dist/littlejs.release.js +521 -232
  7. package/examples/box2d/gameObjects.js +2 -2
  8. package/examples/breakout/gameObjects.js +2 -2
  9. package/examples/breakoutTutorial/README.md +32 -32
  10. package/examples/breakoutTutorial/game.js +1 -1
  11. package/examples/electron/game.js +3 -3
  12. package/examples/electron/index.html +2 -2
  13. package/examples/electron/package.json +1 -8
  14. package/examples/index.html +59 -51
  15. package/examples/module/game.js +3 -3
  16. package/examples/platformer/gameCharacter.js +6 -2
  17. package/examples/platformer/gameEffects.js +4 -4
  18. package/examples/platformer/gameLevel.js +1 -1
  19. package/examples/platformer/gameObjects.js +11 -9
  20. package/examples/puzzle/game.js +1 -1
  21. package/examples/shorts/animation.js +1 -1
  22. package/examples/shorts/base.html +1 -1
  23. package/examples/shorts/blending.js +8 -14
  24. package/examples/shorts/box2d.js +7 -3
  25. package/examples/shorts/box2dCar.js +2 -1
  26. package/examples/shorts/empty.js +30 -0
  27. package/examples/shorts/helloWorld.js +1 -1
  28. package/examples/shorts/hillGlideGame.js +10 -4
  29. package/examples/shorts/landerGame.js +30 -3
  30. package/examples/shorts/medals.js +4 -4
  31. package/examples/shorts/music.js +29 -55
  32. package/examples/shorts/musicPlayer.js +134 -0
  33. package/examples/shorts/nineSlice.js +34 -15
  34. package/examples/shorts/parallax.js +4 -3
  35. package/examples/shorts/particles.js +16 -16
  36. package/examples/shorts/piano.js +15 -21
  37. package/examples/shorts/pongGame.js +6 -4
  38. package/examples/shorts/raycasting.js +13 -5
  39. package/examples/shorts/sequencer.js +122 -0
  40. package/examples/shorts/shapes.js +7 -4
  41. package/examples/shorts/slidingPuzzle.js +16 -6
  42. package/examples/shorts/sound.js +18 -9
  43. package/examples/shorts/spaceGame.js +12 -8
  44. package/examples/shorts/spriteAtlas.js +7 -7
  45. package/examples/shorts/starfield.js +1 -1
  46. package/examples/shorts/systemFont.js +2 -2
  47. package/examples/shorts/texture.js +2 -2
  48. package/examples/shorts/tileLayer.js +10 -10
  49. package/examples/shorts/tiltedView.js +14 -3
  50. package/examples/shorts/timers.js +10 -0
  51. package/examples/shorts/topDown.js +4 -1
  52. package/examples/shorts/uiSystem.js +8 -5
  53. package/examples/starter/game.js +3 -3
  54. package/examples/starter/index.html +2 -2
  55. package/examples/typescript/game.js +3 -3
  56. package/examples/typescript/game.ts +3 -3
  57. package/examples/uiSystem/game.js +6 -6
  58. package/package.json +4 -2
  59. package/plugins/box2d.js +18 -3
  60. package/plugins/newgrounds.js +11 -9
  61. package/plugins/postProcess.js +5 -2
  62. package/plugins/uiSystem.js +120 -34
  63. package/plugins/zzfxm.js +5 -1
  64. package/reference.md +1 -3
  65. package/src/engine.js +52 -21
  66. package/src/engineAudio.js +31 -14
  67. package/src/engineDebug.js +80 -55
  68. package/src/engineDraw.js +60 -31
  69. package/src/engineExport.js +3 -1
  70. package/src/engineMedals.js +10 -2
  71. package/src/engineObject.js +14 -10
  72. package/src/engineParticles.js +59 -46
  73. package/src/engineRelease.js +1 -0
  74. package/src/engineSettings.js +7 -7
  75. package/src/engineTileLayer.js +49 -18
  76. package/src/engineUtilities.js +79 -34
@@ -1,4 +1,36 @@
1
1
  declare module "littlejsengine" {
2
+ /**
3
+ * - Update or render function for a plugin
4
+ */
5
+ export type PluginCallback = () => any;
6
+ /**
7
+ * - Called after the engine starts, can be async
8
+ */
9
+ export type GameInitCallback = () => void | Promise<void>;
10
+ /**
11
+ * - Update or render function for the game
12
+ */
13
+ export type GameCallback = () => any;
14
+ /**
15
+ * - Function that processes an object
16
+ */
17
+ export type ObjectCallbackFunction = (uiObjects: EngineObject) => any;
18
+ /**
19
+ * - A function that draws to a 2D canvas context
20
+ */
21
+ export type Canvas2DDrawFunction = (context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D) => any;
22
+ /**
23
+ * - Function called when a sound ends
24
+ */
25
+ export type AudioEndedCallback = (source: AudioBufferSourceNode) => any;
26
+ /**
27
+ * - Function that processes a medal
28
+ */
29
+ export type MedalCallbackFunction = (medal: Medal) => any;
30
+ /**
31
+ * - Function that processes a particle
32
+ */
33
+ export type ParticleCallbackFunction = (particle: Particle) => any;
2
34
  /**
3
35
  * LittleJS - The Tiny Fast JavaScript Game Engine
4
36
  * MIT License - Copyright 2021 Frank Force
@@ -67,26 +99,35 @@ declare module "littlejsengine" {
67
99
  * @param {boolean} [isPaused]
68
100
  * @memberof Engine */
69
101
  export function setPaused(isPaused?: boolean): void;
102
+ /**
103
+ * @callback GameInitCallback - Called after the engine starts, can be async
104
+ * @returns {void|Promise<void>}
105
+ * @memberof Engine
106
+ */
107
+ /**
108
+ * @callback GameCallback - Update or render function for the game
109
+ * @memberof Engine
110
+ */
70
111
  /** Startup LittleJS engine with your callback functions
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
112
+ * @param {GameInitCallback} gameInit - Called once after the engine starts up, can be async for loading
113
+ * @param {GameCallback} gameUpdate - Called every frame before objects are updated (60fps), use for game logic
114
+ * @param {GameCallback} gameUpdatePost - Called after physics and objects are updated, even when paused, use for UI updates
115
+ * @param {GameCallback} gameRender - Called before objects are rendered, use for drawing backgrounds/world elements
116
+ * @param {GameCallback} gameRenderPost - Called after objects are rendered, use for drawing UI/overlays
76
117
  * @param {Array<string>} [imageSources=[]] - List of image file paths to preload (e.g., ['player.png', 'tiles.png'])
77
118
  * @param {HTMLElement} [rootElement] - Root DOM element to attach canvas to, defaults to document.body
78
119
  * @example
79
120
  * // Basic engine startup
80
121
  * engineInit(
81
- * () => { console.log('Game initialized!'); }, // gameInit
82
- * () => { updateGameLogic(); }, // gameUpdate
83
- * () => { updateUI(); }, // gameUpdatePost
84
- * () => { drawBackground(); }, // gameRender
85
- * () => { drawHUD(); }, // gameRenderPost
86
- * ['tiles.png', 'tilesLevel.png'] // images to load
122
+ * () => { LOG('Game initialized!'); }, // gameInit
123
+ * () => { updateGameLogic(); }, // gameUpdate
124
+ * () => { updateUI(); }, // gameUpdatePost
125
+ * () => { drawBackground(); }, // gameRender
126
+ * () => { drawHUD(); }, // gameRenderPost
127
+ * ['tiles.png', 'tilesLevel.png'] // images to load
87
128
  * );
88
129
  * @memberof Engine */
89
- export function engineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: Array<string>, rootElement?: HTMLElement): Promise<void>;
130
+ export function engineInit(gameInit: GameInitCallback, gameUpdate: GameCallback, gameUpdatePost: GameCallback, gameRender: GameCallback, gameRenderPost: GameCallback, imageSources?: Array<string>, rootElement?: HTMLElement): Promise<void>;
90
131
  /** Update each engine object, remove destroyed objects, and update time
91
132
  * @memberof Engine */
92
133
  export function engineObjectsUpdate(): void;
@@ -100,13 +141,18 @@ declare module "littlejsengine" {
100
141
  * @return {Array<EngineObject>} - List of collected objects
101
142
  * @memberof Engine */
102
143
  export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>): Array<EngineObject>;
144
+ /**
145
+ * @callback ObjectCallbackFunction - Function that processes an object
146
+ * @param {EngineObject} uiObjects
147
+ * @memberof Engine
148
+ */
103
149
  /** Triggers a callback for each object within a given area
104
- * @param {Vector2} [pos] - Center of test area, or undefined for all objects
105
- * @param {Vector2|number} [size] - Radius of circle if float, rectangle size if Vector2
106
- * @param {Function} [callbackFunction] - Calls this function on every object that passes the test
150
+ * @param {Vector2} [pos] - Center of test area, or undefined for all objects
151
+ * @param {Vector2|number} [size] - Radius of circle if float, rectangle size if Vector2
152
+ * @param {ObjectCallbackFunction} [callbackFunction] - Calls this function on every object that passes the test
107
153
  * @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
108
154
  * @memberof Engine */
109
- export function engineObjectsCallback(pos?: Vector2, size?: Vector2 | number, callbackFunction?: Function, objects?: Array<EngineObject>): void;
155
+ export function engineObjectsCallback(pos?: Vector2, size?: Vector2 | number, callbackFunction?: ObjectCallbackFunction, objects?: Array<EngineObject>): void;
110
156
  /** Return a list of objects intersecting a ray
111
157
  * @param {Vector2} start
112
158
  * @param {Vector2} end
@@ -114,11 +160,15 @@ declare module "littlejsengine" {
114
160
  * @return {Array<EngineObject>} - List of objects hit
115
161
  * @memberof Engine */
116
162
  export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?: Array<EngineObject>): Array<EngineObject>;
163
+ /**
164
+ * @callback PluginCallback - Update or render function for a plugin
165
+ * @memberof Engine
166
+ */
117
167
  /** Add a new update function for a plugin
118
- * @param {Function} [updateFunction]
119
- * @param {Function} [renderFunction]
168
+ * @param {PluginCallback} [updateFunction]
169
+ * @param {PluginCallback} [renderFunction]
120
170
  * @memberof Engine */
121
- export function engineAddPlugin(updateFunction?: Function, renderFunction?: Function): void;
171
+ export function engineAddPlugin(updateFunction?: PluginCallback, renderFunction?: PluginCallback): void;
122
172
  /**
123
173
  * LittleJS Debug System
124
174
  * - Press Esc to show debug overlay with mouse pick
@@ -143,70 +193,75 @@ declare module "littlejsengine" {
143
193
  * @default
144
194
  * @memberof Debug */
145
195
  export let showWatermark: boolean;
146
- /** Asserts if the expression is false, does not do anything in release builds
196
+ /** Asserts if the expression is false, does nothing in release builds
197
+ * Halts execution if the assert fails and throws an error
147
198
  * @param {boolean} assert
148
199
  * @param {...Object} [output] - error message output
149
200
  * @memberof Debug */
150
201
  export function ASSERT(assert: boolean, ...output?: any[]): void;
202
+ /** Log to console if debug is enabled, does nothing in release builds
203
+ * @param {...Object} [output] - message output
204
+ * @memberof Debug */
205
+ export function LOG(...output?: any[]): void;
151
206
  /** Draw a debug rectangle in world space
152
207
  * @param {Vector2} pos
153
208
  * @param {Vector2} [size=Vector2()]
154
- * @param {string} [color]
155
- * @param {number} [time]
156
- * @param {number} [angle]
209
+ * @param {Color|string} [color]
210
+ * @param {number} [time]
211
+ * @param {number} [angle]
157
212
  * @param {boolean} [fill]
158
213
  * @memberof Debug */
159
- export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
214
+ export function debugRect(pos: Vector2, size?: Vector2, color?: Color | string, time?: number, angle?: number, fill?: boolean): void;
160
215
  /** Draw a debug poly in world space
161
216
  * @param {Vector2} pos
162
217
  * @param {Array<Vector2>} points
163
- * @param {string} [color]
164
- * @param {number} [time]
165
- * @param {number} [angle]
218
+ * @param {Color|string} [color]
219
+ * @param {number} [time]
220
+ * @param {number} [angle]
166
221
  * @param {boolean} [fill]
167
222
  * @memberof Debug */
168
- export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: string, time?: number, angle?: number, fill?: boolean): void;
223
+ export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: Color | string, time?: number, angle?: number, fill?: boolean): void;
169
224
  /** Draw a debug circle in world space
170
225
  * @param {Vector2} pos
171
- * @param {number} [size] - diameter
172
- * @param {string} [color]
173
- * @param {number} [time]
226
+ * @param {number} [size] - diameter
227
+ * @param {Color|string} [color]
228
+ * @param {number} [time]
174
229
  * @param {boolean} [fill]
175
230
  * @memberof Debug */
176
- export function debugCircle(pos: Vector2, size?: number, color?: string, time?: number, fill?: boolean): void;
231
+ export function debugCircle(pos: Vector2, size?: number, color?: Color | string, time?: number, fill?: boolean): void;
177
232
  /** Draw a debug point in world space
178
233
  * @param {Vector2} pos
179
- * @param {string} [color]
180
- * @param {number} [time]
181
- * @param {number} [angle]
234
+ * @param {Color|string} [color]
235
+ * @param {number} [time]
236
+ * @param {number} [angle]
182
237
  * @memberof Debug */
183
- export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
238
+ export function debugPoint(pos: Vector2, color?: Color | string, time?: number, angle?: number): void;
184
239
  /** Draw a debug line in world space
185
240
  * @param {Vector2} posA
186
241
  * @param {Vector2} posB
187
- * @param {string} [color]
188
- * @param {number} [width]
189
- * @param {number} [time]
242
+ * @param {Color|string} [color]
243
+ * @param {number} [width]
244
+ * @param {number} [time]
190
245
  * @memberof Debug */
191
- export function debugLine(posA: Vector2, posB: Vector2, color?: string, width?: number, time?: number): void;
246
+ export function debugLine(posA: Vector2, posB: Vector2, color?: Color | string, width?: number, time?: number): void;
192
247
  /** Draw a debug combined axis aligned bounding box in world space
193
248
  * @param {Vector2} posA
194
249
  * @param {Vector2} sizeA
195
250
  * @param {Vector2} posB
196
251
  * @param {Vector2} sizeB
197
- * @param {string} [color]
252
+ * @param {Color|string} [color]
198
253
  * @memberof Debug */
199
- export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: string): void;
254
+ export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: Color | string): void;
200
255
  /** Draw a debug axis aligned bounding box in world space
201
- * @param {string} text
256
+ * @param {string} text
202
257
  * @param {Vector2} pos
203
- * @param {number} [size]
204
- * @param {string} [color]
205
- * @param {number} [time]
206
- * @param {number} [angle]
207
- * @param {string} [font]
258
+ * @param {number} [size]
259
+ * @param {Color|string} [color]
260
+ * @param {number} [time]
261
+ * @param {number} [angle]
262
+ * @param {string} [font]
208
263
  * @memberof Debug */
209
- export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
264
+ export function debugText(text: string, pos: Vector2, size?: number, color?: Color | string, time?: number, angle?: number, font?: string): void;
210
265
  /** Clear all debug primitives in the list
211
266
  * @memberof Debug */
212
267
  export function debugClear(): void;
@@ -230,7 +285,9 @@ declare module "littlejsengine" {
230
285
  * @param {string} filename
231
286
  * @memberof Debug */
232
287
  export function debugSaveDataURL(dataURL: string, filename: string): void;
233
- /** Show error as full page of red text
288
+ /** Breaks on all asserts/errors, hides the canvas, and shows message in plain text
289
+ * This is a good function to call at the start of your game to catch all errors
290
+ * In release builds this function has no effect
234
291
  * @memberof Debug */
235
292
  export function debugShowErrors(): void;
236
293
  /** Check if video capture is active
@@ -808,6 +865,7 @@ declare module "littlejsengine" {
808
865
  /**
809
866
  * Seeded random number generator
810
867
  * - Can be used to create a deterministic random number sequence
868
+ * @memberof Engine
811
869
  * @example
812
870
  * let r = new RandomGenerator(123); // random number generator with seed 123
813
871
  * let a = r.float(); // random value between 0 and 1
@@ -855,6 +913,7 @@ declare module "littlejsengine" {
855
913
  /**
856
914
  * 2D Vector object with vector math library
857
915
  * - Functions do not change this so they can be chained together
916
+ * @memberof Engine
858
917
  * @example
859
918
  * let a = new Vector2(2, 3); // vector with coordinates (2, 3)
860
919
  * let b = new Vector2; // vector with coordinates (0, 0)
@@ -945,17 +1004,15 @@ declare module "littlejsengine" {
945
1004
  * @param {number} angle
946
1005
  * @return {Vector2} */
947
1006
  rotate(angle: number): Vector2;
948
- /** Set the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)
1007
+ /** Sets this this vector to point in the specified integer direction (0-3), corresponding to multiples of 90 degree rotation
949
1008
  * @param {number} [direction]
950
- * @param {number} [length] */
1009
+ * @param {number} [length]
1010
+ * @return {Vector2} */
951
1011
  setDirection(direction?: number, length?: number): Vector2;
952
1012
  /** Returns the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)
953
1013
  * @return {number} */
954
1014
  direction(): number;
955
- /** Returns a copy of this vector that has been inverted
956
- * @return {Vector2} */
957
- invert(): Vector2;
958
- /** Returns a copy of this vector absolute values
1015
+ /** Returns a copy of this vector with absolute values
959
1016
  * @return {Vector2} */
960
1017
  abs(): Vector2;
961
1018
  /** Returns a copy of this vector with each axis floored
@@ -987,6 +1044,7 @@ declare module "littlejsengine" {
987
1044
  }
988
1045
  /**
989
1046
  * Color object (red, green, blue, alpha) with some helpful functions
1047
+ * @memberof Engine
990
1048
  * @example
991
1049
  * let a = new Color; // white
992
1050
  * let b = new Color(1, 0, 0); // red
@@ -1080,6 +1138,7 @@ declare module "littlejsengine" {
1080
1138
  }
1081
1139
  /**
1082
1140
  * Timer object tracks how long has passed since it was set
1141
+ * @memberof Engine
1083
1142
  * @example
1084
1143
  * let a = new Timer; // creates a timer that is not set
1085
1144
  * a.set(3); // sets the timer to 3 seconds
@@ -1171,11 +1230,17 @@ declare module "littlejsengine" {
1171
1230
  * @return {boolean}
1172
1231
  * @memberof Utilities */
1173
1232
  export function isNumber(n: any): boolean;
1233
+ /**
1234
+ * Check if object is a valid string or can be converted to one
1235
+ * @param {any} s
1236
+ * @return {boolean}
1237
+ * @memberof Utilities */
1238
+ export function isString(s: any): boolean;
1174
1239
  /** Color - White #ffffff
1175
1240
  * @type {Color}
1176
1241
  * @memberof Utilities */
1177
1242
  export const WHITE: Color;
1178
- /** Color - Clear White #ffffff with 0 alpha
1243
+ /** Color - Clear White #757474ff with 0 alpha
1179
1244
  * @type {Color}
1180
1245
  * @memberof Utilities */
1181
1246
  export const CLEAR_WHITE: Color;
@@ -1227,7 +1292,7 @@ declare module "littlejsengine" {
1227
1292
  * Create a tile info object using a grid based system
1228
1293
  * - This can take vecs or floats for easier use and conversion
1229
1294
  * - If an index is passed in, the tile size and index will determine the position
1230
- * @param {Vector2|number} [pos=0] - Index of tile in sheet
1295
+ * @param {Vector2|number} [pos=0] - Position of the tile in pixels, or tile index
1231
1296
  * @param {Vector2|number} [size=tileSizeDefault] - Size of tile in pixels
1232
1297
  * @param {number} [textureIndex] - Texture index to use
1233
1298
  * @param {number} [padding] - How many pixels padding around tiles
@@ -1241,6 +1306,7 @@ declare module "littlejsengine" {
1241
1306
  export function tile(pos?: Vector2 | number, size?: Vector2 | number, textureIndex?: number, padding?: number): TileInfo;
1242
1307
  /**
1243
1308
  * Tile Info - Stores info about how to draw a tile
1309
+ * @memberof Draw
1244
1310
  */
1245
1311
  export class TileInfo {
1246
1312
  /** Create a tile info object
@@ -1281,7 +1347,10 @@ declare module "littlejsengine" {
1281
1347
  */
1282
1348
  setFullImage(image: HTMLImageElement | OffscreenCanvas, glTexture?: WebGLTexture): TileInfo;
1283
1349
  }
1284
- /** Texture Info - Stores info about each texture */
1350
+ /**
1351
+ * Tile Info - Stores info about each texture
1352
+ * @memberof Draw
1353
+ */
1285
1354
  export class TextureInfo {
1286
1355
  /**
1287
1356
  * Create a TextureInfo, called automatically by the engine
@@ -1459,16 +1528,21 @@ declare module "littlejsengine" {
1459
1528
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
1460
1529
  * @memberof Draw */
1461
1530
  export function drawCircle(pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1531
+ /**
1532
+ * @callback Canvas2DDrawFunction - A function that draws to a 2D canvas context
1533
+ * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
1534
+ * @memberof Draw
1535
+ */
1462
1536
  /** Draw directly to a 2d canvas context in world space
1463
1537
  * @param {Vector2} pos
1464
1538
  * @param {Vector2} size
1465
1539
  * @param {number} angle
1466
1540
  * @param {boolean} [mirror]
1467
- * @param {Function} [drawFunction]
1541
+ * @param {Canvas2DDrawFunction} [drawFunction]
1468
1542
  * @param {boolean} [screenSpace=false]
1469
1543
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
1470
1544
  * @memberof Draw */
1471
- export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1545
+ export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?: Canvas2DDrawFunction, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1472
1546
  /** Draw text on main canvas in world space
1473
1547
  * Automatically splits new lines into rows
1474
1548
  * @param {string} text
@@ -1525,6 +1599,7 @@ declare module "littlejsengine" {
1525
1599
  * - 96 characters (from space to tilde) are stored in an image
1526
1600
  * - Uses a default 8x8 font if none is supplied
1527
1601
  * - You can also use fonts from the main tile sheet
1602
+ * @memberof Draw
1528
1603
  * @example
1529
1604
  * // use built in font
1530
1605
  * const font = new FontImage;
@@ -1875,6 +1950,7 @@ declare module "littlejsengine" {
1875
1950
  * Sound Object - Stores a sound for later use and can be played positionally
1876
1951
  *
1877
1952
  * <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
1953
+ * @memberof Audio
1878
1954
  * @example
1879
1955
  * // create a sound
1880
1956
  * const sound_example = new Sound([.5,.5]);
@@ -1920,12 +1996,12 @@ declare module "littlejsengine" {
1920
1996
  playMusic(volume?: number, loop?: boolean, paused?: boolean): SoundInstance;
1921
1997
  /** Play the sound as a musical note with a semitone offset
1922
1998
  * This can be used to play music with chromatic scales
1923
- * @param {number} semitoneOffset - How many semitones to offset pitch
1999
+ * @param {number} [semitoneOffset=0] - How many semitones to offset pitch
1924
2000
  * @param {Vector2} [pos] - World space position to play the sound if any
1925
2001
  * @param {number} [volume=1] - How much to scale volume by
1926
2002
  * @return {SoundInstance} - The audio source node
1927
2003
  */
1928
- playNote(semitoneOffset: number, pos?: Vector2, volume?: number): SoundInstance;
2004
+ playNote(semitoneOffset?: number, pos?: Vector2, volume?: number): SoundInstance;
1929
2005
  /** Get how long this sound is in seconds
1930
2006
  * @return {number} - How long the sound is in seconds (undefined if loading)
1931
2007
  */
@@ -1938,6 +2014,8 @@ declare module "littlejsengine" {
1938
2014
  /**
1939
2015
  * Sound Wave Object - Stores a wave sound for later use and can be played positionally
1940
2016
  * - this can be used to play wave, mp3, and ogg files
2017
+ * @extends Sound
2018
+ * @memberof Audio
1941
2019
  * @example
1942
2020
  * // create a sound
1943
2021
  * const sound_example = new SoundWave('sound.mp3');
@@ -1946,16 +2024,21 @@ declare module "littlejsengine" {
1946
2024
  * sound_example.play();
1947
2025
  */
1948
2026
  export class SoundWave extends Sound {
2027
+ /**
2028
+ * @callback SoundLoadCallback - Function called when sound is loaded
2029
+ * @param {SoundWave} sound
2030
+ * @memberof Audio
2031
+ */
1949
2032
  /** Create a sound object and cache the wave file for later use
1950
2033
  * @param {string} filename - Filename of audio file to load
1951
2034
  * @param {number} [randomness] - How much to randomize frequency each time sound plays
1952
2035
  * @param {number} [range=soundDefaultRange] - World space max range of sound
1953
2036
  * @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
1954
- * @param {Function} [onloadCallback] - callback function to call when sound is loaded
2037
+ * @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
1955
2038
  */
1956
- constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: Function);
1957
- /** @property {Function} - callback function to call when sound is loaded */
1958
- onloadCallback: Function;
2039
+ constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: (sound: SoundWave) => SoundWave);
2040
+ /** @property {SoundLoadCallback} - callback function to call when sound is loaded */
2041
+ onloadCallback: (sound: SoundWave) => SoundWave;
1959
2042
  /** Loads a sound from a URL and decodes it into sample data. Must be used with await!
1960
2043
  * @param {string} filename
1961
2044
  * @return {Promise<void>} */
@@ -1964,6 +2047,7 @@ declare module "littlejsengine" {
1964
2047
  /**
1965
2048
  * Sound Instance - Wraps an AudioBufferSourceNode for individual sound control
1966
2049
  * Represents a single playing instance of a sound with pause/resume capabilities
2050
+ * @memberof Audio
1967
2051
  * @example
1968
2052
  * // Play a sound and get an instance for control
1969
2053
  * const jumpSound = new Sound([.5,.5,220]);
@@ -2055,6 +2139,11 @@ declare module "littlejsengine" {
2055
2139
  * @return {number} - The frequency of the note
2056
2140
  * @memberof Audio */
2057
2141
  export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
2142
+ /**
2143
+ * @callback AudioEndedCallback - Function called when a sound ends
2144
+ * @param {AudioBufferSourceNode} source
2145
+ * @memberof Audio
2146
+ */
2058
2147
  /** Play cached audio samples with given settings
2059
2148
  * @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
2060
2149
  * @param {number} [volume] - How much to scale volume by
@@ -2064,10 +2153,10 @@ declare module "littlejsengine" {
2064
2153
  * @param {number} [sampleRate=44100] - Sample rate for the sound
2065
2154
  * @param {GainNode} [gainNode] - Optional gain node for volume control while playing
2066
2155
  * @param {number} [offset] - Offset in seconds to start playback from
2067
- * @param {Function} [onended] - Callback for when the sound ends
2156
+ * @param {AudioEndedCallback} [onended] - Callback for when the sound ends
2068
2157
  * @return {AudioBufferSourceNode} - The audio node of the sound played
2069
2158
  * @memberof Audio */
2070
- export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode, offset?: number, onended?: Function): AudioBufferSourceNode;
2159
+ export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode, offset?: number, onended?: AudioEndedCallback): AudioBufferSourceNode;
2071
2160
  /** Generate and play a ZzFX sound
2072
2161
  *
2073
2162
  * <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
@@ -2123,6 +2212,7 @@ declare module "littlejsengine" {
2123
2212
  * - Collision for objects can be set to be solid to block other objects
2124
2213
  * - Objects may get pushed into overlapping other solid objects, if so they will push away
2125
2214
  * - Solid objects are more performance intensive and should be used sparingly
2215
+ * @memberof Engine
2126
2216
  * @example
2127
2217
  * // create an engine object, normally you would first extend the class with your own
2128
2218
  * const pos = vec2(2,3);
@@ -2130,12 +2220,12 @@ declare module "littlejsengine" {
2130
2220
  */
2131
2221
  export class EngineObject {
2132
2222
  /** Create an engine object and adds it to the list of objects
2133
- * @param {Vector2} [pos=(0,0)] - World space position of the object
2134
- * @param {Vector2} [size=(1,1)] - World space size of the object
2135
- * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
2136
- * @param {number} [angle] - Angle the object is rotated by
2137
- * @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
2138
- * @param {number} [renderOrder] - Objects sorted by renderOrder before being rendered
2223
+ * @param {Vector2} [pos=(0,0)] - World space position of the object
2224
+ * @param {Vector2} [size=(1,1)] - World space size of the object
2225
+ * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
2226
+ * @param {number} [angle] - Angle the object is rotated by
2227
+ * @param {Color} [color=WHITE] - Color to apply to tile when rendered
2228
+ * @param {number} [renderOrder] - Objects sorted by renderOrder before being rendered
2139
2229
  */
2140
2230
  constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
2141
2231
  /** @property {Vector2} - World space position of the object */
@@ -2200,7 +2290,7 @@ declare module "littlejsengine" {
2200
2290
  update(): void;
2201
2291
  /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
2202
2292
  render(): void;
2203
- /** Destroy this object, destroy its children, detach it's parent, and mark it for removal */
2293
+ /** Destroy this object, destroy its children, detach its parent, and mark it for removal */
2204
2294
  destroy(): void;
2205
2295
  destroyed: number;
2206
2296
  /** Convert from local space to world space
@@ -2266,16 +2356,16 @@ declare module "littlejsengine" {
2266
2356
  * - Unlimited numbers of layers, allocates canvases as needed
2267
2357
  * - Tile layers can be drawn to using their context with canvas2d
2268
2358
  * - Tile layers can also have collision with EngineObjects
2269
- * @namespace TileCollision
2359
+ * @namespace TileLayers
2270
2360
  */
2271
2361
  /** Keep track of all tile layers with collision
2272
2362
  * @type {Array<TileCollisionLayer>}
2273
- * @memberof TileCollision */
2363
+ * @memberof TileLayers */
2274
2364
  export const tileCollisionLayers: Array<TileCollisionLayer>;
2275
2365
  /** Get tile collision data for a given cell in the grid
2276
2366
  * @param {Vector2} pos
2277
2367
  * @return {number}
2278
- * @memberof TileCollision */
2368
+ * @memberof TileLayers */
2279
2369
  export function tileCollisionGetData(pos: Vector2): number;
2280
2370
  /** Check if a tile layer collides with another object
2281
2371
  * @param {Vector2} pos
@@ -2283,7 +2373,7 @@ declare module "littlejsengine" {
2283
2373
  * @param {EngineObject} [object] - An object or undefined for generic test
2284
2374
  * @param {boolean} [solidOnly] - Only check solid layers if true
2285
2375
  * @return {TileCollisionLayer}
2286
- * @memberof TileCollision */
2376
+ * @memberof TileLayers */
2287
2377
  export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
2288
2378
  /** Return the center of first tile hit, undefined if nothing was hit.
2289
2379
  * This does not return the exact intersection, but the center of the tile hit.
@@ -2292,7 +2382,7 @@ declare module "littlejsengine" {
2292
2382
  * @param {EngineObject} [object] - An object or undefined for generic test
2293
2383
  * @param {boolean} [solidOnly=true] - Only check solid layers if true
2294
2384
  * @return {Vector2}
2295
- * @memberof TileCollision */
2385
+ * @memberof TileLayers */
2296
2386
  export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, solidOnly?: boolean): Vector2;
2297
2387
  /**
2298
2388
  * Load tile layers from exported data
@@ -2302,10 +2392,11 @@ declare module "littlejsengine" {
2302
2392
  * @param {number} [collisionLayer] - Layer to use for collision if any
2303
2393
  * @param {boolean} [draw] - Should the layer be drawn automatically
2304
2394
  * @return {Array<TileCollisionLayer>}
2305
- * @memberof TileCollision */
2306
- export function tileCollisionLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: number, draw?: boolean): Array<TileCollisionLayer>;
2395
+ * @memberof TileLayers */
2396
+ export function tileLayersLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: number, draw?: boolean): Array<TileCollisionLayer>;
2307
2397
  /**
2308
2398
  * Tile layer data object stores info about how to draw a tile
2399
+ * @memberof TileLayers
2309
2400
  * @example
2310
2401
  * // create tile layer data with tile index 0 and random orientation and color
2311
2402
  * const tileIndex = 0;
@@ -2337,6 +2428,7 @@ declare module "littlejsengine" {
2337
2428
  * - Contains an offscreen canvas that can be rendered to
2338
2429
  * - WebGL rendering is optional, call useWebGL to enable
2339
2430
  * @extends EngineObject
2431
+ * @memberof TileLayers
2340
2432
  * @example
2341
2433
  * const canvasLayer = new CanvasLayer(vec2(), vec2(200,100));
2342
2434
  */
@@ -2366,13 +2458,18 @@ declare module "littlejsengine" {
2366
2458
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
2367
2459
  * @memberof Draw */
2368
2460
  draw(pos: Vector2, size?: Vector2, angle?: number, color?: Color, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
2461
+ /**
2462
+ * @callback Canvas2DDrawCallback - Function that draws to a canvas 2D context
2463
+ * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
2464
+ * @memberof TileLayers
2465
+ */
2369
2466
  /** Draw onto the layer canvas in world space (bypass WebGL)
2370
2467
  * @param {Vector2} pos
2371
2468
  * @param {Vector2} size
2372
2469
  * @param {number} angle
2373
2470
  * @param {boolean} mirror
2374
- * @param {Function} drawFunction */
2375
- drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
2471
+ * @param {Canvas2DDrawCallback} drawFunction */
2472
+ drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: (context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D) => any): void;
2376
2473
  /** Draw a tile onto the layer canvas in world space
2377
2474
  * @param {Vector2} pos
2378
2475
  * @param {Vector2} [size=(1,1)]
@@ -2397,7 +2494,9 @@ declare module "littlejsengine" {
2397
2494
  * - To allow dynamic modifications, layers are rendered using canvas 2d
2398
2495
  * - Some devices like mobile phones are limited to 4k texture resolution
2399
2496
  * - For with 16x16 tiles this limits layers to 256x256 on mobile devices
2497
+ * - Tile layers are centered on their corner, so normal levels are at (0,0)
2400
2498
  * @extends CanvasLayer
2499
+ * @memberof TileLayers
2401
2500
  * @example
2402
2501
  * const tileLayer = new TileLayer(vec2(), vec2(200,100));
2403
2502
  */
@@ -2406,11 +2505,10 @@ declare module "littlejsengine" {
2406
2505
  * @param {Vector2} position - World space position
2407
2506
  * @param {Vector2} size - World space size
2408
2507
  * @param {TileInfo} [tileInfo] - Default tile info for layer (used for size and texture)
2409
- * @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
2410
2508
  * @param {number} [renderOrder] - Objects are sorted by renderOrder
2411
2509
  * @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
2412
2510
  */
2413
- constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number, useWebGL?: boolean);
2511
+ constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number, useWebGL?: boolean);
2414
2512
  data: TileLayerData[];
2415
2513
  /** Draw all the tile data to an offscreen canvas
2416
2514
  * - This may be slow in some browsers but only needs to be done once */
@@ -2446,16 +2544,9 @@ declare module "littlejsengine" {
2446
2544
  * - there can be multiple tile collision layers
2447
2545
  * - tile collision layers should not overlap each other
2448
2546
  * @extends TileLayer
2547
+ * @memberof TileLayers
2449
2548
  */
2450
2549
  export class TileCollisionLayer extends TileLayer {
2451
- /** Create a tile layer object
2452
- * @param {Vector2} position - World space position
2453
- * @param {Vector2} size - World space size
2454
- * @param {TileInfo} [tileInfo] - Tile info for layer
2455
- * @param {number} [renderOrder] - Objects are sorted by renderOrder
2456
- * @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
2457
- */
2458
- constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number, useWebGL?: boolean);
2459
2550
  /** @property {Array<number>} - The tile collision grid */
2460
2551
  collisionData: any[];
2461
2552
  /** Clear and initialize tile collision to new size
@@ -2486,9 +2577,15 @@ declare module "littlejsengine" {
2486
2577
  /**
2487
2578
  * LittleJS Particle System
2488
2579
  */
2580
+ /**
2581
+ * @callback ParticleCallbackFunction - Function that processes a particle
2582
+ * @param {Particle} particle
2583
+ * @memberof Engine
2584
+ */
2489
2585
  /**
2490
2586
  * Particle Emitter - Spawns particles with the given settings
2491
2587
  * @extends EngineObject
2588
+ * @memberof Engine
2492
2589
  * @example
2493
2590
  * // create a particle emitter
2494
2591
  * let pos = vec2(2,3);
@@ -2512,10 +2609,10 @@ declare module "littlejsengine" {
2512
2609
  * @param {number} [emitRate] - How many particles per second to spawn, does not emit if 0
2513
2610
  * @param {number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
2514
2611
  * @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
2515
- * @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
2516
- * @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
2517
- * @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
2518
- * @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
2612
+ * @param {Color} [colorStartA=WHITE] - Color at start of life 1, randomized between start colors
2613
+ * @param {Color} [colorStartB=WHITE] - Color at start of life 2, randomized between start colors
2614
+ * @param {Color} [colorEndA=CLEAR_WHITE] - Color at end of life 1, randomized between end colors
2615
+ * @param {Color} [colorEndB=CLEAR_WHITE] - Color at end of life 2, randomized between end colors
2519
2616
  * @param {number} [particleTime] - How long particles live
2520
2617
  * @param {number} [sizeStart] - How big are particles at start
2521
2618
  * @param {number} [sizeEnd] - How big are particles at end
@@ -2574,9 +2671,9 @@ declare module "littlejsengine" {
2574
2671
  localSpace: boolean;
2575
2672
  /** @property {number} - If non zero the particle is drawn as a trail, stretched in the direction of velocity */
2576
2673
  trailScale: number;
2577
- /** @property {Function} - Callback when particle is destroyed */
2674
+ /** @property {ParticleCallbackFunction} - Callback when particle is destroyed */
2578
2675
  particleDestroyCallback: any;
2579
- /** @property {Function} - Callback when particle is created */
2676
+ /** @property {ParticleCallbackFunction} - Callback when particle is created */
2580
2677
  particleCreateCallback: any;
2581
2678
  /** @property {number} - Track particle emit time */
2582
2679
  emitTimeBuffer: number;
@@ -2587,6 +2684,7 @@ declare module "littlejsengine" {
2587
2684
  /**
2588
2685
  * Particle Object - Created automatically by Particle Emitters
2589
2686
  * @extends EngineObject
2687
+ * @memberof Engine
2590
2688
  */
2591
2689
  export class Particle extends EngineObject {
2592
2690
  /**
@@ -2604,19 +2702,19 @@ declare module "littlejsengine" {
2604
2702
  * @param {boolean} additive - Does it use additive blend mode
2605
2703
  * @param {number} trailScale - If a trail, how long to make it
2606
2704
  * @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
2607
- * @param {Function} [destroyCallback] - Callback when particle dies
2705
+ * @param {ParticleCallbackFunction} [destroyCallback] - Callback when particle dies
2608
2706
  */
2609
- constructor(position: Vector2, tileInfo: TileInfo, angle: number, colorStart: Color, colorEnd: Color, lifeTime: number, sizeStart: number, sizeEnd: number, fadeRate: number, additive: boolean, trailScale: number, localSpaceEmitter?: ParticleEmitter, destroyCallback?: Function);
2707
+ constructor(position: Vector2, tileInfo: TileInfo, angle: number, colorStart: Color, colorEnd: Color, lifeTime: number, sizeStart: number, sizeEnd: number, fadeRate: number, additive: boolean, trailScale: number, localSpaceEmitter?: ParticleEmitter, destroyCallback?: ParticleCallbackFunction);
2610
2708
  /** @property {Color} - Color at start of life */
2611
2709
  colorStart: Color;
2612
- /** @property {Color} - Calculated change in color */
2613
- colorEndDelta: Color;
2710
+ /** @property {Color} - Color at end of life */
2711
+ colorEnd: Color;
2614
2712
  /** @property {number} - How long to live for */
2615
2713
  lifeTime: number;
2616
2714
  /** @property {number} - Size at start of life */
2617
2715
  sizeStart: number;
2618
- /** @property {number} - Calculated change in size */
2619
- sizeEndDelta: number;
2716
+ /** @property {number} - Size at end of life */
2717
+ sizeEnd: number;
2620
2718
  /** @property {number} - How quick to fade in/out */
2621
2719
  fadeRate: number;
2622
2720
  /** @property {boolean} - Is it additive */
@@ -2625,8 +2723,8 @@ declare module "littlejsengine" {
2625
2723
  trailScale: number;
2626
2724
  /** @property {ParticleEmitter} - Parent emitter if local space */
2627
2725
  localSpaceEmitter: ParticleEmitter;
2628
- /** @property {Function} - Called when particle dies */
2629
- destroyCallback: Function;
2726
+ /** @property {ParticleCallbackFunction} - Called when particle dies */
2727
+ destroyCallback: ParticleCallbackFunction;
2630
2728
  }
2631
2729
  /**
2632
2730
  * LittleJS Medal System
@@ -2652,6 +2750,7 @@ declare module "littlejsengine" {
2652
2750
  export function medalsInit(saveName: string): void;
2653
2751
  /**
2654
2752
  * Medal - Tracks an unlockable medal
2753
+ * @memberof Medals
2655
2754
  * @example
2656
2755
  * // create a medal
2657
2756
  * const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');
@@ -2696,20 +2795,21 @@ declare module "littlejsengine" {
2696
2795
  storageKey(): string;
2697
2796
  }
2698
2797
  /**
2699
- * LittleJS Newgrounds API
2798
+ * LittleJS Newgrounds Plugin
2700
2799
  * - NewgroundsMedal extends Medal with Newgrounds API functionality
2701
- * - Call new NewgroundsPlugin() to setup Newgrounds
2800
+ * - Call new NewgroundsPlugin(app_id) to setup Newgrounds
2702
2801
  * - Uses CryptoJS for encryption if optional cipher is provided
2802
+ * - provides functions to interact with medals scoreboards
2703
2803
  * - Keeps connection alive and logs views
2704
- * - Functions to interact with scoreboards
2705
- * - Functions to unlock medals
2804
+ * @namespace Newgrounds
2706
2805
  */
2707
2806
  /** Global Newgrounds object
2708
2807
  * @type {NewgroundsPlugin}
2709
- * @memberof Medal */
2808
+ * @memberof Newgrounds */
2710
2809
  export let newgrounds: NewgroundsPlugin;
2711
2810
  /**
2712
2811
  * Newgrounds API object
2812
+ * @memberof Newgrounds
2713
2813
  */
2714
2814
  export class NewgroundsPlugin {
2715
2815
  /** Create the global newgrounds object
@@ -2758,20 +2858,24 @@ declare module "littlejsengine" {
2758
2858
  /**
2759
2859
  * Newgrounds medal auto unlocks in newgrounds API
2760
2860
  * @extends Medal
2861
+ * @memberof Newgrounds
2761
2862
  */
2762
2863
  export class NewgroundsMedal extends Medal {
2763
2864
  }
2764
2865
  /**
2765
2866
  * LittleJS Post Processing Plugin
2766
2867
  * - Supports shadertoy style post processing shaders
2767
- * - call new new PostProcessPlugin() to setup post processing
2868
+ * - call new PostProcessPlugin() to setup post processing
2768
2869
  * - can be enabled to pass other canvases through a final shader
2870
+ * @namespace PostProcess
2769
2871
  */
2770
2872
  /** Global Post Process plugin object
2771
- * @type {PostProcessPlugin} */
2873
+ * @type {PostProcessPlugin}
2874
+ * @memberof PostProcess */
2772
2875
  export let postProcess: PostProcessPlugin;
2773
2876
  /**
2774
2877
  * UI System Global Object
2878
+ * @memberof PostProcess
2775
2879
  */
2776
2880
  export class PostProcessPlugin {
2777
2881
  /** Create global post processing shader
@@ -2791,11 +2895,14 @@ declare module "littlejsengine" {
2791
2895
  }
2792
2896
  /**
2793
2897
  * LittleJS ZzFXM Plugin
2898
+ * @namespace ZzFXM
2794
2899
  */
2795
2900
  /**
2796
2901
  * Music Object - Stores a zzfx music track for later use
2797
2902
  *
2798
2903
  * <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
2904
+ * @extends Sound
2905
+ * @memberof ZzFXM
2799
2906
  * @example
2800
2907
  * // create some music
2801
2908
  * const music_example = new Music(
@@ -2843,12 +2950,15 @@ declare module "littlejsengine" {
2843
2950
  * - Buttons
2844
2951
  * - Checkboxes
2845
2952
  * - Images
2953
+ * @namespace UISystem
2846
2954
  */
2847
2955
  /** Global UI system plugin object
2848
- * @type {UISystemPlugin} */
2956
+ * @type {UISystemPlugin}
2957
+ * @memberof UISystem */
2849
2958
  export let uiSystem: UISystemPlugin;
2850
2959
  /**
2851
2960
  * UI System Global Object
2961
+ * @memberof UISystem
2852
2962
  */
2853
2963
  export class UISystemPlugin {
2854
2964
  /** Create the global UI system object
@@ -2888,10 +2998,12 @@ declare module "littlejsengine" {
2888
2998
  uiObjects: any[];
2889
2999
  /** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
2890
3000
  uiContext: CanvasRenderingContext2D;
2891
- /** @property {UIObject} - Top most object user is over */
2892
- hoverObject: any;
2893
3001
  /** @property {UIObject} - Object user is currently interacting with */
2894
3002
  activeObject: any;
3003
+ /** @property {UIObject} - Top most object user is over */
3004
+ hoverObject: any;
3005
+ /** @property {UIObject} - Hover object at start of update */
3006
+ lastHoverObject: any;
2895
3007
  /** Draw a rectangle to the UI context
2896
3008
  * @param {Vector2} pos
2897
3009
  * @param {Vector2} size
@@ -2925,10 +3037,22 @@ declare module "littlejsengine" {
2925
3037
  * @param {string} [font=uiSystem.defaultFont]
2926
3038
  * @param {boolean} [applyMaxWidth=true] */
2927
3039
  drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, applyMaxWidth?: boolean): void;
3040
+ /**
3041
+ * @callback DragAndDropCallback - Callback for drag and drop events
3042
+ * @param {DragEvent} event - The drag event
3043
+ * @memberof UISystem
3044
+ */
3045
+ /** Setup drag and drop event handlers
3046
+ * Automatically prevents defaults and calls the given functions
3047
+ * @param {DragAndDropCallback} [onDrop] - when a file is dropped
3048
+ * @param {DragAndDropCallback} [onDragEnter] - when a file is dragged onto the window
3049
+ * @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
3050
+ * @param {DragAndDropCallback} [onDragOver] - continously when dragging over */
3051
+ setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
2928
3052
  }
2929
3053
  /**
2930
3054
  * UI Object - Base level object for all UI elements
2931
- */
3055
+ * @memberof UISystem */
2932
3056
  export class UIObject {
2933
3057
  /** Create a UIObject
2934
3058
  * @param {Vector2} [pos=(0,0)]
@@ -3025,6 +3149,7 @@ declare module "littlejsengine" {
3025
3149
  /**
3026
3150
  * UIText - A UI object that displays text
3027
3151
  * @extends UIObject
3152
+ * @memberof UISystem
3028
3153
  */
3029
3154
  export class UIText extends UIObject {
3030
3155
  /** Create a UIText object
@@ -3041,6 +3166,7 @@ declare module "littlejsengine" {
3041
3166
  /**
3042
3167
  * UITile - A UI object that displays a tile image
3043
3168
  * @extends UIObject
3169
+ * @memberof UISystem
3044
3170
  */
3045
3171
  export class UITile extends UIObject {
3046
3172
  /** Create a UITile object
@@ -3062,6 +3188,7 @@ declare module "littlejsengine" {
3062
3188
  /**
3063
3189
  * UIButton - A UI object that acts as a button
3064
3190
  * @extends UIObject
3191
+ * @memberof UISystem
3065
3192
  */
3066
3193
  export class UIButton extends UIObject {
3067
3194
  /** Create a UIButton object
@@ -3076,6 +3203,7 @@ declare module "littlejsengine" {
3076
3203
  /**
3077
3204
  * UICheckbox - A UI object that acts as a checkbox
3078
3205
  * @extends UIObject
3206
+ * @memberof UISystem
3079
3207
  */
3080
3208
  export class UICheckbox extends UIObject {
3081
3209
  /** Create a UICheckbox object
@@ -3093,6 +3221,7 @@ declare module "littlejsengine" {
3093
3221
  /**
3094
3222
  * UIScrollbar - A UI object that acts as a scrollbar
3095
3223
  * @extends UIObject
3224
+ * @memberof UISystem
3096
3225
  */
3097
3226
  export class UIScrollbar extends UIObject {
3098
3227
  /** Create a UIScrollbar object
@@ -3147,6 +3276,7 @@ declare module "littlejsengine" {
3147
3276
  /**
3148
3277
  * Box2D Global Object
3149
3278
  * - Wraps Box2d world and provides global functions
3279
+ * @memberof Box2D
3150
3280
  */
3151
3281
  export class Box2dPlugin {
3152
3282
  /** Create the global UI system object
@@ -3226,6 +3356,7 @@ declare module "littlejsengine" {
3226
3356
  * - Each object has a Box2D body which can have multiple fixtures and joints
3227
3357
  * - Provides interface for Box2D body and fixture functions
3228
3358
  * @extends EngineObject
3359
+ * @memberof Box2D
3229
3360
  */
3230
3361
  export class Box2dObject extends EngineObject {
3231
3362
  /** Create a LittleJS object with Box2d physics
@@ -3455,6 +3586,7 @@ declare module "littlejsengine" {
3455
3586
  * Box2D Joint
3456
3587
  * - Base class for Box2D joints
3457
3588
  * - A joint is used to connect objects together
3589
+ * @memberof Box2D
3458
3590
  */
3459
3591
  export class Box2dJoint {
3460
3592
  /** Create a box2d joint, the base class is not intended to be used directly
@@ -3496,6 +3628,7 @@ declare module "littlejsengine" {
3496
3628
  * - This a soft constraint with a max force
3497
3629
  * - This allows the constraint to stretch and without applying huge forces
3498
3630
  * @extends Box2dJoint
3631
+ * @memberof Box2D
3499
3632
  */
3500
3633
  export class Box2dTargetJoint extends Box2dJoint {
3501
3634
  /** Create a target joint
@@ -3527,6 +3660,7 @@ declare module "littlejsengine" {
3527
3660
  * - Constrains two points on two objects to remain at a fixed distance
3528
3661
  * - You can view this as a massless, rigid rod
3529
3662
  * @extends Box2dJoint
3663
+ * @memberof Box2D
3530
3664
  */
3531
3665
  export class Box2dDistanceJoint extends Box2dJoint {
3532
3666
  /** Create a distance joint
@@ -3565,6 +3699,7 @@ declare module "littlejsengine" {
3565
3699
  * Box2D Pin Joint
3566
3700
  * - Pins two objects together at a point
3567
3701
  * @extends Box2dDistanceJoint
3702
+ * @memberof Box2D
3568
3703
  */
3569
3704
  export class Box2dPinJoint extends Box2dDistanceJoint {
3570
3705
  /** Create a pin joint
@@ -3578,6 +3713,7 @@ declare module "littlejsengine" {
3578
3713
  * Box2D Rope Joint
3579
3714
  * - Enforces a maximum distance between two points on two objects
3580
3715
  * @extends Box2dJoint
3716
+ * @memberof Box2D
3581
3717
  */
3582
3718
  export class Box2dRopeJoint extends Box2dJoint {
3583
3719
  /** Create a rope joint
@@ -3609,6 +3745,7 @@ declare module "littlejsengine" {
3609
3745
  * - You can use a motor to drive the relative rotation about the shared point
3610
3746
  * - A maximum motor torque is provided so that infinite forces are not generated
3611
3747
  * @extends Box2dJoint
3748
+ * @memberof Box2D
3612
3749
  */
3613
3750
  export class Box2dRevoluteJoint extends Box2dJoint {
3614
3751
  /** Create a revolute joint
@@ -3677,6 +3814,7 @@ declare module "littlejsengine" {
3677
3814
  * - Either joint can be a revolute or prismatic joint
3678
3815
  * - You specify a gear ratio to bind the motions together
3679
3816
  * @extends Box2dJoint
3817
+ * @memberof Box2D
3680
3818
  */
3681
3819
  export class Box2dGearJoint extends Box2dJoint {
3682
3820
  /** Create a gear joint
@@ -3708,6 +3846,7 @@ declare module "littlejsengine" {
3708
3846
  * - You can use a joint limit to restrict the range of motion
3709
3847
  * - You can use a joint motor to drive the motion or to model joint friction
3710
3848
  * @extends Box2dJoint
3849
+ * @memberof Box2D
3711
3850
  */
3712
3851
  export class Box2dPrismaticJoint extends Box2dJoint {
3713
3852
  /** Create a prismatic joint
@@ -3781,6 +3920,7 @@ declare module "littlejsengine" {
3781
3920
  * - You can use a joint motor to drive the motion or to model joint friction
3782
3921
  * - This joint is designed for vehicle suspensions
3783
3922
  * @extends Box2dJoint
3923
+ * @memberof Box2D
3784
3924
  */
3785
3925
  export class Box2dWheelJoint extends Box2dJoint {
3786
3926
  /** Create a wheel joint
@@ -3843,6 +3983,7 @@ declare module "littlejsengine" {
3843
3983
  * Box2D Weld Joint
3844
3984
  * - Glues two objects together
3845
3985
  * @extends Box2dJoint
3986
+ * @memberof Box2D
3846
3987
  */
3847
3988
  export class Box2dWeldJoint extends Box2dJoint {
3848
3989
  /** Create a weld joint
@@ -3878,6 +4019,7 @@ declare module "littlejsengine" {
3878
4019
  * - Used to apply top-down friction
3879
4020
  * - Provides 2D translational friction and angular friction
3880
4021
  * @extends Box2dJoint
4022
+ * @memberof Box2D
3881
4023
  */
3882
4024
  export class Box2dFrictionJoint extends Box2dJoint {
3883
4025
  /** Create a friction joint
@@ -3911,6 +4053,7 @@ declare module "littlejsengine" {
3911
4053
  * - The pulley supports a ratio such that: length1 + ratio * length2 <= constant
3912
4054
  * - The force transmitted is scaled by the ratio
3913
4055
  * @extends Box2dJoint
4056
+ * @memberof Box2D
3914
4057
  */
3915
4058
  export class Box2dPulleyJoint extends Box2dJoint {
3916
4059
  /** Create a pulley joint
@@ -3950,6 +4093,7 @@ declare module "littlejsengine" {
3950
4093
  * - Controls the relative motion between two objects
3951
4094
  * - Typical usage is to control the movement of a object with respect to the ground
3952
4095
  * @extends Box2dJoint
4096
+ * @memberof Box2D
3953
4097
  */
3954
4098
  export class Box2dMotorJoint extends Box2dJoint {
3955
4099
  /** Create a motor joint