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