littlejsengine 1.14.11 → 1.14.19
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 +303 -137
- package/dist/littlejs.esm.js +936 -463
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +934 -462
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +859 -417
- package/examples/box2d/game.js +3 -2
- package/examples/box2d/gameObjects.js +2 -2
- package/examples/box2d/tiles.png +0 -0
- package/examples/breakout/game.js +5 -5
- 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 +4 -4
- package/examples/electron/index.html +2 -2
- package/examples/electron/package.json +1 -8
- package/examples/index.html +67 -56
- package/examples/module/game.js +4 -4
- package/examples/platformer/gameEffects.js +5 -5
- 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 +135 -0
- package/examples/shorts/nineSlice.js +34 -15
- package/examples/shorts/parallax.js +5 -4
- 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/shader.js +29 -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 +24 -5
- 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 +4 -4
- package/examples/starter/index.html +2 -2
- package/examples/style.css +1 -0
- package/examples/typescript/game.js +4 -4
- package/examples/typescript/game.ts +4 -4
- package/examples/uiSystem/game.js +4 -3
- package/package.json +4 -2
- package/plugins/box2d.js +17 -2
- package/plugins/newgrounds.js +7 -5
- package/plugins/postProcess.js +76 -53
- package/plugins/uiSystem.js +192 -53
- package/plugins/zzfxm.js +5 -1
- package/reference.md +1 -1
- package/src/engine.js +60 -23
- package/src/engineAudio.js +44 -17
- package/src/engineDebug.js +75 -45
- package/src/engineDraw.js +94 -59
- package/src/engineExport.js +2 -1
- package/src/engineMedals.js +10 -2
- package/src/engineObject.js +14 -10
- package/src/engineParticles.js +60 -47
- package/src/engineSettings.js +7 -7
- package/src/engineTileLayer.js +73 -56
- package/src/engineUtilities.js +67 -20
- package/src/engineWebGL.js +134 -63
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,17 @@ 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} [update]
|
|
169
|
+
* @param {PluginCallback} [render]
|
|
170
|
+
* @param {PluginCallback} [glContextLost]
|
|
171
|
+
* @param {PluginCallback} [glContextRestored]
|
|
120
172
|
* @memberof Engine */
|
|
121
|
-
export function engineAddPlugin(
|
|
173
|
+
export function engineAddPlugin(update?: PluginCallback, render?: PluginCallback, glContextLost?: PluginCallback, glContextRestored?: PluginCallback): void;
|
|
122
174
|
/**
|
|
123
175
|
* LittleJS Debug System
|
|
124
176
|
* - Press Esc to show debug overlay with mouse pick
|
|
@@ -144,6 +196,7 @@ declare module "littlejsengine" {
|
|
|
144
196
|
* @memberof Debug */
|
|
145
197
|
export let showWatermark: boolean;
|
|
146
198
|
/** Asserts if the expression is false, does nothing in release builds
|
|
199
|
+
* Halts execution if the assert fails and throws an error
|
|
147
200
|
* @param {boolean} assert
|
|
148
201
|
* @param {...Object} [output] - error message output
|
|
149
202
|
* @memberof Debug */
|
|
@@ -155,62 +208,62 @@ declare module "littlejsengine" {
|
|
|
155
208
|
/** Draw a debug rectangle in world space
|
|
156
209
|
* @param {Vector2} pos
|
|
157
210
|
* @param {Vector2} [size=Vector2()]
|
|
158
|
-
* @param {string}
|
|
159
|
-
* @param {number}
|
|
160
|
-
* @param {number}
|
|
211
|
+
* @param {Color|string} [color]
|
|
212
|
+
* @param {number} [time]
|
|
213
|
+
* @param {number} [angle]
|
|
161
214
|
* @param {boolean} [fill]
|
|
162
215
|
* @memberof Debug */
|
|
163
|
-
export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
|
|
216
|
+
export function debugRect(pos: Vector2, size?: Vector2, color?: Color | string, time?: number, angle?: number, fill?: boolean): void;
|
|
164
217
|
/** Draw a debug poly in world space
|
|
165
218
|
* @param {Vector2} pos
|
|
166
219
|
* @param {Array<Vector2>} points
|
|
167
|
-
* @param {string}
|
|
168
|
-
* @param {number}
|
|
169
|
-
* @param {number}
|
|
220
|
+
* @param {Color|string} [color]
|
|
221
|
+
* @param {number} [time]
|
|
222
|
+
* @param {number} [angle]
|
|
170
223
|
* @param {boolean} [fill]
|
|
171
224
|
* @memberof Debug */
|
|
172
|
-
export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: string, time?: number, angle?: number, fill?: boolean): void;
|
|
225
|
+
export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: Color | string, time?: number, angle?: number, fill?: boolean): void;
|
|
173
226
|
/** Draw a debug circle in world space
|
|
174
227
|
* @param {Vector2} pos
|
|
175
|
-
* @param {number}
|
|
176
|
-
* @param {string}
|
|
177
|
-
* @param {number}
|
|
228
|
+
* @param {number} [size] - diameter
|
|
229
|
+
* @param {Color|string} [color]
|
|
230
|
+
* @param {number} [time]
|
|
178
231
|
* @param {boolean} [fill]
|
|
179
232
|
* @memberof Debug */
|
|
180
|
-
export function debugCircle(pos: Vector2, size?: number, color?: string, time?: number, fill?: boolean): void;
|
|
233
|
+
export function debugCircle(pos: Vector2, size?: number, color?: Color | string, time?: number, fill?: boolean): void;
|
|
181
234
|
/** Draw a debug point in world space
|
|
182
235
|
* @param {Vector2} pos
|
|
183
|
-
* @param {string}
|
|
184
|
-
* @param {number}
|
|
185
|
-
* @param {number}
|
|
236
|
+
* @param {Color|string} [color]
|
|
237
|
+
* @param {number} [time]
|
|
238
|
+
* @param {number} [angle]
|
|
186
239
|
* @memberof Debug */
|
|
187
|
-
export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
|
|
240
|
+
export function debugPoint(pos: Vector2, color?: Color | string, time?: number, angle?: number): void;
|
|
188
241
|
/** Draw a debug line in world space
|
|
189
242
|
* @param {Vector2} posA
|
|
190
243
|
* @param {Vector2} posB
|
|
191
|
-
* @param {string}
|
|
192
|
-
* @param {number}
|
|
193
|
-
* @param {number}
|
|
244
|
+
* @param {Color|string} [color]
|
|
245
|
+
* @param {number} [width]
|
|
246
|
+
* @param {number} [time]
|
|
194
247
|
* @memberof Debug */
|
|
195
|
-
export function debugLine(posA: Vector2, posB: Vector2, color?: string, width?: number, time?: number): void;
|
|
248
|
+
export function debugLine(posA: Vector2, posB: Vector2, color?: Color | string, width?: number, time?: number): void;
|
|
196
249
|
/** Draw a debug combined axis aligned bounding box in world space
|
|
197
250
|
* @param {Vector2} posA
|
|
198
251
|
* @param {Vector2} sizeA
|
|
199
252
|
* @param {Vector2} posB
|
|
200
253
|
* @param {Vector2} sizeB
|
|
201
|
-
* @param {string}
|
|
254
|
+
* @param {Color|string} [color]
|
|
202
255
|
* @memberof Debug */
|
|
203
|
-
export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: string): void;
|
|
256
|
+
export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: Color | string): void;
|
|
204
257
|
/** Draw a debug axis aligned bounding box in world space
|
|
205
|
-
* @param {string}
|
|
258
|
+
* @param {string} text
|
|
206
259
|
* @param {Vector2} pos
|
|
207
|
-
* @param {number}
|
|
208
|
-
* @param {string}
|
|
209
|
-
* @param {number}
|
|
210
|
-
* @param {number}
|
|
211
|
-
* @param {string}
|
|
260
|
+
* @param {number} [size]
|
|
261
|
+
* @param {Color|string} [color]
|
|
262
|
+
* @param {number} [time]
|
|
263
|
+
* @param {number} [angle]
|
|
264
|
+
* @param {string} [font]
|
|
212
265
|
* @memberof Debug */
|
|
213
|
-
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
266
|
+
export function debugText(text: string, pos: Vector2, size?: number, color?: Color | string, time?: number, angle?: number, font?: string): void;
|
|
214
267
|
/** Clear all debug primitives in the list
|
|
215
268
|
* @memberof Debug */
|
|
216
269
|
export function debugClear(): void;
|
|
@@ -234,7 +287,9 @@ declare module "littlejsengine" {
|
|
|
234
287
|
* @param {string} filename
|
|
235
288
|
* @memberof Debug */
|
|
236
289
|
export function debugSaveDataURL(dataURL: string, filename: string): void;
|
|
237
|
-
/**
|
|
290
|
+
/** Breaks on all asserts/errors, hides the canvas, and shows message in plain text
|
|
291
|
+
* This is a good function to call at the start of your game to catch all errors
|
|
292
|
+
* In release builds this function has no effect
|
|
238
293
|
* @memberof Debug */
|
|
239
294
|
export function debugShowErrors(): void;
|
|
240
295
|
/** Check if video capture is active
|
|
@@ -812,6 +867,7 @@ declare module "littlejsengine" {
|
|
|
812
867
|
/**
|
|
813
868
|
* Seeded random number generator
|
|
814
869
|
* - Can be used to create a deterministic random number sequence
|
|
870
|
+
* @memberof Engine
|
|
815
871
|
* @example
|
|
816
872
|
* let r = new RandomGenerator(123); // random number generator with seed 123
|
|
817
873
|
* let a = r.float(); // random value between 0 and 1
|
|
@@ -859,6 +915,7 @@ declare module "littlejsengine" {
|
|
|
859
915
|
/**
|
|
860
916
|
* 2D Vector object with vector math library
|
|
861
917
|
* - Functions do not change this so they can be chained together
|
|
918
|
+
* @memberof Engine
|
|
862
919
|
* @example
|
|
863
920
|
* let a = new Vector2(2, 3); // vector with coordinates (2, 3)
|
|
864
921
|
* let b = new Vector2; // vector with coordinates (0, 0)
|
|
@@ -949,9 +1006,10 @@ declare module "littlejsengine" {
|
|
|
949
1006
|
* @param {number} angle
|
|
950
1007
|
* @return {Vector2} */
|
|
951
1008
|
rotate(angle: number): Vector2;
|
|
952
|
-
/**
|
|
1009
|
+
/** Sets this this vector to point in the specified integer direction (0-3), corresponding to multiples of 90 degree rotation
|
|
953
1010
|
* @param {number} [direction]
|
|
954
|
-
* @param {number} [length]
|
|
1011
|
+
* @param {number} [length]
|
|
1012
|
+
* @return {Vector2} */
|
|
955
1013
|
setDirection(direction?: number, length?: number): Vector2;
|
|
956
1014
|
/** Returns the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)
|
|
957
1015
|
* @return {number} */
|
|
@@ -988,6 +1046,7 @@ declare module "littlejsengine" {
|
|
|
988
1046
|
}
|
|
989
1047
|
/**
|
|
990
1048
|
* Color object (red, green, blue, alpha) with some helpful functions
|
|
1049
|
+
* @memberof Engine
|
|
991
1050
|
* @example
|
|
992
1051
|
* let a = new Color; // white
|
|
993
1052
|
* let b = new Color(1, 0, 0); // red
|
|
@@ -1081,6 +1140,7 @@ declare module "littlejsengine" {
|
|
|
1081
1140
|
}
|
|
1082
1141
|
/**
|
|
1083
1142
|
* Timer object tracks how long has passed since it was set
|
|
1143
|
+
* @memberof Engine
|
|
1084
1144
|
* @example
|
|
1085
1145
|
* let a = new Timer; // creates a timer that is not set
|
|
1086
1146
|
* a.set(3); // sets the timer to 3 seconds
|
|
@@ -1172,11 +1232,17 @@ declare module "littlejsengine" {
|
|
|
1172
1232
|
* @return {boolean}
|
|
1173
1233
|
* @memberof Utilities */
|
|
1174
1234
|
export function isNumber(n: any): boolean;
|
|
1235
|
+
/**
|
|
1236
|
+
* Check if object is a valid string or can be converted to one
|
|
1237
|
+
* @param {any} s
|
|
1238
|
+
* @return {boolean}
|
|
1239
|
+
* @memberof Utilities */
|
|
1240
|
+
export function isString(s: any): boolean;
|
|
1175
1241
|
/** Color - White #ffffff
|
|
1176
1242
|
* @type {Color}
|
|
1177
1243
|
* @memberof Utilities */
|
|
1178
1244
|
export const WHITE: Color;
|
|
1179
|
-
/** Color - Clear White #
|
|
1245
|
+
/** Color - Clear White #757474ff with 0 alpha
|
|
1180
1246
|
* @type {Color}
|
|
1181
1247
|
* @memberof Utilities */
|
|
1182
1248
|
export const CLEAR_WHITE: Color;
|
|
@@ -1228,7 +1294,7 @@ declare module "littlejsengine" {
|
|
|
1228
1294
|
* Create a tile info object using a grid based system
|
|
1229
1295
|
* - This can take vecs or floats for easier use and conversion
|
|
1230
1296
|
* - If an index is passed in, the tile size and index will determine the position
|
|
1231
|
-
* @param {Vector2|number} [pos=0] -
|
|
1297
|
+
* @param {Vector2|number} [pos=0] - Position of the tile in pixels, or tile index
|
|
1232
1298
|
* @param {Vector2|number} [size=tileSizeDefault] - Size of tile in pixels
|
|
1233
1299
|
* @param {number} [textureIndex] - Texture index to use
|
|
1234
1300
|
* @param {number} [padding] - How many pixels padding around tiles
|
|
@@ -1242,6 +1308,7 @@ declare module "littlejsengine" {
|
|
|
1242
1308
|
export function tile(pos?: Vector2 | number, size?: Vector2 | number, textureIndex?: number, padding?: number): TileInfo;
|
|
1243
1309
|
/**
|
|
1244
1310
|
* Tile Info - Stores info about how to draw a tile
|
|
1311
|
+
* @memberof Draw
|
|
1245
1312
|
*/
|
|
1246
1313
|
export class TileInfo {
|
|
1247
1314
|
/** Create a tile info object
|
|
@@ -1275,30 +1342,38 @@ declare module "littlejsengine" {
|
|
|
1275
1342
|
*/
|
|
1276
1343
|
frame(frame: number): TileInfo;
|
|
1277
1344
|
/**
|
|
1278
|
-
* Set this tile to use a full image
|
|
1279
|
-
* @param {
|
|
1280
|
-
* @param {WebGLTexture} [glTexture] - WebGL texture
|
|
1345
|
+
* Set this tile to use a full image in a texture info
|
|
1346
|
+
* @param {TextureInfo} textureInfo
|
|
1281
1347
|
* @return {TileInfo}
|
|
1282
1348
|
*/
|
|
1283
|
-
setFullImage(
|
|
1349
|
+
setFullImage(textureInfo: TextureInfo): TileInfo;
|
|
1284
1350
|
}
|
|
1285
|
-
/**
|
|
1351
|
+
/**
|
|
1352
|
+
* Tile Info - Stores info about each texture
|
|
1353
|
+
* @memberof Draw
|
|
1354
|
+
*/
|
|
1286
1355
|
export class TextureInfo {
|
|
1287
1356
|
/**
|
|
1288
1357
|
* Create a TextureInfo, called automatically by the engine
|
|
1289
1358
|
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1290
|
-
* @param {
|
|
1359
|
+
* @param {boolean} [useWebGL] - Should use WebGL if available?
|
|
1291
1360
|
*/
|
|
1292
|
-
constructor(image: HTMLImageElement | OffscreenCanvas,
|
|
1293
|
-
/** @property {HTMLImageElement} - image source */
|
|
1361
|
+
constructor(image: HTMLImageElement | OffscreenCanvas, useWebGL?: boolean);
|
|
1362
|
+
/** @property {HTMLImageElement|OffscreenCanvas} - image source */
|
|
1294
1363
|
image: OffscreenCanvas | HTMLImageElement;
|
|
1295
1364
|
/** @property {Vector2} - size of the image */
|
|
1296
1365
|
size: Vector2;
|
|
1297
1366
|
/** @property {Vector2} - inverse of the size, cached for rendering */
|
|
1298
1367
|
sizeInverse: Vector2;
|
|
1299
1368
|
/** @property {WebGLTexture} - WebGL texture */
|
|
1300
|
-
glTexture:
|
|
1369
|
+
glTexture: any;
|
|
1370
|
+
/** Creates the WebGL texture, updates if already created */
|
|
1301
1371
|
createWebGLTexture(): void;
|
|
1372
|
+
/** Destroys the WebGL texture */
|
|
1373
|
+
destroyWebGLTexture(): void;
|
|
1374
|
+
/** Check if the texture is webgl enabled
|
|
1375
|
+
* @return {boolean} */
|
|
1376
|
+
hasWebGL(): boolean;
|
|
1302
1377
|
}
|
|
1303
1378
|
/**
|
|
1304
1379
|
* LittleJS Drawing System
|
|
@@ -1460,16 +1535,21 @@ declare module "littlejsengine" {
|
|
|
1460
1535
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1461
1536
|
* @memberof Draw */
|
|
1462
1537
|
export function drawCircle(pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1538
|
+
/**
|
|
1539
|
+
* @callback Canvas2DDrawFunction - A function that draws to a 2D canvas context
|
|
1540
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1541
|
+
* @memberof Draw
|
|
1542
|
+
*/
|
|
1463
1543
|
/** Draw directly to a 2d canvas context in world space
|
|
1464
1544
|
* @param {Vector2} pos
|
|
1465
1545
|
* @param {Vector2} size
|
|
1466
1546
|
* @param {number} angle
|
|
1467
1547
|
* @param {boolean} [mirror]
|
|
1468
|
-
* @param {
|
|
1548
|
+
* @param {Canvas2DDrawFunction} [drawFunction]
|
|
1469
1549
|
* @param {boolean} [screenSpace=false]
|
|
1470
1550
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1471
1551
|
* @memberof Draw */
|
|
1472
|
-
export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?:
|
|
1552
|
+
export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?: Canvas2DDrawFunction, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1473
1553
|
/** Draw text on main canvas in world space
|
|
1474
1554
|
* Automatically splits new lines into rows
|
|
1475
1555
|
* @param {string} text
|
|
@@ -1480,10 +1560,11 @@ declare module "littlejsengine" {
|
|
|
1480
1560
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1481
1561
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1482
1562
|
* @param {string} [font=fontDefault]
|
|
1563
|
+
* @param {string} [fontStyle]
|
|
1483
1564
|
* @param {number} [maxWidth]
|
|
1484
1565
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1485
1566
|
* @memberof Draw */
|
|
1486
|
-
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1567
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1487
1568
|
/** Draw text on overlay canvas in world space
|
|
1488
1569
|
* Automatically splits new lines into rows
|
|
1489
1570
|
* @param {string} text
|
|
@@ -1494,9 +1575,10 @@ declare module "littlejsengine" {
|
|
|
1494
1575
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1495
1576
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1496
1577
|
* @param {string} [font=fontDefault]
|
|
1578
|
+
* @param {string} [fontStyle]
|
|
1497
1579
|
* @param {number} [maxWidth]
|
|
1498
1580
|
* @memberof Draw */
|
|
1499
|
-
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number): void;
|
|
1581
|
+
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number): void;
|
|
1500
1582
|
/** Draw text on overlay canvas in screen space
|
|
1501
1583
|
* Automatically splits new lines into rows
|
|
1502
1584
|
* @param {string} text
|
|
@@ -1507,10 +1589,11 @@ declare module "littlejsengine" {
|
|
|
1507
1589
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1508
1590
|
* @param {CanvasTextAlign} [textAlign]
|
|
1509
1591
|
* @param {string} [font=fontDefault]
|
|
1592
|
+
* @param {string} [fontStyle]
|
|
1510
1593
|
* @param {number} [maxWidth]
|
|
1511
1594
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1512
1595
|
* @memberof Draw */
|
|
1513
|
-
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1596
|
+
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1514
1597
|
/** Enable normal or additive blend mode
|
|
1515
1598
|
* @param {boolean} [additive]
|
|
1516
1599
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1526,6 +1609,7 @@ declare module "littlejsengine" {
|
|
|
1526
1609
|
* - 96 characters (from space to tilde) are stored in an image
|
|
1527
1610
|
* - Uses a default 8x8 font if none is supplied
|
|
1528
1611
|
* - You can also use fonts from the main tile sheet
|
|
1612
|
+
* @memberof Draw
|
|
1529
1613
|
* @example
|
|
1530
1614
|
* // use built in font
|
|
1531
1615
|
* const font = new FontImage;
|
|
@@ -1535,11 +1619,11 @@ declare module "littlejsengine" {
|
|
|
1535
1619
|
*/
|
|
1536
1620
|
export class FontImage {
|
|
1537
1621
|
/** Create an image font
|
|
1538
|
-
* @param {HTMLImageElement} [image]
|
|
1539
|
-
* @param {Vector2} [tileSize=(8,8)]
|
|
1540
|
-
* @param {Vector2} [paddingSize=(0,1)] - How much
|
|
1622
|
+
* @param {HTMLImageElement} [image] - Image for the font, default if undefined
|
|
1623
|
+
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1624
|
+
* @param {Vector2} [paddingSize=(0,1)] - How much space between characters
|
|
1541
1625
|
*/
|
|
1542
|
-
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2
|
|
1626
|
+
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2);
|
|
1543
1627
|
image: any;
|
|
1544
1628
|
tileSize: Vector2;
|
|
1545
1629
|
paddingSize: Vector2;
|
|
@@ -1876,6 +1960,7 @@ declare module "littlejsengine" {
|
|
|
1876
1960
|
* Sound Object - Stores a sound for later use and can be played positionally
|
|
1877
1961
|
*
|
|
1878
1962
|
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1963
|
+
* @memberof Audio
|
|
1879
1964
|
* @example
|
|
1880
1965
|
* // create a sound
|
|
1881
1966
|
* const sound_example = new Sound([.5,.5]);
|
|
@@ -1921,12 +2006,12 @@ declare module "littlejsengine" {
|
|
|
1921
2006
|
playMusic(volume?: number, loop?: boolean, paused?: boolean): SoundInstance;
|
|
1922
2007
|
/** Play the sound as a musical note with a semitone offset
|
|
1923
2008
|
* This can be used to play music with chromatic scales
|
|
1924
|
-
* @param {number} semitoneOffset - How many semitones to offset pitch
|
|
2009
|
+
* @param {number} [semitoneOffset=0] - How many semitones to offset pitch
|
|
1925
2010
|
* @param {Vector2} [pos] - World space position to play the sound if any
|
|
1926
2011
|
* @param {number} [volume=1] - How much to scale volume by
|
|
1927
2012
|
* @return {SoundInstance} - The audio source node
|
|
1928
2013
|
*/
|
|
1929
|
-
playNote(semitoneOffset
|
|
2014
|
+
playNote(semitoneOffset?: number, pos?: Vector2, volume?: number): SoundInstance;
|
|
1930
2015
|
/** Get how long this sound is in seconds
|
|
1931
2016
|
* @return {number} - How long the sound is in seconds (undefined if loading)
|
|
1932
2017
|
*/
|
|
@@ -1939,6 +2024,8 @@ declare module "littlejsengine" {
|
|
|
1939
2024
|
/**
|
|
1940
2025
|
* Sound Wave Object - Stores a wave sound for later use and can be played positionally
|
|
1941
2026
|
* - this can be used to play wave, mp3, and ogg files
|
|
2027
|
+
* @extends Sound
|
|
2028
|
+
* @memberof Audio
|
|
1942
2029
|
* @example
|
|
1943
2030
|
* // create a sound
|
|
1944
2031
|
* const sound_example = new SoundWave('sound.mp3');
|
|
@@ -1947,16 +2034,21 @@ declare module "littlejsengine" {
|
|
|
1947
2034
|
* sound_example.play();
|
|
1948
2035
|
*/
|
|
1949
2036
|
export class SoundWave extends Sound {
|
|
2037
|
+
/**
|
|
2038
|
+
* @callback SoundLoadCallback - Function called when sound is loaded
|
|
2039
|
+
* @param {SoundWave} sound
|
|
2040
|
+
* @memberof Audio
|
|
2041
|
+
*/
|
|
1950
2042
|
/** Create a sound object and cache the wave file for later use
|
|
1951
2043
|
* @param {string} filename - Filename of audio file to load
|
|
1952
2044
|
* @param {number} [randomness] - How much to randomize frequency each time sound plays
|
|
1953
2045
|
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
1954
2046
|
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
1955
|
-
* @param {
|
|
2047
|
+
* @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
|
|
1956
2048
|
*/
|
|
1957
|
-
constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?:
|
|
1958
|
-
/** @property {
|
|
1959
|
-
onloadCallback:
|
|
2049
|
+
constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: (sound: SoundWave) => SoundWave);
|
|
2050
|
+
/** @property {SoundLoadCallback} - callback function to call when sound is loaded */
|
|
2051
|
+
onloadCallback: (sound: SoundWave) => SoundWave;
|
|
1960
2052
|
/** Loads a sound from a URL and decodes it into sample data. Must be used with await!
|
|
1961
2053
|
* @param {string} filename
|
|
1962
2054
|
* @return {Promise<void>} */
|
|
@@ -1965,6 +2057,7 @@ declare module "littlejsengine" {
|
|
|
1965
2057
|
/**
|
|
1966
2058
|
* Sound Instance - Wraps an AudioBufferSourceNode for individual sound control
|
|
1967
2059
|
* Represents a single playing instance of a sound with pause/resume capabilities
|
|
2060
|
+
* @memberof Audio
|
|
1968
2061
|
* @example
|
|
1969
2062
|
* // Play a sound and get an instance for control
|
|
1970
2063
|
* const jumpSound = new Sound([.5,.5,220]);
|
|
@@ -2056,6 +2149,11 @@ declare module "littlejsengine" {
|
|
|
2056
2149
|
* @return {number} - The frequency of the note
|
|
2057
2150
|
* @memberof Audio */
|
|
2058
2151
|
export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
|
|
2152
|
+
/**
|
|
2153
|
+
* @callback AudioEndedCallback - Function called when a sound ends
|
|
2154
|
+
* @param {AudioBufferSourceNode} source
|
|
2155
|
+
* @memberof Audio
|
|
2156
|
+
*/
|
|
2059
2157
|
/** Play cached audio samples with given settings
|
|
2060
2158
|
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
|
|
2061
2159
|
* @param {number} [volume] - How much to scale volume by
|
|
@@ -2065,10 +2163,10 @@ declare module "littlejsengine" {
|
|
|
2065
2163
|
* @param {number} [sampleRate=44100] - Sample rate for the sound
|
|
2066
2164
|
* @param {GainNode} [gainNode] - Optional gain node for volume control while playing
|
|
2067
2165
|
* @param {number} [offset] - Offset in seconds to start playback from
|
|
2068
|
-
* @param {
|
|
2069
|
-
* @return {AudioBufferSourceNode} - The
|
|
2166
|
+
* @param {AudioEndedCallback} [onended] - Callback for when the sound ends
|
|
2167
|
+
* @return {AudioBufferSourceNode} - The source node of the sound played, may be undefined if play fails
|
|
2070
2168
|
* @memberof Audio */
|
|
2071
|
-
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode, offset?: number, onended?:
|
|
2169
|
+
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode, offset?: number, onended?: AudioEndedCallback): AudioBufferSourceNode;
|
|
2072
2170
|
/** Generate and play a ZzFX sound
|
|
2073
2171
|
*
|
|
2074
2172
|
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
@@ -2124,6 +2222,7 @@ declare module "littlejsengine" {
|
|
|
2124
2222
|
* - Collision for objects can be set to be solid to block other objects
|
|
2125
2223
|
* - Objects may get pushed into overlapping other solid objects, if so they will push away
|
|
2126
2224
|
* - Solid objects are more performance intensive and should be used sparingly
|
|
2225
|
+
* @memberof Engine
|
|
2127
2226
|
* @example
|
|
2128
2227
|
* // create an engine object, normally you would first extend the class with your own
|
|
2129
2228
|
* const pos = vec2(2,3);
|
|
@@ -2131,12 +2230,12 @@ declare module "littlejsengine" {
|
|
|
2131
2230
|
*/
|
|
2132
2231
|
export class EngineObject {
|
|
2133
2232
|
/** 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]
|
|
2233
|
+
* @param {Vector2} [pos=(0,0)] - World space position of the object
|
|
2234
|
+
* @param {Vector2} [size=(1,1)] - World space size of the object
|
|
2235
|
+
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
|
|
2236
|
+
* @param {number} [angle] - Angle the object is rotated by
|
|
2237
|
+
* @param {Color} [color=WHITE] - Color to apply to tile when rendered
|
|
2238
|
+
* @param {number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
2140
2239
|
*/
|
|
2141
2240
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
2142
2241
|
/** @property {Vector2} - World space position of the object */
|
|
@@ -2201,7 +2300,7 @@ declare module "littlejsengine" {
|
|
|
2201
2300
|
update(): void;
|
|
2202
2301
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
2203
2302
|
render(): void;
|
|
2204
|
-
/** Destroy this object, destroy its children, detach
|
|
2303
|
+
/** Destroy this object, destroy its children, detach its parent, and mark it for removal */
|
|
2205
2304
|
destroy(): void;
|
|
2206
2305
|
destroyed: number;
|
|
2207
2306
|
/** Convert from local space to world space
|
|
@@ -2267,16 +2366,16 @@ declare module "littlejsengine" {
|
|
|
2267
2366
|
* - Unlimited numbers of layers, allocates canvases as needed
|
|
2268
2367
|
* - Tile layers can be drawn to using their context with canvas2d
|
|
2269
2368
|
* - Tile layers can also have collision with EngineObjects
|
|
2270
|
-
* @namespace
|
|
2369
|
+
* @namespace TileLayers
|
|
2271
2370
|
*/
|
|
2272
2371
|
/** Keep track of all tile layers with collision
|
|
2273
2372
|
* @type {Array<TileCollisionLayer>}
|
|
2274
|
-
* @memberof
|
|
2373
|
+
* @memberof TileLayers */
|
|
2275
2374
|
export const tileCollisionLayers: Array<TileCollisionLayer>;
|
|
2276
2375
|
/** Get tile collision data for a given cell in the grid
|
|
2277
2376
|
* @param {Vector2} pos
|
|
2278
2377
|
* @return {number}
|
|
2279
|
-
* @memberof
|
|
2378
|
+
* @memberof TileLayers */
|
|
2280
2379
|
export function tileCollisionGetData(pos: Vector2): number;
|
|
2281
2380
|
/** Check if a tile layer collides with another object
|
|
2282
2381
|
* @param {Vector2} pos
|
|
@@ -2284,7 +2383,7 @@ declare module "littlejsengine" {
|
|
|
2284
2383
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2285
2384
|
* @param {boolean} [solidOnly] - Only check solid layers if true
|
|
2286
2385
|
* @return {TileCollisionLayer}
|
|
2287
|
-
* @memberof
|
|
2386
|
+
* @memberof TileLayers */
|
|
2288
2387
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
|
|
2289
2388
|
/** Return the center of first tile hit, undefined if nothing was hit.
|
|
2290
2389
|
* This does not return the exact intersection, but the center of the tile hit.
|
|
@@ -2293,7 +2392,7 @@ declare module "littlejsengine" {
|
|
|
2293
2392
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2294
2393
|
* @param {boolean} [solidOnly=true] - Only check solid layers if true
|
|
2295
2394
|
* @return {Vector2}
|
|
2296
|
-
* @memberof
|
|
2395
|
+
* @memberof TileLayers */
|
|
2297
2396
|
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, solidOnly?: boolean): Vector2;
|
|
2298
2397
|
/**
|
|
2299
2398
|
* Load tile layers from exported data
|
|
@@ -2303,10 +2402,11 @@ declare module "littlejsengine" {
|
|
|
2303
2402
|
* @param {number} [collisionLayer] - Layer to use for collision if any
|
|
2304
2403
|
* @param {boolean} [draw] - Should the layer be drawn automatically
|
|
2305
2404
|
* @return {Array<TileCollisionLayer>}
|
|
2306
|
-
* @memberof
|
|
2307
|
-
export function
|
|
2405
|
+
* @memberof TileLayers */
|
|
2406
|
+
export function tileLayersLoad(tileMapData: any, tileInfo?: TileInfo, renderOrder?: number, collisionLayer?: number, draw?: boolean): Array<TileCollisionLayer>;
|
|
2308
2407
|
/**
|
|
2309
2408
|
* Tile layer data object stores info about how to draw a tile
|
|
2409
|
+
* @memberof TileLayers
|
|
2310
2410
|
* @example
|
|
2311
2411
|
* // create tile layer data with tile index 0 and random orientation and color
|
|
2312
2412
|
* const tileIndex = 0;
|
|
@@ -2338,6 +2438,7 @@ declare module "littlejsengine" {
|
|
|
2338
2438
|
* - Contains an offscreen canvas that can be rendered to
|
|
2339
2439
|
* - WebGL rendering is optional, call useWebGL to enable
|
|
2340
2440
|
* @extends EngineObject
|
|
2441
|
+
* @memberof TileLayers
|
|
2341
2442
|
* @example
|
|
2342
2443
|
* const canvasLayer = new CanvasLayer(vec2(), vec2(200,100));
|
|
2343
2444
|
*/
|
|
@@ -2354,8 +2455,7 @@ declare module "littlejsengine" {
|
|
|
2354
2455
|
canvas: OffscreenCanvas;
|
|
2355
2456
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2356
2457
|
context: OffscreenCanvasRenderingContext2D;
|
|
2357
|
-
|
|
2358
|
-
glTexture: WebGLTexture;
|
|
2458
|
+
textureInfo: TextureInfo;
|
|
2359
2459
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2360
2460
|
* @param {Vector2} pos - Center in world space
|
|
2361
2461
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2367,13 +2467,18 @@ declare module "littlejsengine" {
|
|
|
2367
2467
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2368
2468
|
* @memberof Draw */
|
|
2369
2469
|
draw(pos: Vector2, size?: Vector2, angle?: number, color?: Color, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2470
|
+
/**
|
|
2471
|
+
* @callback Canvas2DDrawCallback - Function that draws to a canvas 2D context
|
|
2472
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
2473
|
+
* @memberof TileLayers
|
|
2474
|
+
*/
|
|
2370
2475
|
/** Draw onto the layer canvas in world space (bypass WebGL)
|
|
2371
2476
|
* @param {Vector2} pos
|
|
2372
2477
|
* @param {Vector2} size
|
|
2373
2478
|
* @param {number} angle
|
|
2374
2479
|
* @param {boolean} mirror
|
|
2375
|
-
* @param {
|
|
2376
|
-
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction:
|
|
2480
|
+
* @param {Canvas2DDrawCallback} drawFunction */
|
|
2481
|
+
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: (context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D) => any): void;
|
|
2377
2482
|
/** Draw a tile onto the layer canvas in world space
|
|
2378
2483
|
* @param {Vector2} pos
|
|
2379
2484
|
* @param {Vector2} [size=(1,1)]
|
|
@@ -2398,7 +2503,9 @@ declare module "littlejsengine" {
|
|
|
2398
2503
|
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
2399
2504
|
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
2400
2505
|
* - For with 16x16 tiles this limits layers to 256x256 on mobile devices
|
|
2506
|
+
* - Tile layers are centered on their corner, so normal levels are at (0,0)
|
|
2401
2507
|
* @extends CanvasLayer
|
|
2508
|
+
* @memberof TileLayers
|
|
2402
2509
|
* @example
|
|
2403
2510
|
* const tileLayer = new TileLayer(vec2(), vec2(200,100));
|
|
2404
2511
|
*/
|
|
@@ -2407,11 +2514,9 @@ declare module "littlejsengine" {
|
|
|
2407
2514
|
* @param {Vector2} position - World space position
|
|
2408
2515
|
* @param {Vector2} size - World space size
|
|
2409
2516
|
* @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
2517
|
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2412
|
-
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
2413
2518
|
*/
|
|
2414
|
-
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo,
|
|
2519
|
+
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number);
|
|
2415
2520
|
data: TileLayerData[];
|
|
2416
2521
|
/** Draw all the tile data to an offscreen canvas
|
|
2417
2522
|
* - This may be slow in some browsers but only needs to be done once */
|
|
@@ -2447,16 +2552,9 @@ declare module "littlejsengine" {
|
|
|
2447
2552
|
* - there can be multiple tile collision layers
|
|
2448
2553
|
* - tile collision layers should not overlap each other
|
|
2449
2554
|
* @extends TileLayer
|
|
2555
|
+
* @memberof TileLayers
|
|
2450
2556
|
*/
|
|
2451
2557
|
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
2558
|
/** @property {Array<number>} - The tile collision grid */
|
|
2461
2559
|
collisionData: any[];
|
|
2462
2560
|
/** Clear and initialize tile collision to new size
|
|
@@ -2487,9 +2585,15 @@ declare module "littlejsengine" {
|
|
|
2487
2585
|
/**
|
|
2488
2586
|
* LittleJS Particle System
|
|
2489
2587
|
*/
|
|
2588
|
+
/**
|
|
2589
|
+
* @callback ParticleCallbackFunction - Function that processes a particle
|
|
2590
|
+
* @param {Particle} particle
|
|
2591
|
+
* @memberof Engine
|
|
2592
|
+
*/
|
|
2490
2593
|
/**
|
|
2491
2594
|
* Particle Emitter - Spawns particles with the given settings
|
|
2492
2595
|
* @extends EngineObject
|
|
2596
|
+
* @memberof Engine
|
|
2493
2597
|
* @example
|
|
2494
2598
|
* // create a particle emitter
|
|
2495
2599
|
* let pos = vec2(2,3);
|
|
@@ -2499,7 +2603,7 @@ declare module "littlejsengine" {
|
|
|
2499
2603
|
* tile(0, 16), // tileInfo
|
|
2500
2604
|
* rgb(1,1,1,1), rgb(0,0,0,1), // colorStartA, colorStartB
|
|
2501
2605
|
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
2502
|
-
*
|
|
2606
|
+
* 1, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
2503
2607
|
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
2504
2608
|
* .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
2505
2609
|
* );
|
|
@@ -2513,10 +2617,10 @@ declare module "littlejsengine" {
|
|
|
2513
2617
|
* @param {number} [emitRate] - How many particles per second to spawn, does not emit if 0
|
|
2514
2618
|
* @param {number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
2515
2619
|
* @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=
|
|
2620
|
+
* @param {Color} [colorStartA=WHITE] - Color at start of life 1, randomized between start colors
|
|
2621
|
+
* @param {Color} [colorStartB=WHITE] - Color at start of life 2, randomized between start colors
|
|
2622
|
+
* @param {Color} [colorEndA=CLEAR_WHITE] - Color at end of life 1, randomized between end colors
|
|
2623
|
+
* @param {Color} [colorEndB=CLEAR_WHITE] - Color at end of life 2, randomized between end colors
|
|
2520
2624
|
* @param {number} [particleTime] - How long particles live
|
|
2521
2625
|
* @param {number} [sizeStart] - How big are particles at start
|
|
2522
2626
|
* @param {number} [sizeEnd] - How big are particles at end
|
|
@@ -2575,9 +2679,9 @@ declare module "littlejsengine" {
|
|
|
2575
2679
|
localSpace: boolean;
|
|
2576
2680
|
/** @property {number} - If non zero the particle is drawn as a trail, stretched in the direction of velocity */
|
|
2577
2681
|
trailScale: number;
|
|
2578
|
-
/** @property {
|
|
2682
|
+
/** @property {ParticleCallbackFunction} - Callback when particle is destroyed */
|
|
2579
2683
|
particleDestroyCallback: any;
|
|
2580
|
-
/** @property {
|
|
2684
|
+
/** @property {ParticleCallbackFunction} - Callback when particle is created */
|
|
2581
2685
|
particleCreateCallback: any;
|
|
2582
2686
|
/** @property {number} - Track particle emit time */
|
|
2583
2687
|
emitTimeBuffer: number;
|
|
@@ -2588,6 +2692,7 @@ declare module "littlejsengine" {
|
|
|
2588
2692
|
/**
|
|
2589
2693
|
* Particle Object - Created automatically by Particle Emitters
|
|
2590
2694
|
* @extends EngineObject
|
|
2695
|
+
* @memberof Engine
|
|
2591
2696
|
*/
|
|
2592
2697
|
export class Particle extends EngineObject {
|
|
2593
2698
|
/**
|
|
@@ -2605,19 +2710,19 @@ declare module "littlejsengine" {
|
|
|
2605
2710
|
* @param {boolean} additive - Does it use additive blend mode
|
|
2606
2711
|
* @param {number} trailScale - If a trail, how long to make it
|
|
2607
2712
|
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
2608
|
-
* @param {
|
|
2713
|
+
* @param {ParticleCallbackFunction} [destroyCallback] - Callback when particle dies
|
|
2609
2714
|
*/
|
|
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?:
|
|
2715
|
+
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
2716
|
/** @property {Color} - Color at start of life */
|
|
2612
2717
|
colorStart: Color;
|
|
2613
|
-
/** @property {Color} -
|
|
2614
|
-
|
|
2718
|
+
/** @property {Color} - Color at end of life */
|
|
2719
|
+
colorEnd: Color;
|
|
2615
2720
|
/** @property {number} - How long to live for */
|
|
2616
2721
|
lifeTime: number;
|
|
2617
2722
|
/** @property {number} - Size at start of life */
|
|
2618
2723
|
sizeStart: number;
|
|
2619
|
-
/** @property {number} -
|
|
2620
|
-
|
|
2724
|
+
/** @property {number} - Size at end of life */
|
|
2725
|
+
sizeEnd: number;
|
|
2621
2726
|
/** @property {number} - How quick to fade in/out */
|
|
2622
2727
|
fadeRate: number;
|
|
2623
2728
|
/** @property {boolean} - Is it additive */
|
|
@@ -2626,8 +2731,8 @@ declare module "littlejsengine" {
|
|
|
2626
2731
|
trailScale: number;
|
|
2627
2732
|
/** @property {ParticleEmitter} - Parent emitter if local space */
|
|
2628
2733
|
localSpaceEmitter: ParticleEmitter;
|
|
2629
|
-
/** @property {
|
|
2630
|
-
destroyCallback:
|
|
2734
|
+
/** @property {ParticleCallbackFunction} - Called when particle dies */
|
|
2735
|
+
destroyCallback: ParticleCallbackFunction;
|
|
2631
2736
|
}
|
|
2632
2737
|
/**
|
|
2633
2738
|
* LittleJS Medal System
|
|
@@ -2653,6 +2758,7 @@ declare module "littlejsengine" {
|
|
|
2653
2758
|
export function medalsInit(saveName: string): void;
|
|
2654
2759
|
/**
|
|
2655
2760
|
* Medal - Tracks an unlockable medal
|
|
2761
|
+
* @memberof Medals
|
|
2656
2762
|
* @example
|
|
2657
2763
|
* // create a medal
|
|
2658
2764
|
* const medal_example = new Medal(0, 'Example Medal', 'More info about the medal goes here.', '🎖️');
|
|
@@ -2697,20 +2803,21 @@ declare module "littlejsengine" {
|
|
|
2697
2803
|
storageKey(): string;
|
|
2698
2804
|
}
|
|
2699
2805
|
/**
|
|
2700
|
-
* LittleJS Newgrounds
|
|
2806
|
+
* LittleJS Newgrounds Plugin
|
|
2701
2807
|
* - NewgroundsMedal extends Medal with Newgrounds API functionality
|
|
2702
|
-
* - Call new NewgroundsPlugin() to setup Newgrounds
|
|
2808
|
+
* - Call new NewgroundsPlugin(app_id) to setup Newgrounds
|
|
2703
2809
|
* - Uses CryptoJS for encryption if optional cipher is provided
|
|
2810
|
+
* - provides functions to interact with medals scoreboards
|
|
2704
2811
|
* - Keeps connection alive and logs views
|
|
2705
|
-
*
|
|
2706
|
-
* - Functions to unlock medals
|
|
2812
|
+
* @namespace Newgrounds
|
|
2707
2813
|
*/
|
|
2708
2814
|
/** Global Newgrounds object
|
|
2709
2815
|
* @type {NewgroundsPlugin}
|
|
2710
|
-
* @memberof
|
|
2816
|
+
* @memberof Newgrounds */
|
|
2711
2817
|
export let newgrounds: NewgroundsPlugin;
|
|
2712
2818
|
/**
|
|
2713
2819
|
* Newgrounds API object
|
|
2820
|
+
* @memberof Newgrounds
|
|
2714
2821
|
*/
|
|
2715
2822
|
export class NewgroundsPlugin {
|
|
2716
2823
|
/** Create the global newgrounds object
|
|
@@ -2759,44 +2866,50 @@ declare module "littlejsengine" {
|
|
|
2759
2866
|
/**
|
|
2760
2867
|
* Newgrounds medal auto unlocks in newgrounds API
|
|
2761
2868
|
* @extends Medal
|
|
2869
|
+
* @memberof Newgrounds
|
|
2762
2870
|
*/
|
|
2763
2871
|
export class NewgroundsMedal extends Medal {
|
|
2764
2872
|
}
|
|
2765
2873
|
/**
|
|
2766
2874
|
* LittleJS Post Processing Plugin
|
|
2767
2875
|
* - Supports shadertoy style post processing shaders
|
|
2768
|
-
* - call new
|
|
2876
|
+
* - call new PostProcessPlugin() to setup post processing
|
|
2769
2877
|
* - can be enabled to pass other canvases through a final shader
|
|
2878
|
+
* @namespace PostProcess
|
|
2770
2879
|
*/
|
|
2771
2880
|
/** Global Post Process plugin object
|
|
2772
|
-
* @type {PostProcessPlugin}
|
|
2881
|
+
* @type {PostProcessPlugin}
|
|
2882
|
+
* @memberof PostProcess */
|
|
2773
2883
|
export let postProcess: PostProcessPlugin;
|
|
2774
2884
|
/**
|
|
2775
2885
|
* UI System Global Object
|
|
2886
|
+
* @memberof PostProcess
|
|
2776
2887
|
*/
|
|
2777
2888
|
export class PostProcessPlugin {
|
|
2778
2889
|
/** Create global post processing shader
|
|
2779
2890
|
* @param {string} shaderCode
|
|
2780
2891
|
* @param {boolean} [includeOverlay]
|
|
2892
|
+
* @param {boolean} [includeMainCanvas]
|
|
2781
2893
|
* @example
|
|
2782
2894
|
* // create the post process plugin object
|
|
2783
2895
|
* new PostProcessPlugin(shaderCode);
|
|
2784
2896
|
*/
|
|
2785
|
-
constructor(shaderCode: string, includeOverlay?: boolean);
|
|
2897
|
+
constructor(shaderCode: string, includeOverlay?: boolean, includeMainCanvas?: boolean);
|
|
2786
2898
|
/** @property {WebGLProgram} - Shader for post processing */
|
|
2787
|
-
shader:
|
|
2899
|
+
shader: any;
|
|
2788
2900
|
/** @property {WebGLTexture} - Texture for post processing */
|
|
2789
|
-
texture:
|
|
2790
|
-
/** @property {boolean} - Should overlay canvas be included in post processing */
|
|
2791
|
-
includeOverlay: boolean;
|
|
2901
|
+
texture: any;
|
|
2792
2902
|
}
|
|
2793
2903
|
/**
|
|
2794
2904
|
* LittleJS ZzFXM Plugin
|
|
2905
|
+
* @namespace ZzFXM
|
|
2795
2906
|
*/
|
|
2796
2907
|
/**
|
|
2797
2908
|
* Music Object - Stores a zzfx music track for later use
|
|
2798
2909
|
*
|
|
2799
2910
|
* <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
|
|
2911
|
+
* @extends Sound
|
|
2912
|
+
* @memberof ZzFXM
|
|
2800
2913
|
* @example
|
|
2801
2914
|
* // create some music
|
|
2802
2915
|
* const music_example = new Music(
|
|
@@ -2844,12 +2957,15 @@ declare module "littlejsengine" {
|
|
|
2844
2957
|
* - Buttons
|
|
2845
2958
|
* - Checkboxes
|
|
2846
2959
|
* - Images
|
|
2960
|
+
* @namespace UISystem
|
|
2847
2961
|
*/
|
|
2848
2962
|
/** Global UI system plugin object
|
|
2849
|
-
* @type {UISystemPlugin}
|
|
2963
|
+
* @type {UISystemPlugin}
|
|
2964
|
+
* @memberof UISystem */
|
|
2850
2965
|
export let uiSystem: UISystemPlugin;
|
|
2851
2966
|
/**
|
|
2852
2967
|
* UI System Global Object
|
|
2968
|
+
* @memberof UISystem
|
|
2853
2969
|
*/
|
|
2854
2970
|
export class UISystemPlugin {
|
|
2855
2971
|
/** Create the global UI system object
|
|
@@ -2871,6 +2987,8 @@ declare module "littlejsengine" {
|
|
|
2871
2987
|
defaultHoverColor: Color;
|
|
2872
2988
|
/** @property {Color} - Default color for disabled UI elements */
|
|
2873
2989
|
defaultDisabledColor: Color;
|
|
2990
|
+
/** @property {Color} - Uses a gradient fill combined with color */
|
|
2991
|
+
defaultGradientColor: any;
|
|
2874
2992
|
/** @property {number} - Default line width for UI elements */
|
|
2875
2993
|
defaultLineWidth: number;
|
|
2876
2994
|
/** @property {number} - Default rounded rect corner radius for UI elements */
|
|
@@ -2889,18 +3007,23 @@ declare module "littlejsengine" {
|
|
|
2889
3007
|
uiObjects: any[];
|
|
2890
3008
|
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
|
|
2891
3009
|
uiContext: CanvasRenderingContext2D;
|
|
2892
|
-
/** @property {UIObject} - Top most object user is over */
|
|
2893
|
-
hoverObject: any;
|
|
2894
3010
|
/** @property {UIObject} - Object user is currently interacting with */
|
|
2895
3011
|
activeObject: any;
|
|
3012
|
+
/** @property {UIObject} - Top most object user is over */
|
|
3013
|
+
hoverObject: any;
|
|
3014
|
+
/** @property {UIObject} - Hover object at start of update */
|
|
3015
|
+
lastHoverObject: any;
|
|
3016
|
+
/** @property {number} - If set ui coords will be renormalized to this canvas height */
|
|
3017
|
+
nativeHeight: number;
|
|
2896
3018
|
/** Draw a rectangle to the UI context
|
|
2897
3019
|
* @param {Vector2} pos
|
|
2898
3020
|
* @param {Vector2} size
|
|
2899
3021
|
* @param {Color} [color=uiSystem.defaultColor]
|
|
2900
3022
|
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2901
3023
|
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2902
|
-
* @param {number} [cornerRadius=uiSystem.defaultCornerRadius]
|
|
2903
|
-
|
|
3024
|
+
* @param {number} [cornerRadius=uiSystem.defaultCornerRadius]
|
|
3025
|
+
* @param {Color} [gradientColor=uiSystem.defaultGradientColor] */
|
|
3026
|
+
drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, cornerRadius?: number, gradientColor?: Color): void;
|
|
2904
3027
|
/** Draw a line to the UI context
|
|
2905
3028
|
* @param {Vector2} posA
|
|
2906
3029
|
* @param {Vector2} posB
|
|
@@ -2924,12 +3047,25 @@ declare module "littlejsengine" {
|
|
|
2924
3047
|
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2925
3048
|
* @param {string} [align]
|
|
2926
3049
|
* @param {string} [font=uiSystem.defaultFont]
|
|
3050
|
+
* @param {string} [fontStyle]
|
|
2927
3051
|
* @param {boolean} [applyMaxWidth=true] */
|
|
2928
|
-
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, applyMaxWidth?: boolean): void;
|
|
3052
|
+
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean): void;
|
|
3053
|
+
/**
|
|
3054
|
+
* @callback DragAndDropCallback - Callback for drag and drop events
|
|
3055
|
+
* @param {DragEvent} event - The drag event
|
|
3056
|
+
* @memberof UISystem
|
|
3057
|
+
*/
|
|
3058
|
+
/** Setup drag and drop event handlers
|
|
3059
|
+
* Automatically prevents defaults and calls the given functions
|
|
3060
|
+
* @param {DragAndDropCallback} [onDrop] - when a file is dropped
|
|
3061
|
+
* @param {DragAndDropCallback} [onDragEnter] - when a file is dragged onto the window
|
|
3062
|
+
* @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
|
|
3063
|
+
* @param {DragAndDropCallback} [onDragOver] - continously when dragging over */
|
|
3064
|
+
setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
|
|
2929
3065
|
}
|
|
2930
3066
|
/**
|
|
2931
3067
|
* UI Object - Base level object for all UI elements
|
|
2932
|
-
*/
|
|
3068
|
+
* @memberof UISystem */
|
|
2933
3069
|
export class UIObject {
|
|
2934
3070
|
/** Create a UIObject
|
|
2935
3071
|
* @param {Vector2} [pos=(0,0)]
|
|
@@ -2958,12 +3094,16 @@ declare module "littlejsengine" {
|
|
|
2958
3094
|
hoverColor: Color;
|
|
2959
3095
|
/** @property {Color} - Color for line drawing */
|
|
2960
3096
|
lineColor: Color;
|
|
3097
|
+
/** @property {Color} - Uses a gradient fill combined with color */
|
|
3098
|
+
gradientColor: any;
|
|
2961
3099
|
/** @property {number} - Width for line drawing */
|
|
2962
3100
|
lineWidth: number;
|
|
2963
3101
|
/** @property {number} - Corner radius for rounded rects */
|
|
2964
3102
|
cornerRadius: number;
|
|
2965
3103
|
/** @property {string} - Font for this objecct */
|
|
2966
3104
|
font: string;
|
|
3105
|
+
/** @property {string} - Font style for this object or undefined */
|
|
3106
|
+
fontStyle: any;
|
|
2967
3107
|
/** @property {number} - Override for text width */
|
|
2968
3108
|
textWidth: any;
|
|
2969
3109
|
/** @property {number} - Override for text height */
|
|
@@ -2988,6 +3128,8 @@ declare module "littlejsengine" {
|
|
|
2988
3128
|
interactive: boolean;
|
|
2989
3129
|
/** @property {boolean} - Activate when dragged over with mouse held down */
|
|
2990
3130
|
dragActivate: boolean;
|
|
3131
|
+
/** @property {boolean} - True if this can be a hover object */
|
|
3132
|
+
canBeHover: boolean;
|
|
2991
3133
|
/** Add a child UIObject to this object
|
|
2992
3134
|
* @param {UIObject} child
|
|
2993
3135
|
*/
|
|
@@ -2996,6 +3138,10 @@ declare module "littlejsengine" {
|
|
|
2996
3138
|
* @param {UIObject} child
|
|
2997
3139
|
*/
|
|
2998
3140
|
removeChild(child: UIObject): void;
|
|
3141
|
+
/** Check if the mouse is overlapping a box in screen space
|
|
3142
|
+
* @return {boolean} - True if overlapping
|
|
3143
|
+
*/
|
|
3144
|
+
isMouseOverlapping(): boolean;
|
|
2999
3145
|
/** Update the object, called automatically by plugin once each frame */
|
|
3000
3146
|
update(): void;
|
|
3001
3147
|
/** Render the object, called automatically by plugin once each frame */
|
|
@@ -3026,6 +3172,7 @@ declare module "littlejsengine" {
|
|
|
3026
3172
|
/**
|
|
3027
3173
|
* UIText - A UI object that displays text
|
|
3028
3174
|
* @extends UIObject
|
|
3175
|
+
* @memberof UISystem
|
|
3029
3176
|
*/
|
|
3030
3177
|
export class UIText extends UIObject {
|
|
3031
3178
|
/** Create a UIText object
|
|
@@ -3042,6 +3189,7 @@ declare module "littlejsengine" {
|
|
|
3042
3189
|
/**
|
|
3043
3190
|
* UITile - A UI object that displays a tile image
|
|
3044
3191
|
* @extends UIObject
|
|
3192
|
+
* @memberof UISystem
|
|
3045
3193
|
*/
|
|
3046
3194
|
export class UITile extends UIObject {
|
|
3047
3195
|
/** Create a UITile object
|
|
@@ -3063,6 +3211,7 @@ declare module "littlejsengine" {
|
|
|
3063
3211
|
/**
|
|
3064
3212
|
* UIButton - A UI object that acts as a button
|
|
3065
3213
|
* @extends UIObject
|
|
3214
|
+
* @memberof UISystem
|
|
3066
3215
|
*/
|
|
3067
3216
|
export class UIButton extends UIObject {
|
|
3068
3217
|
/** Create a UIButton object
|
|
@@ -3077,6 +3226,7 @@ declare module "littlejsengine" {
|
|
|
3077
3226
|
/**
|
|
3078
3227
|
* UICheckbox - A UI object that acts as a checkbox
|
|
3079
3228
|
* @extends UIObject
|
|
3229
|
+
* @memberof UISystem
|
|
3080
3230
|
*/
|
|
3081
3231
|
export class UICheckbox extends UIObject {
|
|
3082
3232
|
/** Create a UICheckbox object
|
|
@@ -3094,6 +3244,7 @@ declare module "littlejsengine" {
|
|
|
3094
3244
|
/**
|
|
3095
3245
|
* UIScrollbar - A UI object that acts as a scrollbar
|
|
3096
3246
|
* @extends UIObject
|
|
3247
|
+
* @memberof UISystem
|
|
3097
3248
|
*/
|
|
3098
3249
|
export class UIScrollbar extends UIObject {
|
|
3099
3250
|
/** Create a UIScrollbar object
|
|
@@ -3148,6 +3299,7 @@ declare module "littlejsengine" {
|
|
|
3148
3299
|
/**
|
|
3149
3300
|
* Box2D Global Object
|
|
3150
3301
|
* - Wraps Box2d world and provides global functions
|
|
3302
|
+
* @memberof Box2D
|
|
3151
3303
|
*/
|
|
3152
3304
|
export class Box2dPlugin {
|
|
3153
3305
|
/** Create the global UI system object
|
|
@@ -3227,6 +3379,7 @@ declare module "littlejsengine" {
|
|
|
3227
3379
|
* - Each object has a Box2D body which can have multiple fixtures and joints
|
|
3228
3380
|
* - Provides interface for Box2D body and fixture functions
|
|
3229
3381
|
* @extends EngineObject
|
|
3382
|
+
* @memberof Box2D
|
|
3230
3383
|
*/
|
|
3231
3384
|
export class Box2dObject extends EngineObject {
|
|
3232
3385
|
/** Create a LittleJS object with Box2d physics
|
|
@@ -3456,6 +3609,7 @@ declare module "littlejsengine" {
|
|
|
3456
3609
|
* Box2D Joint
|
|
3457
3610
|
* - Base class for Box2D joints
|
|
3458
3611
|
* - A joint is used to connect objects together
|
|
3612
|
+
* @memberof Box2D
|
|
3459
3613
|
*/
|
|
3460
3614
|
export class Box2dJoint {
|
|
3461
3615
|
/** Create a box2d joint, the base class is not intended to be used directly
|
|
@@ -3497,6 +3651,7 @@ declare module "littlejsengine" {
|
|
|
3497
3651
|
* - This a soft constraint with a max force
|
|
3498
3652
|
* - This allows the constraint to stretch and without applying huge forces
|
|
3499
3653
|
* @extends Box2dJoint
|
|
3654
|
+
* @memberof Box2D
|
|
3500
3655
|
*/
|
|
3501
3656
|
export class Box2dTargetJoint extends Box2dJoint {
|
|
3502
3657
|
/** Create a target joint
|
|
@@ -3528,6 +3683,7 @@ declare module "littlejsengine" {
|
|
|
3528
3683
|
* - Constrains two points on two objects to remain at a fixed distance
|
|
3529
3684
|
* - You can view this as a massless, rigid rod
|
|
3530
3685
|
* @extends Box2dJoint
|
|
3686
|
+
* @memberof Box2D
|
|
3531
3687
|
*/
|
|
3532
3688
|
export class Box2dDistanceJoint extends Box2dJoint {
|
|
3533
3689
|
/** Create a distance joint
|
|
@@ -3566,6 +3722,7 @@ declare module "littlejsengine" {
|
|
|
3566
3722
|
* Box2D Pin Joint
|
|
3567
3723
|
* - Pins two objects together at a point
|
|
3568
3724
|
* @extends Box2dDistanceJoint
|
|
3725
|
+
* @memberof Box2D
|
|
3569
3726
|
*/
|
|
3570
3727
|
export class Box2dPinJoint extends Box2dDistanceJoint {
|
|
3571
3728
|
/** Create a pin joint
|
|
@@ -3579,6 +3736,7 @@ declare module "littlejsengine" {
|
|
|
3579
3736
|
* Box2D Rope Joint
|
|
3580
3737
|
* - Enforces a maximum distance between two points on two objects
|
|
3581
3738
|
* @extends Box2dJoint
|
|
3739
|
+
* @memberof Box2D
|
|
3582
3740
|
*/
|
|
3583
3741
|
export class Box2dRopeJoint extends Box2dJoint {
|
|
3584
3742
|
/** Create a rope joint
|
|
@@ -3610,6 +3768,7 @@ declare module "littlejsengine" {
|
|
|
3610
3768
|
* - You can use a motor to drive the relative rotation about the shared point
|
|
3611
3769
|
* - A maximum motor torque is provided so that infinite forces are not generated
|
|
3612
3770
|
* @extends Box2dJoint
|
|
3771
|
+
* @memberof Box2D
|
|
3613
3772
|
*/
|
|
3614
3773
|
export class Box2dRevoluteJoint extends Box2dJoint {
|
|
3615
3774
|
/** Create a revolute joint
|
|
@@ -3678,6 +3837,7 @@ declare module "littlejsengine" {
|
|
|
3678
3837
|
* - Either joint can be a revolute or prismatic joint
|
|
3679
3838
|
* - You specify a gear ratio to bind the motions together
|
|
3680
3839
|
* @extends Box2dJoint
|
|
3840
|
+
* @memberof Box2D
|
|
3681
3841
|
*/
|
|
3682
3842
|
export class Box2dGearJoint extends Box2dJoint {
|
|
3683
3843
|
/** Create a gear joint
|
|
@@ -3709,6 +3869,7 @@ declare module "littlejsengine" {
|
|
|
3709
3869
|
* - You can use a joint limit to restrict the range of motion
|
|
3710
3870
|
* - You can use a joint motor to drive the motion or to model joint friction
|
|
3711
3871
|
* @extends Box2dJoint
|
|
3872
|
+
* @memberof Box2D
|
|
3712
3873
|
*/
|
|
3713
3874
|
export class Box2dPrismaticJoint extends Box2dJoint {
|
|
3714
3875
|
/** Create a prismatic joint
|
|
@@ -3782,6 +3943,7 @@ declare module "littlejsengine" {
|
|
|
3782
3943
|
* - You can use a joint motor to drive the motion or to model joint friction
|
|
3783
3944
|
* - This joint is designed for vehicle suspensions
|
|
3784
3945
|
* @extends Box2dJoint
|
|
3946
|
+
* @memberof Box2D
|
|
3785
3947
|
*/
|
|
3786
3948
|
export class Box2dWheelJoint extends Box2dJoint {
|
|
3787
3949
|
/** Create a wheel joint
|
|
@@ -3844,6 +4006,7 @@ declare module "littlejsengine" {
|
|
|
3844
4006
|
* Box2D Weld Joint
|
|
3845
4007
|
* - Glues two objects together
|
|
3846
4008
|
* @extends Box2dJoint
|
|
4009
|
+
* @memberof Box2D
|
|
3847
4010
|
*/
|
|
3848
4011
|
export class Box2dWeldJoint extends Box2dJoint {
|
|
3849
4012
|
/** Create a weld joint
|
|
@@ -3879,6 +4042,7 @@ declare module "littlejsengine" {
|
|
|
3879
4042
|
* - Used to apply top-down friction
|
|
3880
4043
|
* - Provides 2D translational friction and angular friction
|
|
3881
4044
|
* @extends Box2dJoint
|
|
4045
|
+
* @memberof Box2D
|
|
3882
4046
|
*/
|
|
3883
4047
|
export class Box2dFrictionJoint extends Box2dJoint {
|
|
3884
4048
|
/** Create a friction joint
|
|
@@ -3912,6 +4076,7 @@ declare module "littlejsengine" {
|
|
|
3912
4076
|
* - The pulley supports a ratio such that: length1 + ratio * length2 <= constant
|
|
3913
4077
|
* - The force transmitted is scaled by the ratio
|
|
3914
4078
|
* @extends Box2dJoint
|
|
4079
|
+
* @memberof Box2D
|
|
3915
4080
|
*/
|
|
3916
4081
|
export class Box2dPulleyJoint extends Box2dJoint {
|
|
3917
4082
|
/** Create a pulley joint
|
|
@@ -3951,6 +4116,7 @@ declare module "littlejsengine" {
|
|
|
3951
4116
|
* - Controls the relative motion between two objects
|
|
3952
4117
|
* - Typical usage is to control the movement of a object with respect to the ground
|
|
3953
4118
|
* @extends Box2dJoint
|
|
4119
|
+
* @memberof Box2D
|
|
3954
4120
|
*/
|
|
3955
4121
|
export class Box2dMotorJoint extends Box2dJoint {
|
|
3956
4122
|
/** Create a motor joint
|