littlejsengine 1.11.9 → 1.11.10
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/README.md +3 -3
- package/dist/littlejs.d.ts +482 -479
- package/dist/littlejs.esm.js +512 -501
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +510 -499
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +466 -458
- package/examples/module/game.js +2 -2
- package/examples/shorts/base.html +1 -1
- package/examples/starter/game.js +8 -1
- package/examples/typescript/build/dist/littlejs.esm.js +4834 -0
- package/examples/typescript/build/examples/typescript/build.js +24 -0
- package/examples/typescript/build/examples/typescript/game.js +102 -0
- package/examples/typescript/build.bat +5 -0
- package/examples/typescript/build.js +33 -0
- package/examples/typescript/game.js +102 -0
- package/examples/typescript/game.ts +134 -0
- package/examples/typescript/index.html +10 -0
- package/examples/typescript/tiles.png +0 -0
- package/examples/typescript/tsconfig.json +8 -0
- package/package.json +1 -1
- package/plugins/newgrounds.js +38 -34
- package/plugins/postProcess.js +18 -4
- package/plugins/uiSystem.js +196 -30
- package/src/engine.js +21 -20
- package/src/engineAudio.js +59 -59
- package/src/engineDebug.js +44 -41
- package/src/engineDraw.js +58 -58
- package/src/engineExport.js +2 -2
- package/src/engineInput.js +30 -30
- package/src/engineMedals.js +1 -1
- package/src/engineObject.js +39 -34
- package/src/engineParticles.js +10 -10
- package/src/engineSettings.js +74 -72
- package/src/engineTileLayer.js +21 -21
- package/src/engineUtilities.js +150 -150
- package/src/engineWebGL.js +3 -3
package/dist/littlejs.d.ts
CHANGED
|
@@ -19,48 +19,48 @@ declare module "littlejsengine" {
|
|
|
19
19
|
* @namespace Engine
|
|
20
20
|
*/
|
|
21
21
|
/** Name of engine
|
|
22
|
-
* @type {
|
|
22
|
+
* @type {string}
|
|
23
23
|
* @default
|
|
24
24
|
* @memberof Engine */
|
|
25
25
|
export const engineName: string;
|
|
26
26
|
/** Version of engine
|
|
27
|
-
* @type {
|
|
27
|
+
* @type {string}
|
|
28
28
|
* @default
|
|
29
29
|
* @memberof Engine */
|
|
30
30
|
export const engineVersion: string;
|
|
31
31
|
/** Frames per second to update
|
|
32
|
-
* @type {
|
|
32
|
+
* @type {number}
|
|
33
33
|
* @default
|
|
34
34
|
* @memberof Engine */
|
|
35
35
|
export const frameRate: number;
|
|
36
36
|
/** How many seconds each frame lasts, engine uses a fixed time step
|
|
37
|
-
* @type {
|
|
37
|
+
* @type {number}
|
|
38
38
|
* @default 1/60
|
|
39
39
|
* @memberof Engine */
|
|
40
40
|
export const timeDelta: number;
|
|
41
41
|
/** Array containing all engine objects
|
|
42
|
-
* @type {Array}
|
|
42
|
+
* @type {Array<EngineObject>}
|
|
43
43
|
* @memberof Engine */
|
|
44
|
-
export let engineObjects:
|
|
44
|
+
export let engineObjects: Array<EngineObject>;
|
|
45
45
|
/** Current update frame, used to calculate time
|
|
46
|
-
* @type {
|
|
46
|
+
* @type {number}
|
|
47
47
|
* @memberof Engine */
|
|
48
48
|
export let frame: number;
|
|
49
49
|
/** Current engine time since start in seconds
|
|
50
|
-
* @type {
|
|
50
|
+
* @type {number}
|
|
51
51
|
* @memberof Engine */
|
|
52
52
|
export let time: number;
|
|
53
53
|
/** Actual clock time since start in seconds (not affected by pause or frame rate clamping)
|
|
54
|
-
* @type {
|
|
54
|
+
* @type {number}
|
|
55
55
|
* @memberof Engine */
|
|
56
56
|
export let timeReal: number;
|
|
57
57
|
/** Is the game paused? Causes time and objects to not be updated
|
|
58
|
-
* @type {
|
|
58
|
+
* @type {boolean}
|
|
59
59
|
* @default false
|
|
60
60
|
* @memberof Engine */
|
|
61
61
|
export let paused: boolean;
|
|
62
62
|
/** Set if game is paused
|
|
63
|
-
* @param {
|
|
63
|
+
* @param {boolean} isPaused
|
|
64
64
|
* @memberof Engine */
|
|
65
65
|
export function setPaused(isPaused: boolean): void;
|
|
66
66
|
/** Startup LittleJS engine with your callback functions
|
|
@@ -69,10 +69,10 @@ declare module "littlejsengine" {
|
|
|
69
69
|
* @param {Function} gameUpdatePost - Called after physics and objects are updated, even when paused
|
|
70
70
|
* @param {Function} gameRender - Called before objects are rendered, for drawing the background
|
|
71
71
|
* @param {Function} gameRenderPost - Called after objects are rendered, useful for drawing UI
|
|
72
|
-
* @param {Array} [imageSources=[]] - List of images to load
|
|
72
|
+
* @param {Array<string>} [imageSources=[]] - List of images to load
|
|
73
73
|
* @param {HTMLElement} [rootElement] - Root element to attach to, the document body by default
|
|
74
74
|
* @memberof Engine */
|
|
75
|
-
export function engineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?:
|
|
75
|
+
export function engineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: Array<string>, rootElement?: HTMLElement): void;
|
|
76
76
|
/** Update each engine object, remove destroyed objects, and update time
|
|
77
77
|
* @memberof Engine */
|
|
78
78
|
export function engineObjectsUpdate(): void;
|
|
@@ -81,25 +81,25 @@ declare module "littlejsengine" {
|
|
|
81
81
|
export function engineObjectsDestroy(): void;
|
|
82
82
|
/** Collects all object within a given area
|
|
83
83
|
* @param {Vector2} [pos] - Center of test area, or undefined for all objects
|
|
84
|
-
* @param {
|
|
85
|
-
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
86
|
-
* @return {Array} - List of collected objects
|
|
84
|
+
* @param {Vector2|number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
85
|
+
* @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
|
|
86
|
+
* @return {Array<EngineObject>} - List of collected objects
|
|
87
87
|
* @memberof Engine */
|
|
88
|
-
export function engineObjectsCollect(pos?: Vector2, size?:
|
|
88
|
+
export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>): Array<EngineObject>;
|
|
89
89
|
/** Triggers a callback for each object within a given area
|
|
90
90
|
* @param {Vector2} [pos] - Center of test area, or undefined for all objects
|
|
91
|
-
* @param {
|
|
91
|
+
* @param {Vector2|number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
92
92
|
* @param {Function} [callbackFunction] - Calls this function on every object that passes the test
|
|
93
|
-
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
93
|
+
* @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
|
|
94
94
|
* @memberof Engine */
|
|
95
|
-
export function engineObjectsCallback(pos?: Vector2, size?:
|
|
95
|
+
export function engineObjectsCallback(pos?: Vector2, size?: Vector2 | number, callbackFunction?: Function, objects?: Array<EngineObject>): void;
|
|
96
96
|
/** Return a list of objects intersecting a ray
|
|
97
97
|
* @param {Vector2} start
|
|
98
98
|
* @param {Vector2} end
|
|
99
|
-
* @param {Array} [objects=engineObjects] - List of objects to check
|
|
100
|
-
* @return {Array} - List of objects hit
|
|
99
|
+
* @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
|
|
100
|
+
* @return {Array<EngineObject>} - List of objects hit
|
|
101
101
|
* @memberof Engine */
|
|
102
|
-
export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?:
|
|
102
|
+
export function engineObjectsRaycast(start: Vector2, end: Vector2, objects?: Array<EngineObject>): Array<EngineObject>;
|
|
103
103
|
/** Add a new update function for a plugin
|
|
104
104
|
* @param {Function} [updateFunction]
|
|
105
105
|
* @param {Function} [renderFunction]
|
|
@@ -115,64 +115,64 @@ declare module "littlejsengine" {
|
|
|
115
115
|
* @namespace Debug
|
|
116
116
|
*/
|
|
117
117
|
/** True if debug is enabled
|
|
118
|
-
* @type {
|
|
118
|
+
* @type {boolean}
|
|
119
119
|
* @default
|
|
120
120
|
* @memberof Debug */
|
|
121
121
|
export const debug: boolean;
|
|
122
122
|
/** True if the debug overlay is active, always false in release builds
|
|
123
|
-
* @type {
|
|
123
|
+
* @type {boolean}
|
|
124
124
|
* @default
|
|
125
125
|
* @memberof Debug */
|
|
126
126
|
export let debugOverlay: boolean;
|
|
127
127
|
/** True if watermark with FPS should be shown, false in release builds
|
|
128
|
-
* @type {
|
|
128
|
+
* @type {boolean}
|
|
129
129
|
* @default
|
|
130
130
|
* @memberof Debug */
|
|
131
131
|
export let showWatermark: boolean;
|
|
132
132
|
/** Asserts if the expression is false, does not do anything in release builds
|
|
133
|
-
* @param {
|
|
133
|
+
* @param {boolean} assert
|
|
134
134
|
* @param {Object} [output]
|
|
135
135
|
* @memberof Debug */
|
|
136
136
|
export function ASSERT(assert: boolean, output?: any): void;
|
|
137
137
|
/** Draw a debug rectangle in world space
|
|
138
138
|
* @param {Vector2} pos
|
|
139
139
|
* @param {Vector2} [size=Vector2()]
|
|
140
|
-
* @param {
|
|
141
|
-
* @param {
|
|
142
|
-
* @param {
|
|
143
|
-
* @param {
|
|
140
|
+
* @param {string} [color]
|
|
141
|
+
* @param {number} [time]
|
|
142
|
+
* @param {number} [angle]
|
|
143
|
+
* @param {boolean} [fill]
|
|
144
144
|
* @memberof Debug */
|
|
145
145
|
export function debugRect(pos: Vector2, size?: Vector2, color?: string, time?: number, angle?: number, fill?: boolean): void;
|
|
146
146
|
/** Draw a debug poly in world space
|
|
147
147
|
* @param {Vector2} pos
|
|
148
|
-
* @param {Array}
|
|
149
|
-
* @param {
|
|
150
|
-
* @param {
|
|
151
|
-
* @param {
|
|
152
|
-
* @param {
|
|
148
|
+
* @param {Array<Vector2>} points
|
|
149
|
+
* @param {string} [color]
|
|
150
|
+
* @param {number} [time]
|
|
151
|
+
* @param {number} [angle]
|
|
152
|
+
* @param {boolean} [fill]
|
|
153
153
|
* @memberof Debug */
|
|
154
|
-
export function debugPoly(pos: Vector2, points:
|
|
154
|
+
export function debugPoly(pos: Vector2, points: Array<Vector2>, color?: string, time?: number, angle?: number, fill?: boolean): void;
|
|
155
155
|
/** Draw a debug circle in world space
|
|
156
156
|
* @param {Vector2} pos
|
|
157
|
-
* @param {
|
|
158
|
-
* @param {
|
|
159
|
-
* @param {
|
|
160
|
-
* @param {
|
|
157
|
+
* @param {number} [radius]
|
|
158
|
+
* @param {string} [color]
|
|
159
|
+
* @param {number} [time]
|
|
160
|
+
* @param {boolean} [fill]
|
|
161
161
|
* @memberof Debug */
|
|
162
162
|
export function debugCircle(pos: Vector2, radius?: number, color?: string, time?: number, fill?: boolean): void;
|
|
163
163
|
/** Draw a debug point in world space
|
|
164
164
|
* @param {Vector2} pos
|
|
165
|
-
* @param {
|
|
166
|
-
* @param {
|
|
167
|
-
* @param {
|
|
165
|
+
* @param {string} [color]
|
|
166
|
+
* @param {number} [time]
|
|
167
|
+
* @param {number} [angle]
|
|
168
168
|
* @memberof Debug */
|
|
169
169
|
export function debugPoint(pos: Vector2, color?: string, time?: number, angle?: number): void;
|
|
170
170
|
/** Draw a debug line in world space
|
|
171
171
|
* @param {Vector2} posA
|
|
172
172
|
* @param {Vector2} posB
|
|
173
|
-
* @param {
|
|
174
|
-
* @param {
|
|
175
|
-
* @param {
|
|
173
|
+
* @param {string} [color]
|
|
174
|
+
* @param {number} [thickness]
|
|
175
|
+
* @param {number} [time]
|
|
176
176
|
* @memberof Debug */
|
|
177
177
|
export function debugLine(posA: Vector2, posB: Vector2, color?: string, thickness?: number, time?: number): void;
|
|
178
178
|
/** Draw a debug combined axis aligned bounding box in world space
|
|
@@ -180,17 +180,17 @@ declare module "littlejsengine" {
|
|
|
180
180
|
* @param {Vector2} sA - size A
|
|
181
181
|
* @param {Vector2} pB - position B
|
|
182
182
|
* @param {Vector2} sB - size B
|
|
183
|
-
* @param {
|
|
183
|
+
* @param {string} [color]
|
|
184
184
|
* @memberof Debug */
|
|
185
185
|
export function debugOverlap(pA: Vector2, sA: Vector2, pB: Vector2, sB: Vector2, color?: string): void;
|
|
186
186
|
/** Draw a debug axis aligned bounding box in world space
|
|
187
|
-
* @param {
|
|
187
|
+
* @param {string} text
|
|
188
188
|
* @param {Vector2} pos
|
|
189
|
-
* @param {
|
|
190
|
-
* @param {
|
|
191
|
-
* @param {
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {
|
|
189
|
+
* @param {number} [size]
|
|
190
|
+
* @param {string} [color]
|
|
191
|
+
* @param {number} [time]
|
|
192
|
+
* @param {number} [angle]
|
|
193
|
+
* @param {string} [font]
|
|
194
194
|
* @memberof Debug */
|
|
195
195
|
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
196
196
|
/** Clear all debug primitives in the list
|
|
@@ -201,19 +201,19 @@ declare module "littlejsengine" {
|
|
|
201
201
|
export function debugScreenshot(): void;
|
|
202
202
|
/** Save a canvas to disk
|
|
203
203
|
* @param {HTMLCanvasElement} canvas
|
|
204
|
-
* @param {
|
|
205
|
-
* @param {
|
|
204
|
+
* @param {string} [filename]
|
|
205
|
+
* @param {string} [type]
|
|
206
206
|
* @memberof Debug */
|
|
207
207
|
export function debugSaveCanvas(canvas: HTMLCanvasElement, filename?: string, type?: string): void;
|
|
208
208
|
/** Save a text file to disk
|
|
209
|
-
* @param {
|
|
210
|
-
* @param {
|
|
211
|
-
* @param {
|
|
209
|
+
* @param {string} text
|
|
210
|
+
* @param {string} [filename]
|
|
211
|
+
* @param {string} [type]
|
|
212
212
|
* @memberof Debug */
|
|
213
213
|
export function debugSaveText(text: string, filename?: string, type?: string): void;
|
|
214
214
|
/** Save a data url to disk
|
|
215
|
-
* @param {
|
|
216
|
-
* @param {
|
|
215
|
+
* @param {string} dataURL
|
|
216
|
+
* @param {string} filename
|
|
217
217
|
* @memberof Debug */
|
|
218
218
|
export function debugSaveDataURL(dataURL: string, filename: string): void;
|
|
219
219
|
/**
|
|
@@ -227,7 +227,7 @@ declare module "littlejsengine" {
|
|
|
227
227
|
* @memberof Settings */
|
|
228
228
|
export let cameraPos: Vector2;
|
|
229
229
|
/** Scale of camera in world space
|
|
230
|
-
* @type {
|
|
230
|
+
* @type {number}
|
|
231
231
|
* @default
|
|
232
232
|
* @memberof Settings */
|
|
233
233
|
export let cameraScale: number;
|
|
@@ -243,27 +243,29 @@ declare module "littlejsengine" {
|
|
|
243
243
|
* @memberof Settings */
|
|
244
244
|
export let canvasFixedSize: Vector2;
|
|
245
245
|
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
246
|
-
*
|
|
246
|
+
* - Must be set before startup to take effect
|
|
247
|
+
* - If enabled sets css image-rendering:pixelated
|
|
248
|
+
* @type {boolean}
|
|
247
249
|
* @default
|
|
248
250
|
* @memberof Settings */
|
|
249
251
|
export let canvasPixelated: boolean;
|
|
250
252
|
/** Disables texture filtering for crisper pixel art
|
|
251
|
-
* @type {
|
|
253
|
+
* @type {boolean}
|
|
252
254
|
* @default
|
|
253
255
|
* @memberof Settings */
|
|
254
256
|
export let tilesPixelated: boolean;
|
|
255
257
|
/** Default font used for text rendering
|
|
256
|
-
* @type {
|
|
258
|
+
* @type {string}
|
|
257
259
|
* @default
|
|
258
260
|
* @memberof Settings */
|
|
259
261
|
export let fontDefault: string;
|
|
260
262
|
/** Enable to show the LittleJS splash screen be shown on startup
|
|
261
|
-
* @type {
|
|
263
|
+
* @type {boolean}
|
|
262
264
|
* @default
|
|
263
265
|
* @memberof Settings */
|
|
264
266
|
export let showSplashScreen: boolean;
|
|
265
267
|
/** Disables all rendering, audio, and input for servers
|
|
266
|
-
* @type {
|
|
268
|
+
* @type {boolean}
|
|
267
269
|
* @default
|
|
268
270
|
* @memberof Settings */
|
|
269
271
|
export let headlessMode: boolean;
|
|
@@ -273,134 +275,134 @@ declare module "littlejsengine" {
|
|
|
273
275
|
* @memberof Settings */
|
|
274
276
|
export let tileSizeDefault: Vector2;
|
|
275
277
|
/** How many pixels smaller to draw tiles to prevent bleeding from neighbors
|
|
276
|
-
* @type {
|
|
278
|
+
* @type {number}
|
|
277
279
|
* @default
|
|
278
280
|
* @memberof Settings */
|
|
279
281
|
export let tileFixBleedScale: number;
|
|
280
282
|
/** Enable physics solver for collisions between objects
|
|
281
|
-
* @type {
|
|
283
|
+
* @type {boolean}
|
|
282
284
|
* @default
|
|
283
285
|
* @memberof Settings */
|
|
284
286
|
export let enablePhysicsSolver: boolean;
|
|
285
287
|
/** Default object mass for collision calculations (how heavy objects are)
|
|
286
|
-
* @type {
|
|
288
|
+
* @type {number}
|
|
287
289
|
* @default
|
|
288
290
|
* @memberof Settings */
|
|
289
291
|
export let objectDefaultMass: number;
|
|
290
292
|
/** How much to slow velocity by each frame (0-1)
|
|
291
|
-
* @type {
|
|
293
|
+
* @type {number}
|
|
292
294
|
* @default
|
|
293
295
|
* @memberof Settings */
|
|
294
296
|
export let objectDefaultDamping: number;
|
|
295
297
|
/** How much to slow angular velocity each frame (0-1)
|
|
296
|
-
* @type {
|
|
298
|
+
* @type {number}
|
|
297
299
|
* @default
|
|
298
300
|
* @memberof Settings */
|
|
299
301
|
export let objectDefaultAngleDamping: number;
|
|
300
302
|
/** How much to bounce when a collision occurs (0-1)
|
|
301
|
-
* @type {
|
|
303
|
+
* @type {number}
|
|
302
304
|
* @default
|
|
303
305
|
* @memberof Settings */
|
|
304
306
|
export let objectDefaultElasticity: number;
|
|
305
307
|
/** How much to slow when touching (0-1)
|
|
306
|
-
* @type {
|
|
308
|
+
* @type {number}
|
|
307
309
|
* @default
|
|
308
310
|
* @memberof Settings */
|
|
309
311
|
export let objectDefaultFriction: number;
|
|
310
312
|
/** Clamp max speed to avoid fast objects missing collisions
|
|
311
|
-
* @type {
|
|
313
|
+
* @type {number}
|
|
312
314
|
* @default
|
|
313
315
|
* @memberof Settings */
|
|
314
316
|
export let objectMaxSpeed: number;
|
|
315
317
|
/** How much gravity to apply to objects along the Y axis, negative is down
|
|
316
|
-
* @type {
|
|
318
|
+
* @type {number}
|
|
317
319
|
* @default
|
|
318
320
|
* @memberof Settings */
|
|
319
321
|
export let gravity: number;
|
|
320
322
|
/** Scales emit rate of particles, useful for low graphics mode (0 disables particle emitters)
|
|
321
|
-
* @type {
|
|
323
|
+
* @type {number}
|
|
322
324
|
* @default
|
|
323
325
|
* @memberof Settings */
|
|
324
326
|
export let particleEmitRateScale: number;
|
|
325
327
|
/** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
|
|
326
|
-
* @type {
|
|
328
|
+
* @type {boolean}
|
|
327
329
|
* @default
|
|
328
330
|
* @memberof Settings */
|
|
329
331
|
export let glEnable: boolean;
|
|
330
332
|
/** Fixes slow rendering in some browsers by not compositing the WebGL canvas
|
|
331
|
-
* @type {
|
|
333
|
+
* @type {boolean}
|
|
332
334
|
* @default
|
|
333
335
|
* @memberof Settings */
|
|
334
336
|
export let glOverlay: boolean;
|
|
335
337
|
/** Should gamepads be allowed
|
|
336
|
-
* @type {
|
|
338
|
+
* @type {boolean}
|
|
337
339
|
* @default
|
|
338
340
|
* @memberof Settings */
|
|
339
341
|
export let gamepadsEnable: boolean;
|
|
340
342
|
/** If true, the dpad input is also routed to the left analog stick (for better accessability)
|
|
341
|
-
* @type {
|
|
343
|
+
* @type {boolean}
|
|
342
344
|
* @default
|
|
343
345
|
* @memberof Settings */
|
|
344
346
|
export let gamepadDirectionEmulateStick: boolean;
|
|
345
347
|
/** If true the WASD keys are also routed to the direction keys (for better accessability)
|
|
346
|
-
* @type {
|
|
348
|
+
* @type {boolean}
|
|
347
349
|
* @default
|
|
348
350
|
* @memberof Settings */
|
|
349
351
|
export let inputWASDEmulateDirection: boolean;
|
|
350
352
|
/** True if touch gamepad should appear on mobile devices
|
|
351
353
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
352
354
|
* - Must be set by end of gameInit to be activated
|
|
353
|
-
* @type {
|
|
355
|
+
* @type {boolean}
|
|
354
356
|
* @default
|
|
355
357
|
* @memberof Settings */
|
|
356
358
|
export let touchGamepadEnable: boolean;
|
|
357
359
|
/** True if touch gamepad should be analog stick or false to use if 8 way dpad
|
|
358
|
-
* @type {
|
|
360
|
+
* @type {boolean}
|
|
359
361
|
* @default
|
|
360
362
|
* @memberof Settings */
|
|
361
363
|
export let touchGamepadAnalog: boolean;
|
|
362
364
|
/** Size of virtual gamepad for touch devices in pixels
|
|
363
|
-
* @type {
|
|
365
|
+
* @type {number}
|
|
364
366
|
* @default
|
|
365
367
|
* @memberof Settings */
|
|
366
368
|
export let touchGamepadSize: number;
|
|
367
369
|
/** Transparency of touch gamepad overlay
|
|
368
|
-
* @type {
|
|
370
|
+
* @type {number}
|
|
369
371
|
* @default
|
|
370
372
|
* @memberof Settings */
|
|
371
373
|
export let touchGamepadAlpha: number;
|
|
372
374
|
/** Allow vibration hardware if it exists
|
|
373
|
-
* @type {
|
|
375
|
+
* @type {boolean}
|
|
374
376
|
* @default
|
|
375
377
|
* @memberof Settings */
|
|
376
378
|
export let vibrateEnable: boolean;
|
|
377
379
|
/** All audio code can be disabled and removed from build
|
|
378
|
-
* @type {
|
|
380
|
+
* @type {boolean}
|
|
379
381
|
* @default
|
|
380
382
|
* @memberof Settings */
|
|
381
383
|
export let soundEnable: boolean;
|
|
382
384
|
/** Volume scale to apply to all sound, music and speech
|
|
383
|
-
* @type {
|
|
385
|
+
* @type {number}
|
|
384
386
|
* @default
|
|
385
387
|
* @memberof Settings */
|
|
386
388
|
export let soundVolume: number;
|
|
387
389
|
/** Default range where sound no longer plays
|
|
388
|
-
* @type {
|
|
390
|
+
* @type {number}
|
|
389
391
|
* @default
|
|
390
392
|
* @memberof Settings */
|
|
391
393
|
export let soundDefaultRange: number;
|
|
392
394
|
/** Default range percent to start tapering off sound (0-1)
|
|
393
|
-
* @type {
|
|
395
|
+
* @type {number}
|
|
394
396
|
* @default
|
|
395
397
|
* @memberof Settings */
|
|
396
398
|
export let soundDefaultTaper: number;
|
|
397
399
|
/** How long to show medals for in seconds
|
|
398
|
-
* @type {
|
|
400
|
+
* @type {number}
|
|
399
401
|
* @default
|
|
400
402
|
* @memberof Settings */
|
|
401
403
|
export let medalDisplayTime: number;
|
|
402
404
|
/** How quickly to slide on/off medals in seconds
|
|
403
|
-
* @type {
|
|
405
|
+
* @type {number}
|
|
404
406
|
* @default
|
|
405
407
|
* @memberof Settings */
|
|
406
408
|
export let medalDisplaySlideTime: number;
|
|
@@ -410,7 +412,7 @@ declare module "littlejsengine" {
|
|
|
410
412
|
* @memberof Settings */
|
|
411
413
|
export let medalDisplaySize: Vector2;
|
|
412
414
|
/** Size of icon in medal display
|
|
413
|
-
* @type {
|
|
415
|
+
* @type {number}
|
|
414
416
|
* @default
|
|
415
417
|
* @memberof Settings */
|
|
416
418
|
export let medalDisplayIconSize: number;
|
|
@@ -419,7 +421,7 @@ declare module "littlejsengine" {
|
|
|
419
421
|
* @memberof Settings */
|
|
420
422
|
export function setCameraPos(pos: Vector2): void;
|
|
421
423
|
/** Set scale of camera in world space
|
|
422
|
-
* @param {
|
|
424
|
+
* @param {number} scale
|
|
423
425
|
* @memberof Settings */
|
|
424
426
|
export function setCameraScale(scale: number): void;
|
|
425
427
|
/** Set max size of the canvas
|
|
@@ -431,31 +433,31 @@ declare module "littlejsengine" {
|
|
|
431
433
|
* @memberof Settings */
|
|
432
434
|
export function setCanvasFixedSize(size: Vector2): void;
|
|
433
435
|
/** Use nearest neighbor scaling algorithm for canvas for more pixelated look
|
|
434
|
-
* @param {
|
|
436
|
+
* @param {boolean} pixelated
|
|
435
437
|
* @memberof Settings */
|
|
436
438
|
export function setCanvasPixelated(pixelated: boolean): void;
|
|
437
439
|
/** Disables texture filtering for crisper pixel art
|
|
438
|
-
* @param {
|
|
440
|
+
* @param {boolean} pixelated
|
|
439
441
|
* @memberof Settings */
|
|
440
442
|
export function setTilesPixelated(pixelated: boolean): void;
|
|
441
443
|
/** Set default font used for text rendering
|
|
442
|
-
* @param {
|
|
444
|
+
* @param {string} font
|
|
443
445
|
* @memberof Settings */
|
|
444
446
|
export function setFontDefault(font: string): void;
|
|
445
447
|
/** Set if the LittleJS splash screen be shown on startup
|
|
446
|
-
* @param {
|
|
448
|
+
* @param {boolean} show
|
|
447
449
|
* @memberof Settings */
|
|
448
450
|
export function setShowSplashScreen(show: boolean): void;
|
|
449
451
|
/** Set to disable rendering, audio, and input for servers
|
|
450
|
-
* @param {
|
|
452
|
+
* @param {boolean} headless
|
|
451
453
|
* @memberof Settings */
|
|
452
454
|
export function setHeadlessMode(headless: boolean): void;
|
|
453
455
|
/** Set if webgl rendering is enabled
|
|
454
|
-
* @param {
|
|
456
|
+
* @param {boolean} enable
|
|
455
457
|
* @memberof Settings */
|
|
456
458
|
export function setGlEnable(enable: boolean): void;
|
|
457
459
|
/** Set to not composite the WebGL canvas
|
|
458
|
-
* @param {
|
|
460
|
+
* @param {boolean} overlay
|
|
459
461
|
* @memberof Settings */
|
|
460
462
|
export function setGlOverlay(overlay: boolean): void;
|
|
461
463
|
/** Set default size of tiles in pixels
|
|
@@ -463,103 +465,103 @@ declare module "littlejsengine" {
|
|
|
463
465
|
* @memberof Settings */
|
|
464
466
|
export function setTileSizeDefault(size: Vector2): void;
|
|
465
467
|
/** Set to prevent tile bleeding from neighbors in pixels
|
|
466
|
-
* @param {
|
|
468
|
+
* @param {number} scale
|
|
467
469
|
* @memberof Settings */
|
|
468
470
|
export function setTileFixBleedScale(scale: number): void;
|
|
469
471
|
/** Set if collisions between objects are enabled
|
|
470
|
-
* @param {
|
|
472
|
+
* @param {boolean} enable
|
|
471
473
|
* @memberof Settings */
|
|
472
474
|
export function setEnablePhysicsSolver(enable: boolean): void;
|
|
473
475
|
/** Set default object mass for collision calculations
|
|
474
|
-
* @param {
|
|
476
|
+
* @param {number} mass
|
|
475
477
|
* @memberof Settings */
|
|
476
478
|
export function setObjectDefaultMass(mass: number): void;
|
|
477
479
|
/** Set how much to slow velocity by each frame
|
|
478
|
-
* @param {
|
|
480
|
+
* @param {number} damp
|
|
479
481
|
* @memberof Settings */
|
|
480
482
|
export function setObjectDefaultDamping(damp: number): void;
|
|
481
483
|
/** Set how much to slow angular velocity each frame
|
|
482
|
-
* @param {
|
|
484
|
+
* @param {number} damp
|
|
483
485
|
* @memberof Settings */
|
|
484
486
|
export function setObjectDefaultAngleDamping(damp: number): void;
|
|
485
487
|
/** Set how much to bounce when a collision occur
|
|
486
|
-
* @param {
|
|
488
|
+
* @param {number} elasticity
|
|
487
489
|
* @memberof Settings */
|
|
488
490
|
export function setObjectDefaultElasticity(elasticity: number): void;
|
|
489
491
|
/** Set how much to slow when touching
|
|
490
|
-
* @param {
|
|
492
|
+
* @param {number} friction
|
|
491
493
|
* @memberof Settings */
|
|
492
494
|
export function setObjectDefaultFriction(friction: number): void;
|
|
493
495
|
/** Set max speed to avoid fast objects missing collisions
|
|
494
|
-
* @param {
|
|
496
|
+
* @param {number} speed
|
|
495
497
|
* @memberof Settings */
|
|
496
498
|
export function setObjectMaxSpeed(speed: number): void;
|
|
497
499
|
/** Set how much gravity to apply to objects along the Y axis
|
|
498
|
-
* @param {
|
|
500
|
+
* @param {number} newGravity
|
|
499
501
|
* @memberof Settings */
|
|
500
502
|
export function setGravity(newGravity: number): void;
|
|
501
503
|
/** Set to scales emit rate of particles
|
|
502
|
-
* @param {
|
|
504
|
+
* @param {number} scale
|
|
503
505
|
* @memberof Settings */
|
|
504
506
|
export function setParticleEmitRateScale(scale: number): void;
|
|
505
507
|
/** Set if touch input is allowed
|
|
506
|
-
* @param {
|
|
508
|
+
* @param {boolean} enable
|
|
507
509
|
* @memberof Settings */
|
|
508
510
|
export function setTouchInputEnable(enable: boolean): void;
|
|
509
511
|
/** Set if gamepads are enabled
|
|
510
|
-
* @param {
|
|
512
|
+
* @param {boolean} enable
|
|
511
513
|
* @memberof Settings */
|
|
512
514
|
export function setGamepadsEnable(enable: boolean): void;
|
|
513
515
|
/** Set if the dpad input is also routed to the left analog stick
|
|
514
|
-
* @param {
|
|
516
|
+
* @param {boolean} enable
|
|
515
517
|
* @memberof Settings */
|
|
516
518
|
export function setGamepadDirectionEmulateStick(enable: boolean): void;
|
|
517
519
|
/** Set if true the WASD keys are also routed to the direction keys
|
|
518
|
-
* @param {
|
|
520
|
+
* @param {boolean} enable
|
|
519
521
|
* @memberof Settings */
|
|
520
522
|
export function setInputWASDEmulateDirection(enable: boolean): void;
|
|
521
523
|
/** Set if touch gamepad should appear on mobile devices
|
|
522
|
-
* @param {
|
|
524
|
+
* @param {boolean} enable
|
|
523
525
|
* @memberof Settings */
|
|
524
526
|
export function setTouchGamepadEnable(enable: boolean): void;
|
|
525
527
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
526
|
-
* @param {
|
|
528
|
+
* @param {boolean} analog
|
|
527
529
|
* @memberof Settings */
|
|
528
530
|
export function setTouchGamepadAnalog(analog: boolean): void;
|
|
529
531
|
/** Set size of virtual gamepad for touch devices in pixels
|
|
530
|
-
* @param {
|
|
532
|
+
* @param {number} size
|
|
531
533
|
* @memberof Settings */
|
|
532
534
|
export function setTouchGamepadSize(size: number): void;
|
|
533
535
|
/** Set transparency of touch gamepad overlay
|
|
534
|
-
* @param {
|
|
536
|
+
* @param {number} alpha
|
|
535
537
|
* @memberof Settings */
|
|
536
538
|
export function setTouchGamepadAlpha(alpha: number): void;
|
|
537
539
|
/** Set to allow vibration hardware if it exists
|
|
538
|
-
* @param {
|
|
540
|
+
* @param {boolean} enable
|
|
539
541
|
* @memberof Settings */
|
|
540
542
|
export function setVibrateEnable(enable: boolean): void;
|
|
541
543
|
/** Set to disable all audio code
|
|
542
|
-
* @param {
|
|
544
|
+
* @param {boolean} enable
|
|
543
545
|
* @memberof Settings */
|
|
544
546
|
export function setSoundEnable(enable: boolean): void;
|
|
545
547
|
/** Set volume scale to apply to all sound, music and speech
|
|
546
|
-
* @param {
|
|
548
|
+
* @param {number} volume
|
|
547
549
|
* @memberof Settings */
|
|
548
550
|
export function setSoundVolume(volume: number): void;
|
|
549
551
|
/** Set default range where sound no longer plays
|
|
550
|
-
* @param {
|
|
552
|
+
* @param {number} range
|
|
551
553
|
* @memberof Settings */
|
|
552
554
|
export function setSoundDefaultRange(range: number): void;
|
|
553
555
|
/** Set default range percent to start tapering off sound
|
|
554
|
-
* @param {
|
|
556
|
+
* @param {number} taper
|
|
555
557
|
* @memberof Settings */
|
|
556
558
|
export function setSoundDefaultTaper(taper: number): void;
|
|
557
559
|
/** Set how long to show medals for in seconds
|
|
558
|
-
* @param {
|
|
560
|
+
* @param {number} time
|
|
559
561
|
* @memberof Settings */
|
|
560
562
|
export function setMedalDisplayTime(time: number): void;
|
|
561
563
|
/** Set how quickly to slide on/off medals in seconds
|
|
562
|
-
* @param {
|
|
564
|
+
* @param {number} time
|
|
563
565
|
* @memberof Settings */
|
|
564
566
|
export function setMedalDisplaySlideTime(time: number): void;
|
|
565
567
|
/** Set size of medal display
|
|
@@ -567,19 +569,19 @@ declare module "littlejsengine" {
|
|
|
567
569
|
* @memberof Settings */
|
|
568
570
|
export function setMedalDisplaySize(size: Vector2): void;
|
|
569
571
|
/** Set size of icon in medal display
|
|
570
|
-
* @param {
|
|
572
|
+
* @param {number} size
|
|
571
573
|
* @memberof Settings */
|
|
572
574
|
export function setMedalDisplayIconSize(size: number): void;
|
|
573
575
|
/** Set to stop medals from being unlockable
|
|
574
|
-
* @param {
|
|
576
|
+
* @param {boolean} preventUnlock
|
|
575
577
|
* @memberof Settings */
|
|
576
578
|
export function setMedalsPreventUnlock(preventUnlock: boolean): void;
|
|
577
579
|
/** Set if watermark with FPS should be shown
|
|
578
|
-
* @param {
|
|
580
|
+
* @param {boolean} show
|
|
579
581
|
* @memberof Debug */
|
|
580
582
|
export function setShowWatermark(show: boolean): void;
|
|
581
583
|
/** Set key code used to toggle debug mode, Esc by default
|
|
582
|
-
* @param {
|
|
584
|
+
* @param {string} key
|
|
583
585
|
* @memberof Debug */
|
|
584
586
|
export function setDebugKey(key: string): void;
|
|
585
587
|
/**
|
|
@@ -592,95 +594,95 @@ declare module "littlejsengine" {
|
|
|
592
594
|
* @namespace Utilities
|
|
593
595
|
*/
|
|
594
596
|
/** A shortcut to get Math.PI
|
|
595
|
-
* @type {
|
|
597
|
+
* @type {number}
|
|
596
598
|
* @default Math.PI
|
|
597
599
|
* @memberof Utilities */
|
|
598
600
|
export const PI: number;
|
|
599
601
|
/** Returns absolute value of value passed in
|
|
600
|
-
* @param {
|
|
601
|
-
* @return {
|
|
602
|
+
* @param {number} value
|
|
603
|
+
* @return {number}
|
|
602
604
|
* @memberof Utilities */
|
|
603
605
|
export function abs(value: number): number;
|
|
604
606
|
/** Returns lowest of two values passed in
|
|
605
|
-
* @param {
|
|
606
|
-
* @param {
|
|
607
|
-
* @return {
|
|
607
|
+
* @param {number} valueA
|
|
608
|
+
* @param {number} valueB
|
|
609
|
+
* @return {number}
|
|
608
610
|
* @memberof Utilities */
|
|
609
611
|
export function min(valueA: number, valueB: number): number;
|
|
610
612
|
/** Returns highest of two values passed in
|
|
611
|
-
* @param {
|
|
612
|
-
* @param {
|
|
613
|
-
* @return {
|
|
613
|
+
* @param {number} valueA
|
|
614
|
+
* @param {number} valueB
|
|
615
|
+
* @return {number}
|
|
614
616
|
* @memberof Utilities */
|
|
615
617
|
export function max(valueA: number, valueB: number): number;
|
|
616
618
|
/** Returns the sign of value passed in
|
|
617
|
-
* @param {
|
|
618
|
-
* @return {
|
|
619
|
+
* @param {number} value
|
|
620
|
+
* @return {number}
|
|
619
621
|
* @memberof Utilities */
|
|
620
622
|
export function sign(value: number): number;
|
|
621
623
|
/** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
|
|
622
|
-
* @param {
|
|
623
|
-
* @param {
|
|
624
|
-
* @return {
|
|
624
|
+
* @param {number} dividend
|
|
625
|
+
* @param {number} [divisor]
|
|
626
|
+
* @return {number}
|
|
625
627
|
* @memberof Utilities */
|
|
626
628
|
export function mod(dividend: number, divisor?: number): number;
|
|
627
629
|
/** Clamps the value between max and min
|
|
628
|
-
* @param {
|
|
629
|
-
* @param {
|
|
630
|
-
* @param {
|
|
631
|
-
* @return {
|
|
630
|
+
* @param {number} value
|
|
631
|
+
* @param {number} [min]
|
|
632
|
+
* @param {number} [max]
|
|
633
|
+
* @return {number}
|
|
632
634
|
* @memberof Utilities */
|
|
633
635
|
export function clamp(value: number, min?: number, max?: number): number;
|
|
634
636
|
/** Returns what percentage the value is between valueA and valueB
|
|
635
|
-
* @param {
|
|
636
|
-
* @param {
|
|
637
|
-
* @param {
|
|
638
|
-
* @return {
|
|
637
|
+
* @param {number} value
|
|
638
|
+
* @param {number} valueA
|
|
639
|
+
* @param {number} valueB
|
|
640
|
+
* @return {number}
|
|
639
641
|
* @memberof Utilities */
|
|
640
642
|
export function percent(value: number, valueA: number, valueB: number): number;
|
|
641
643
|
/** Returns signed wrapped distance between the two values passed in
|
|
642
|
-
* @param {
|
|
643
|
-
* @param {
|
|
644
|
-
* @param {
|
|
645
|
-
* @returns {
|
|
644
|
+
* @param {number} valueA
|
|
645
|
+
* @param {number} valueB
|
|
646
|
+
* @param {number} [wrapSize]
|
|
647
|
+
* @returns {number}
|
|
646
648
|
* @memberof Utilities */
|
|
647
649
|
export function distanceWrap(valueA: number, valueB: number, wrapSize?: number): number;
|
|
648
650
|
/** Linearly interpolates between values passed in with wrapping
|
|
649
|
-
* @param {
|
|
650
|
-
* @param {
|
|
651
|
-
* @param {
|
|
652
|
-
* @param {
|
|
653
|
-
* @returns {
|
|
651
|
+
* @param {number} percent
|
|
652
|
+
* @param {number} valueA
|
|
653
|
+
* @param {number} valueB
|
|
654
|
+
* @param {number} [wrapSize]
|
|
655
|
+
* @returns {number}
|
|
654
656
|
* @memberof Utilities */
|
|
655
657
|
export function lerpWrap(percent: number, valueA: number, valueB: number, wrapSize?: number): number;
|
|
656
658
|
/** Returns signed wrapped distance between the two angles passed in
|
|
657
|
-
* @param {
|
|
658
|
-
* @param {
|
|
659
|
-
* @returns {
|
|
659
|
+
* @param {number} angleA
|
|
660
|
+
* @param {number} angleB
|
|
661
|
+
* @returns {number}
|
|
660
662
|
* @memberof Utilities */
|
|
661
663
|
export function distanceAngle(angleA: number, angleB: number): number;
|
|
662
664
|
/** Linearly interpolates between the angles passed in with wrapping
|
|
663
|
-
* @param {
|
|
664
|
-
* @param {
|
|
665
|
-
* @param {
|
|
666
|
-
* @returns {
|
|
665
|
+
* @param {number} percent
|
|
666
|
+
* @param {number} angleA
|
|
667
|
+
* @param {number} angleB
|
|
668
|
+
* @returns {number}
|
|
667
669
|
* @memberof Utilities */
|
|
668
670
|
export function lerpAngle(percent: number, angleA: number, angleB: number): number;
|
|
669
671
|
/** Linearly interpolates between values passed in using percent
|
|
670
|
-
* @param {
|
|
671
|
-
* @param {
|
|
672
|
-
* @param {
|
|
673
|
-
* @return {
|
|
672
|
+
* @param {number} percent
|
|
673
|
+
* @param {number} valueA
|
|
674
|
+
* @param {number} valueB
|
|
675
|
+
* @return {number}
|
|
674
676
|
* @memberof Utilities */
|
|
675
677
|
export function lerp(percent: number, valueA: number, valueB: number): number;
|
|
676
678
|
/** Applies smoothstep function to the percentage value
|
|
677
|
-
* @param {
|
|
678
|
-
* @return {
|
|
679
|
+
* @param {number} percent
|
|
680
|
+
* @return {number}
|
|
679
681
|
* @memberof Utilities */
|
|
680
682
|
export function smoothStep(percent: number): number;
|
|
681
683
|
/** Returns the nearest power of two not less then the value
|
|
682
|
-
* @param {
|
|
683
|
-
* @return {
|
|
684
|
+
* @param {number} value
|
|
685
|
+
* @return {number}
|
|
684
686
|
* @memberof Utilities */
|
|
685
687
|
export function nearestPowerOfTwo(value: number): number;
|
|
686
688
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
@@ -688,7 +690,7 @@ declare module "littlejsengine" {
|
|
|
688
690
|
* @param {Vector2} sizeA - Size of box A
|
|
689
691
|
* @param {Vector2} posB - Center of box B
|
|
690
692
|
* @param {Vector2} [sizeB=(0,0)] - Size of box B, a point if undefined
|
|
691
|
-
* @return {
|
|
693
|
+
* @return {boolean} - True if overlapping
|
|
692
694
|
* @memberof Utilities */
|
|
693
695
|
export function isOverlapping(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB?: Vector2): boolean;
|
|
694
696
|
/** Returns true if a line segment is intersecting an axis aligned box
|
|
@@ -696,55 +698,55 @@ declare module "littlejsengine" {
|
|
|
696
698
|
* @param {Vector2} end - End of raycast
|
|
697
699
|
* @param {Vector2} pos - Center of box
|
|
698
700
|
* @param {Vector2} size - Size of box
|
|
699
|
-
* @return {
|
|
701
|
+
* @return {boolean} - True if intersecting
|
|
700
702
|
* @memberof Utilities */
|
|
701
703
|
export function isIntersecting(start: Vector2, end: Vector2, pos: Vector2, size: Vector2): boolean;
|
|
702
704
|
/** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
|
|
703
|
-
* @param {
|
|
704
|
-
* @param {
|
|
705
|
-
* @param {
|
|
706
|
-
* @return {
|
|
705
|
+
* @param {number} [frequency] - Frequency of the wave in Hz
|
|
706
|
+
* @param {number} [amplitude] - Amplitude (max height) of the wave
|
|
707
|
+
* @param {number} [t=time] - Value to use for time of the wave
|
|
708
|
+
* @return {number} - Value waving between 0 and amplitude
|
|
707
709
|
* @memberof Utilities */
|
|
708
710
|
export function wave(frequency?: number, amplitude?: number, t?: number): number;
|
|
709
711
|
/** Formats seconds to mm:ss style for display purposes
|
|
710
|
-
* @param {
|
|
711
|
-
* @return {
|
|
712
|
+
* @param {number} t - time in seconds
|
|
713
|
+
* @return {string}
|
|
712
714
|
* @memberof Utilities */
|
|
713
715
|
export function formatTime(t: number): string;
|
|
714
716
|
/** Random global functions
|
|
715
717
|
* @namespace Random */
|
|
716
718
|
/** Returns a random value between the two values passed in
|
|
717
|
-
* @param {
|
|
718
|
-
* @param {
|
|
719
|
-
* @return {
|
|
719
|
+
* @param {number} [valueA]
|
|
720
|
+
* @param {number} [valueB]
|
|
721
|
+
* @return {number}
|
|
720
722
|
* @memberof Random */
|
|
721
723
|
export function rand(valueA?: number, valueB?: number): number;
|
|
722
724
|
/** Returns a floored random value between the two values passed in
|
|
723
725
|
* The upper bound is exclusive. (If 2 is passed in, result will be 0 or 1)
|
|
724
|
-
* @param {
|
|
725
|
-
* @param {
|
|
726
|
-
* @return {
|
|
726
|
+
* @param {number} valueA
|
|
727
|
+
* @param {number} [valueB]
|
|
728
|
+
* @return {number}
|
|
727
729
|
* @memberof Random */
|
|
728
730
|
export function randInt(valueA: number, valueB?: number): number;
|
|
729
731
|
/** Randomly returns either -1 or 1
|
|
730
|
-
* @return {
|
|
732
|
+
* @return {number}
|
|
731
733
|
* @memberof Random */
|
|
732
734
|
export function randSign(): number;
|
|
733
735
|
/** Returns a random Vector2 within a circular shape
|
|
734
|
-
* @param {
|
|
735
|
-
* @param {
|
|
736
|
+
* @param {number} [radius]
|
|
737
|
+
* @param {number} [minRadius]
|
|
736
738
|
* @return {Vector2}
|
|
737
739
|
* @memberof Random */
|
|
738
740
|
export function randInCircle(radius?: number, minRadius?: number): Vector2;
|
|
739
741
|
/** Returns a random Vector2 with the passed in length
|
|
740
|
-
* @param {
|
|
742
|
+
* @param {number} [length]
|
|
741
743
|
* @return {Vector2}
|
|
742
744
|
* @memberof Random */
|
|
743
745
|
export function randVector(length?: number): Vector2;
|
|
744
746
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
745
747
|
* @param {Color} [colorA=(1,1,1,1)]
|
|
746
748
|
* @param {Color} [colorB=(0,0,0,1)]
|
|
747
|
-
* @param {
|
|
749
|
+
* @param {boolean} [linear]
|
|
748
750
|
* @return {Color}
|
|
749
751
|
* @memberof Random */
|
|
750
752
|
export function randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
@@ -760,22 +762,22 @@ declare module "littlejsengine" {
|
|
|
760
762
|
*/
|
|
761
763
|
export class RandomGenerator {
|
|
762
764
|
/** Create a random number generator with the seed passed in
|
|
763
|
-
* @param {
|
|
765
|
+
* @param {number} seed - Starting seed */
|
|
764
766
|
constructor(seed: number);
|
|
765
|
-
/** @property {
|
|
767
|
+
/** @property {number} - random seed */
|
|
766
768
|
seed: number;
|
|
767
769
|
/** Returns a seeded random value between the two values passed in
|
|
768
|
-
* @param {
|
|
769
|
-
* @param {
|
|
770
|
-
* @return {
|
|
770
|
+
* @param {number} [valueA]
|
|
771
|
+
* @param {number} [valueB]
|
|
772
|
+
* @return {number} */
|
|
771
773
|
float(valueA?: number, valueB?: number): number;
|
|
772
774
|
/** Returns a floored seeded random value the two values passed in
|
|
773
|
-
* @param {
|
|
774
|
-
* @param {
|
|
775
|
-
* @return {
|
|
775
|
+
* @param {number} valueA
|
|
776
|
+
* @param {number} [valueB]
|
|
777
|
+
* @return {number} */
|
|
776
778
|
int(valueA: number, valueB?: number): number;
|
|
777
779
|
/** Randomly returns either -1 or 1 deterministically
|
|
778
|
-
* @return {
|
|
780
|
+
* @return {number} */
|
|
779
781
|
sign(): number;
|
|
780
782
|
}
|
|
781
783
|
/**
|
|
@@ -789,16 +791,16 @@ declare module "littlejsengine" {
|
|
|
789
791
|
*/
|
|
790
792
|
export class Vector2 {
|
|
791
793
|
/** Create a 2D vector with the x and y passed in, can also be created with vec2()
|
|
792
|
-
* @param {
|
|
793
|
-
* @param {
|
|
794
|
+
* @param {number} [x] - X axis location
|
|
795
|
+
* @param {number} [y] - Y axis location */
|
|
794
796
|
constructor(x?: number, y?: number);
|
|
795
|
-
/** @property {
|
|
797
|
+
/** @property {number} - X axis location */
|
|
796
798
|
x: number;
|
|
797
|
-
/** @property {
|
|
799
|
+
/** @property {number} - Y axis location */
|
|
798
800
|
y: number;
|
|
799
801
|
/** Sets values of this vector and returns self
|
|
800
|
-
* @param {
|
|
801
|
-
* @param {
|
|
802
|
+
* @param {number} [x] - X axis location
|
|
803
|
+
* @param {number} [y] - Y axis location
|
|
802
804
|
* @return {Vector2} */
|
|
803
805
|
set(x?: number, y?: number): Vector2;
|
|
804
806
|
/** Returns a new vector that is a copy of this
|
|
@@ -821,57 +823,57 @@ declare module "littlejsengine" {
|
|
|
821
823
|
* @return {Vector2} */
|
|
822
824
|
divide(v: Vector2): Vector2;
|
|
823
825
|
/** Returns a copy of this vector scaled by the vector passed in
|
|
824
|
-
* @param {
|
|
826
|
+
* @param {number} s - scale
|
|
825
827
|
* @return {Vector2} */
|
|
826
828
|
scale(s: number): Vector2;
|
|
827
829
|
/** Returns the length of this vector
|
|
828
|
-
* @return {
|
|
830
|
+
* @return {number} */
|
|
829
831
|
length(): number;
|
|
830
832
|
/** Returns the length of this vector squared
|
|
831
|
-
* @return {
|
|
833
|
+
* @return {number} */
|
|
832
834
|
lengthSquared(): number;
|
|
833
835
|
/** Returns the distance from this vector to vector passed in
|
|
834
836
|
* @param {Vector2} v - other vector
|
|
835
|
-
* @return {
|
|
837
|
+
* @return {number} */
|
|
836
838
|
distance(v: Vector2): number;
|
|
837
839
|
/** Returns the distance squared from this vector to vector passed in
|
|
838
840
|
* @param {Vector2} v - other vector
|
|
839
|
-
* @return {
|
|
841
|
+
* @return {number} */
|
|
840
842
|
distanceSquared(v: Vector2): number;
|
|
841
843
|
/** Returns a new vector in same direction as this one with the length passed in
|
|
842
|
-
* @param {
|
|
844
|
+
* @param {number} [length]
|
|
843
845
|
* @return {Vector2} */
|
|
844
846
|
normalize(length?: number): Vector2;
|
|
845
847
|
/** Returns a new vector clamped to length passed in
|
|
846
|
-
* @param {
|
|
848
|
+
* @param {number} [length]
|
|
847
849
|
* @return {Vector2} */
|
|
848
850
|
clampLength(length?: number): Vector2;
|
|
849
851
|
/** Returns the dot product of this and the vector passed in
|
|
850
852
|
* @param {Vector2} v - other vector
|
|
851
|
-
* @return {
|
|
853
|
+
* @return {number} */
|
|
852
854
|
dot(v: Vector2): number;
|
|
853
855
|
/** Returns the cross product of this and the vector passed in
|
|
854
856
|
* @param {Vector2} v - other vector
|
|
855
|
-
* @return {
|
|
857
|
+
* @return {number} */
|
|
856
858
|
cross(v: Vector2): number;
|
|
857
859
|
/** Returns the clockwise angle of this vector, up is angle 0
|
|
858
|
-
* @return {
|
|
860
|
+
* @return {number} */
|
|
859
861
|
angle(): number;
|
|
860
862
|
/** Sets this vector with clockwise angle and length passed in
|
|
861
|
-
* @param {
|
|
862
|
-
* @param {
|
|
863
|
+
* @param {number} [angle]
|
|
864
|
+
* @param {number} [length]
|
|
863
865
|
* @return {Vector2} */
|
|
864
866
|
setAngle(angle?: number, length?: number): Vector2;
|
|
865
867
|
/** Returns copy of this vector rotated by the clockwise angle passed in
|
|
866
|
-
* @param {
|
|
868
|
+
* @param {number} angle
|
|
867
869
|
* @return {Vector2} */
|
|
868
870
|
rotate(angle: number): Vector2;
|
|
869
871
|
/** Set the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)
|
|
870
|
-
* @param {
|
|
871
|
-
* @param {
|
|
872
|
+
* @param {number} [direction]
|
|
873
|
+
* @param {number} [length] */
|
|
872
874
|
setDirection(direction?: number, length?: number): Vector2;
|
|
873
875
|
/** Returns the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3)
|
|
874
|
-
* @return {
|
|
876
|
+
* @return {number} */
|
|
875
877
|
direction(): number;
|
|
876
878
|
/** Returns a copy of this vector that has been inverted
|
|
877
879
|
* @return {Vector2} */
|
|
@@ -880,23 +882,23 @@ declare module "littlejsengine" {
|
|
|
880
882
|
* @return {Vector2} */
|
|
881
883
|
floor(): Vector2;
|
|
882
884
|
/** Returns the area this vector covers as a rectangle
|
|
883
|
-
* @return {
|
|
885
|
+
* @return {number} */
|
|
884
886
|
area(): number;
|
|
885
887
|
/** Returns a new vector that is p percent between this and the vector passed in
|
|
886
888
|
* @param {Vector2} v - other vector
|
|
887
|
-
* @param {
|
|
889
|
+
* @param {number} percent
|
|
888
890
|
* @return {Vector2} */
|
|
889
891
|
lerp(v: Vector2, percent: number): Vector2;
|
|
890
892
|
/** Returns true if this vector is within the bounds of an array size passed in
|
|
891
893
|
* @param {Vector2} arraySize
|
|
892
|
-
* @return {
|
|
894
|
+
* @return {boolean} */
|
|
893
895
|
arrayCheck(arraySize: Vector2): boolean;
|
|
894
896
|
/** Returns this vector expressed as a string
|
|
895
|
-
* @param {
|
|
896
|
-
* @return {
|
|
897
|
+
* @param {number} digits - precision to display
|
|
898
|
+
* @return {string} */
|
|
897
899
|
toString(digits?: number): string;
|
|
898
900
|
/** Checks if this is a valid vector
|
|
899
|
-
* @return {
|
|
901
|
+
* @return {boolean} */
|
|
900
902
|
isValid(): boolean;
|
|
901
903
|
}
|
|
902
904
|
/**
|
|
@@ -910,24 +912,24 @@ declare module "littlejsengine" {
|
|
|
910
912
|
*/
|
|
911
913
|
export class Color {
|
|
912
914
|
/** Create a color with the rgba components passed in, white by default
|
|
913
|
-
* @param {
|
|
914
|
-
* @param {
|
|
915
|
-
* @param {
|
|
916
|
-
* @param {
|
|
915
|
+
* @param {number} [r] - red
|
|
916
|
+
* @param {number} [g] - green
|
|
917
|
+
* @param {number} [b] - blue
|
|
918
|
+
* @param {number} [a] - alpha*/
|
|
917
919
|
constructor(r?: number, g?: number, b?: number, a?: number);
|
|
918
|
-
/** @property {
|
|
920
|
+
/** @property {number} - Red */
|
|
919
921
|
r: number;
|
|
920
|
-
/** @property {
|
|
922
|
+
/** @property {number} - Green */
|
|
921
923
|
g: number;
|
|
922
|
-
/** @property {
|
|
924
|
+
/** @property {number} - Blue */
|
|
923
925
|
b: number;
|
|
924
|
-
/** @property {
|
|
926
|
+
/** @property {number} - Alpha */
|
|
925
927
|
a: number;
|
|
926
928
|
/** Sets values of this color and returns self
|
|
927
|
-
* @param {
|
|
928
|
-
* @param {
|
|
929
|
-
* @param {
|
|
930
|
-
* @param {
|
|
929
|
+
* @param {number} [r] - red
|
|
930
|
+
* @param {number} [g] - green
|
|
931
|
+
* @param {number} [b] - blue
|
|
932
|
+
* @param {number} [a] - alpha
|
|
931
933
|
* @return {Color} */
|
|
932
934
|
set(r?: number, g?: number, b?: number, a?: number): Color;
|
|
933
935
|
/** Returns a new color that is a copy of this
|
|
@@ -950,8 +952,8 @@ declare module "littlejsengine" {
|
|
|
950
952
|
* @return {Color} */
|
|
951
953
|
divide(c: Color): Color;
|
|
952
954
|
/** Returns a copy of this color scaled by the value passed in, alpha can be scaled separately
|
|
953
|
-
* @param {
|
|
954
|
-
* @param {
|
|
955
|
+
* @param {number} scale
|
|
956
|
+
* @param {number} [alphaScale=scale]
|
|
955
957
|
* @return {Color} */
|
|
956
958
|
scale(scale: number, alphaScale?: number): Color;
|
|
957
959
|
/** Returns a copy of this color clamped to the valid range between 0 and 1
|
|
@@ -959,37 +961,37 @@ declare module "littlejsengine" {
|
|
|
959
961
|
clamp(): Color;
|
|
960
962
|
/** Returns a new color that is p percent between this and the color passed in
|
|
961
963
|
* @param {Color} c - other color
|
|
962
|
-
* @param {
|
|
964
|
+
* @param {number} percent
|
|
963
965
|
* @return {Color} */
|
|
964
966
|
lerp(c: Color, percent: number): Color;
|
|
965
967
|
/** Sets this color given a hue, saturation, lightness, and alpha
|
|
966
|
-
* @param {
|
|
967
|
-
* @param {
|
|
968
|
-
* @param {
|
|
969
|
-
* @param {
|
|
968
|
+
* @param {number} [h] - hue
|
|
969
|
+
* @param {number} [s] - saturation
|
|
970
|
+
* @param {number} [l] - lightness
|
|
971
|
+
* @param {number} [a] - alpha
|
|
970
972
|
* @return {Color} */
|
|
971
973
|
setHSLA(h?: number, s?: number, l?: number, a?: number): Color;
|
|
972
974
|
/** Returns this color expressed in hsla format
|
|
973
|
-
* @return {Array} */
|
|
974
|
-
HSLA():
|
|
975
|
+
* @return {Array<number>} */
|
|
976
|
+
HSLA(): Array<number>;
|
|
975
977
|
/** Returns a new color that has each component randomly adjusted
|
|
976
|
-
* @param {
|
|
977
|
-
* @param {
|
|
978
|
+
* @param {number} [amount]
|
|
979
|
+
* @param {number} [alphaAmount]
|
|
978
980
|
* @return {Color} */
|
|
979
981
|
mutate(amount?: number, alphaAmount?: number): Color;
|
|
980
982
|
/** Returns this color expressed as a hex color code
|
|
981
|
-
* @param {
|
|
982
|
-
* @return {
|
|
983
|
+
* @param {boolean} [useAlpha] - if alpha should be included in result
|
|
984
|
+
* @return {string} */
|
|
983
985
|
toString(useAlpha?: boolean): string;
|
|
984
986
|
/** Set this color from a hex code
|
|
985
|
-
* @param {
|
|
987
|
+
* @param {string} hex - html hex code
|
|
986
988
|
* @return {Color} */
|
|
987
989
|
setHex(hex: string): Color;
|
|
988
990
|
/** Returns this color expressed as 32 bit RGBA value
|
|
989
|
-
* @return {
|
|
991
|
+
* @return {number} */
|
|
990
992
|
rgbaInt(): number;
|
|
991
993
|
/** Checks if this is a valid color
|
|
992
|
-
* @return {
|
|
994
|
+
* @return {boolean} */
|
|
993
995
|
isValid(): boolean;
|
|
994
996
|
}
|
|
995
997
|
/**
|
|
@@ -1003,41 +1005,41 @@ declare module "littlejsengine" {
|
|
|
1003
1005
|
*/
|
|
1004
1006
|
export class Timer {
|
|
1005
1007
|
/** Create a timer object set time passed in
|
|
1006
|
-
* @param {
|
|
1008
|
+
* @param {number} [timeLeft] - How much time left before the timer elapses in seconds */
|
|
1007
1009
|
constructor(timeLeft?: number);
|
|
1008
1010
|
time: number;
|
|
1009
1011
|
setTime: number;
|
|
1010
1012
|
/** Set the timer with seconds passed in
|
|
1011
|
-
* @param {
|
|
1013
|
+
* @param {number} [timeLeft] - How much time left before the timer is elapsed in seconds */
|
|
1012
1014
|
set(timeLeft?: number): void;
|
|
1013
1015
|
/** Unset the timer */
|
|
1014
1016
|
unset(): void;
|
|
1015
1017
|
/** Returns true if set
|
|
1016
|
-
* @return {
|
|
1018
|
+
* @return {boolean} */
|
|
1017
1019
|
isSet(): boolean;
|
|
1018
1020
|
/** Returns true if set and has not elapsed
|
|
1019
|
-
* @return {
|
|
1021
|
+
* @return {boolean} */
|
|
1020
1022
|
active(): boolean;
|
|
1021
1023
|
/** Returns true if set and elapsed
|
|
1022
|
-
* @return {
|
|
1024
|
+
* @return {boolean} */
|
|
1023
1025
|
elapsed(): boolean;
|
|
1024
1026
|
/** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
|
|
1025
|
-
* @return {
|
|
1027
|
+
* @return {number} */
|
|
1026
1028
|
get(): number;
|
|
1027
1029
|
/** Get percentage elapsed based on time it was set to, returns 0 if not set
|
|
1028
|
-
* @return {
|
|
1030
|
+
* @return {number} */
|
|
1029
1031
|
getPercent(): number;
|
|
1030
1032
|
/** Returns this timer expressed as a string
|
|
1031
|
-
* @return {
|
|
1033
|
+
* @return {string} */
|
|
1032
1034
|
toString(): string;
|
|
1033
1035
|
/** Get how long since elapsed, returns 0 if not set (returns negative if currently active)
|
|
1034
|
-
* @return {
|
|
1036
|
+
* @return {number} */
|
|
1035
1037
|
valueOf(): number;
|
|
1036
1038
|
}
|
|
1037
1039
|
/**
|
|
1038
1040
|
* Create a 2d vector, can take another Vector2 to copy, 2 scalars, or 1 scalar
|
|
1039
|
-
* @param {
|
|
1040
|
-
* @param {
|
|
1041
|
+
* @param {Vector2|number} [x]
|
|
1042
|
+
* @param {number} [y]
|
|
1041
1043
|
* @return {Vector2}
|
|
1042
1044
|
* @example
|
|
1043
1045
|
* let a = vec2(0, 1); // vector with coordinates (0, 1)
|
|
@@ -1046,23 +1048,23 @@ declare module "littlejsengine" {
|
|
|
1046
1048
|
* b = vec2(); // set b to (0, 0)
|
|
1047
1049
|
* @memberof Utilities
|
|
1048
1050
|
*/
|
|
1049
|
-
export function vec2(x?:
|
|
1051
|
+
export function vec2(x?: Vector2 | number, y?: number): Vector2;
|
|
1050
1052
|
/**
|
|
1051
1053
|
* Create a color object with RGBA values, white by default
|
|
1052
|
-
* @param {
|
|
1053
|
-
* @param {
|
|
1054
|
-
* @param {
|
|
1055
|
-
* @param {
|
|
1054
|
+
* @param {number} [r=1] - red
|
|
1055
|
+
* @param {number} [g=1] - green
|
|
1056
|
+
* @param {number} [b=1] - blue
|
|
1057
|
+
* @param {number} [a=1] - alpha
|
|
1056
1058
|
* @return {Color}
|
|
1057
1059
|
* @memberof Utilities
|
|
1058
1060
|
*/
|
|
1059
1061
|
export function rgb(r?: number, g?: number, b?: number, a?: number): Color;
|
|
1060
1062
|
/**
|
|
1061
1063
|
* Create a color object with HSLA values, white by default
|
|
1062
|
-
* @param {
|
|
1063
|
-
* @param {
|
|
1064
|
-
* @param {
|
|
1065
|
-
* @param {
|
|
1064
|
+
* @param {number} [h=0] - hue
|
|
1065
|
+
* @param {number} [s=0] - saturation
|
|
1066
|
+
* @param {number} [l=1] - lightness
|
|
1067
|
+
* @param {number} [a=1] - alpha
|
|
1066
1068
|
* @return {Color}
|
|
1067
1069
|
* @memberof Utilities
|
|
1068
1070
|
*/
|
|
@@ -1070,7 +1072,7 @@ declare module "littlejsengine" {
|
|
|
1070
1072
|
/**
|
|
1071
1073
|
* Check if object is a valid Color
|
|
1072
1074
|
* @param {any} c
|
|
1073
|
-
* @return {
|
|
1075
|
+
* @return {boolean}
|
|
1074
1076
|
* @memberof Utilities
|
|
1075
1077
|
*/
|
|
1076
1078
|
export function isColor(c: any): boolean;
|
|
@@ -1126,10 +1128,10 @@ declare module "littlejsengine" {
|
|
|
1126
1128
|
* Create a tile info object using a grid based system
|
|
1127
1129
|
* - This can take vecs or floats for easier use and conversion
|
|
1128
1130
|
* - If an index is passed in, the tile size and index will determine the position
|
|
1129
|
-
* @param {
|
|
1130
|
-
* @param {
|
|
1131
|
-
* @param {
|
|
1132
|
-
* @param {
|
|
1131
|
+
* @param {Vector2|number} [pos=0] - Index of tile in sheet
|
|
1132
|
+
* @param {Vector2|number} [size=tileSizeDefault] - Size of tile in pixels
|
|
1133
|
+
* @param {number} [textureIndex] - Texture index to use
|
|
1134
|
+
* @param {number} [padding] - How many pixels padding around tiles
|
|
1133
1135
|
* @return {TileInfo}
|
|
1134
1136
|
* @example
|
|
1135
1137
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
@@ -1138,7 +1140,7 @@ declare module "littlejsengine" {
|
|
|
1138
1140
|
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
1139
1141
|
* @memberof Draw
|
|
1140
1142
|
*/
|
|
1141
|
-
export function tile(pos?:
|
|
1143
|
+
export function tile(pos?: Vector2 | number, size?: Vector2 | number, textureIndex?: number, padding?: number): TileInfo;
|
|
1142
1144
|
/**
|
|
1143
1145
|
* Tile Info - Stores info about how to draw a tile
|
|
1144
1146
|
*/
|
|
@@ -1146,17 +1148,17 @@ declare module "littlejsengine" {
|
|
|
1146
1148
|
/** Create a tile info object
|
|
1147
1149
|
* @param {Vector2} [pos=(0,0)] - Top left corner of tile in pixels
|
|
1148
1150
|
* @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
|
|
1149
|
-
* @param {
|
|
1150
|
-
* @param {
|
|
1151
|
+
* @param {number} [textureIndex] - Texture index to use
|
|
1152
|
+
* @param {number} [padding] - How many pixels padding around tiles
|
|
1151
1153
|
*/
|
|
1152
1154
|
constructor(pos?: Vector2, size?: Vector2, textureIndex?: number, padding?: number);
|
|
1153
1155
|
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
1154
1156
|
pos: Vector2;
|
|
1155
1157
|
/** @property {Vector2} - Size of tile in pixels */
|
|
1156
1158
|
size: Vector2;
|
|
1157
|
-
/** @property {
|
|
1159
|
+
/** @property {number} - Texture index to use */
|
|
1158
1160
|
textureIndex: number;
|
|
1159
|
-
/** @property {
|
|
1161
|
+
/** @property {number} - How many pixels padding around tiles */
|
|
1160
1162
|
padding: number;
|
|
1161
1163
|
/** Returns a copy of this tile offset by a vector
|
|
1162
1164
|
* @param {Vector2} offset - Offset to apply in pixels
|
|
@@ -1164,7 +1166,7 @@ declare module "littlejsengine" {
|
|
|
1164
1166
|
*/
|
|
1165
1167
|
offset(offset: Vector2): TileInfo;
|
|
1166
1168
|
/** Returns a copy of this tile offset by a number of animation frames
|
|
1167
|
-
* @param {
|
|
1169
|
+
* @param {number} frame - Offset to apply in animation frames
|
|
1168
1170
|
* @return {TileInfo}
|
|
1169
1171
|
*/
|
|
1170
1172
|
frame(frame: number): TileInfo;
|
|
@@ -1243,11 +1245,11 @@ declare module "littlejsengine" {
|
|
|
1243
1245
|
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
|
|
1244
1246
|
* @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
|
|
1245
1247
|
* @param {Color} [color=(1,1,1,1)] - Color to modulate with
|
|
1246
|
-
* @param {
|
|
1247
|
-
* @param {
|
|
1248
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1249
|
+
* @param {boolean} [mirror] - If true image is flipped along the Y axis
|
|
1248
1250
|
* @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
|
|
1249
|
-
* @param {
|
|
1250
|
-
* @param {
|
|
1251
|
+
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1252
|
+
* @param {boolean} [screenSpace=false] - If true the pos and size are in screen space
|
|
1251
1253
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1252
1254
|
* @memberof Draw */
|
|
1253
1255
|
export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
@@ -1255,107 +1257,107 @@ declare module "littlejsengine" {
|
|
|
1255
1257
|
* @param {Vector2} pos
|
|
1256
1258
|
* @param {Vector2} [size=(1,1)]
|
|
1257
1259
|
* @param {Color} [color=(1,1,1,1)]
|
|
1258
|
-
* @param {
|
|
1259
|
-
* @param {
|
|
1260
|
-
* @param {
|
|
1260
|
+
* @param {number} [angle]
|
|
1261
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1262
|
+
* @param {boolean} [screenSpace=false]
|
|
1261
1263
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1262
1264
|
* @memberof Draw */
|
|
1263
1265
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1264
1266
|
/** Draw colored line between two points
|
|
1265
1267
|
* @param {Vector2} posA
|
|
1266
1268
|
* @param {Vector2} posB
|
|
1267
|
-
* @param {
|
|
1269
|
+
* @param {number} [thickness]
|
|
1268
1270
|
* @param {Color} [color=(1,1,1,1)]
|
|
1269
|
-
* @param {
|
|
1270
|
-
* @param {
|
|
1271
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1272
|
+
* @param {boolean} [screenSpace=false]
|
|
1271
1273
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1272
1274
|
* @memberof Draw */
|
|
1273
1275
|
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1274
1276
|
/** Draw colored polygon using passed in points
|
|
1275
|
-
* @param {Array} points - Array of Vector2 points
|
|
1277
|
+
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1276
1278
|
* @param {Color} [color=(1,1,1,1)]
|
|
1277
|
-
* @param {
|
|
1279
|
+
* @param {number} [lineWidth=0]
|
|
1278
1280
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1279
|
-
* @param {
|
|
1281
|
+
* @param {boolean} [screenSpace=false]
|
|
1280
1282
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1281
1283
|
* @memberof Draw */
|
|
1282
|
-
export function drawPoly(points:
|
|
1284
|
+
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1283
1285
|
/** Draw colored ellipse using passed in point
|
|
1284
1286
|
* @param {Vector2} pos
|
|
1285
|
-
* @param {
|
|
1286
|
-
* @param {
|
|
1287
|
-
* @param {
|
|
1287
|
+
* @param {number} [width=1]
|
|
1288
|
+
* @param {number} [height=1]
|
|
1289
|
+
* @param {number} [angle=0]
|
|
1288
1290
|
* @param {Color} [color=(1,1,1,1)]
|
|
1289
|
-
* @param {
|
|
1291
|
+
* @param {number} [lineWidth=0]
|
|
1290
1292
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1291
|
-
* @param {
|
|
1293
|
+
* @param {boolean} [screenSpace=false]
|
|
1292
1294
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1293
1295
|
* @memberof Draw */
|
|
1294
1296
|
export function drawEllipse(pos: Vector2, width?: number, height?: number, angle?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1295
1297
|
/** Draw colored circle using passed in point
|
|
1296
1298
|
* @param {Vector2} pos
|
|
1297
|
-
* @param {
|
|
1299
|
+
* @param {number} [radius=1]
|
|
1298
1300
|
* @param {Color} [color=(1,1,1,1)]
|
|
1299
|
-
* @param {
|
|
1301
|
+
* @param {number} [lineWidth=0]
|
|
1300
1302
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1301
|
-
* @param {
|
|
1303
|
+
* @param {boolean} [screenSpace=false]
|
|
1302
1304
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1303
1305
|
* @memberof Draw */
|
|
1304
1306
|
export function drawCircle(pos: Vector2, radius?: number, color?: Color, lineWidth?: number, lineColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
1305
1307
|
/** Draw directly to a 2d canvas context in world space
|
|
1306
1308
|
* @param {Vector2} pos
|
|
1307
1309
|
* @param {Vector2} size
|
|
1308
|
-
* @param {
|
|
1309
|
-
* @param {
|
|
1310
|
+
* @param {number} angle
|
|
1311
|
+
* @param {boolean} mirror
|
|
1310
1312
|
* @param {Function} drawFunction
|
|
1311
|
-
* @param {
|
|
1313
|
+
* @param {boolean} [screenSpace=false]
|
|
1312
1314
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1313
1315
|
* @memberof Draw */
|
|
1314
1316
|
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1315
1317
|
/** Draw text on main canvas in world space
|
|
1316
1318
|
* Automatically splits new lines into rows
|
|
1317
|
-
* @param {
|
|
1319
|
+
* @param {string} text
|
|
1318
1320
|
* @param {Vector2} pos
|
|
1319
|
-
* @param {
|
|
1321
|
+
* @param {number} [size]
|
|
1320
1322
|
* @param {Color} [color=(1,1,1,1)]
|
|
1321
|
-
* @param {
|
|
1323
|
+
* @param {number} [lineWidth]
|
|
1322
1324
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1323
1325
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1324
|
-
* @param {
|
|
1325
|
-
* @param {
|
|
1326
|
+
* @param {string} [font=fontDefault]
|
|
1327
|
+
* @param {number} [maxWidth]
|
|
1326
1328
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1327
1329
|
* @memberof Draw */
|
|
1328
1330
|
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;
|
|
1329
1331
|
/** Draw text on overlay canvas in world space
|
|
1330
1332
|
* Automatically splits new lines into rows
|
|
1331
|
-
* @param {
|
|
1333
|
+
* @param {string} text
|
|
1332
1334
|
* @param {Vector2} pos
|
|
1333
|
-
* @param {
|
|
1335
|
+
* @param {number} [size]
|
|
1334
1336
|
* @param {Color} [color=(1,1,1,1)]
|
|
1335
|
-
* @param {
|
|
1337
|
+
* @param {number} [lineWidth]
|
|
1336
1338
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1337
1339
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1338
|
-
* @param {
|
|
1339
|
-
* @param {
|
|
1340
|
+
* @param {string} [font=fontDefault]
|
|
1341
|
+
* @param {number} [maxWidth]
|
|
1340
1342
|
* @memberof Draw */
|
|
1341
1343
|
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, maxWidth?: number): void;
|
|
1342
1344
|
/** Draw text on overlay canvas in screen space
|
|
1343
1345
|
* Automatically splits new lines into rows
|
|
1344
|
-
* @param {
|
|
1346
|
+
* @param {string} text
|
|
1345
1347
|
* @param {Vector2} pos
|
|
1346
|
-
* @param {
|
|
1348
|
+
* @param {number} [size]
|
|
1347
1349
|
* @param {Color} [color=(1,1,1,1)]
|
|
1348
|
-
* @param {
|
|
1350
|
+
* @param {number} [lineWidth]
|
|
1349
1351
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1350
1352
|
* @param {CanvasTextAlign} [textAlign]
|
|
1351
|
-
* @param {
|
|
1352
|
-
* @param {
|
|
1353
|
+
* @param {string} [font=fontDefault]
|
|
1354
|
+
* @param {number} [maxWidth]
|
|
1353
1355
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1354
1356
|
* @memberof Draw */
|
|
1355
1357
|
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;
|
|
1356
1358
|
/** Enable normal or additive blend mode
|
|
1357
|
-
* @param {
|
|
1358
|
-
* @param {
|
|
1359
|
+
* @param {boolean} [additive]
|
|
1360
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1359
1361
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=mainContext]
|
|
1360
1362
|
* @memberof Draw */
|
|
1361
1363
|
export function setBlendMode(additive?: boolean, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
@@ -1389,29 +1391,29 @@ declare module "littlejsengine" {
|
|
|
1389
1391
|
paddingSize: Vector2;
|
|
1390
1392
|
context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
1391
1393
|
/** Draw text in world space using the image font
|
|
1392
|
-
* @param {
|
|
1394
|
+
* @param {string} text
|
|
1393
1395
|
* @param {Vector2} pos
|
|
1394
|
-
* @param {
|
|
1395
|
-
* @param {
|
|
1396
|
+
* @param {number} [scale=.25]
|
|
1397
|
+
* @param {boolean} [center]
|
|
1396
1398
|
*/
|
|
1397
1399
|
drawText(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
1398
1400
|
/** Draw text in screen space using the image font
|
|
1399
|
-
* @param {
|
|
1401
|
+
* @param {string} text
|
|
1400
1402
|
* @param {Vector2} pos
|
|
1401
|
-
* @param {
|
|
1402
|
-
* @param {
|
|
1403
|
+
* @param {number} [scale]
|
|
1404
|
+
* @param {boolean} [center]
|
|
1403
1405
|
*/
|
|
1404
1406
|
drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
1405
1407
|
}
|
|
1406
1408
|
/** Returns true if fullscreen mode is active
|
|
1407
|
-
* @return {
|
|
1409
|
+
* @return {boolean}
|
|
1408
1410
|
* @memberof Draw */
|
|
1409
1411
|
export function isFullscreen(): boolean;
|
|
1410
1412
|
/** Toggle fullscreen mode
|
|
1411
1413
|
* @memberof Draw */
|
|
1412
1414
|
export function toggleFullscreen(): void;
|
|
1413
1415
|
/** Set the cursor style
|
|
1414
|
-
* @param {
|
|
1416
|
+
* @param {string} cursorStyle - CSS cursor style (auto, none, crosshair, etc)
|
|
1415
1417
|
* @memberof Draw */
|
|
1416
1418
|
export function setCursor(cursorStyle?: string): void;
|
|
1417
1419
|
/** Get the camera's visible area in world space
|
|
@@ -1445,7 +1447,7 @@ declare module "littlejsengine" {
|
|
|
1445
1447
|
export function glCompileShader(source: string, type: number): WebGLShader;
|
|
1446
1448
|
/** Draw any sprites still in the buffer and copy to main canvas
|
|
1447
1449
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1448
|
-
* @param {
|
|
1450
|
+
* @param {boolean} [forceDraw]
|
|
1449
1451
|
* @memberof WebGL */
|
|
1450
1452
|
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, forceDraw?: boolean): void;
|
|
1451
1453
|
/** Create WebGL program with given shaders
|
|
@@ -1482,14 +1484,14 @@ declare module "littlejsengine" {
|
|
|
1482
1484
|
* @memberof WebGL */
|
|
1483
1485
|
export function glSetTexture(texture: WebGLTexture): void;
|
|
1484
1486
|
/** Set anti-aliasing for webgl canvas
|
|
1485
|
-
* @param {
|
|
1487
|
+
* @param {boolean} [antialias]
|
|
1486
1488
|
* @memberof WebGL */
|
|
1487
1489
|
export function glSetAntialias(antialias?: boolean): void;
|
|
1488
1490
|
/** Clear the canvas and setup the viewport
|
|
1489
1491
|
* @memberof WebGL */
|
|
1490
1492
|
export function glClearCanvas(): void;
|
|
1491
1493
|
/** Should webgl be setup with anti-aliasing? must be set before calling engineInit
|
|
1492
|
-
* @type {
|
|
1494
|
+
* @type {boolean}
|
|
1493
1495
|
* @memberof WebGL */
|
|
1494
1496
|
export let glAntialias: boolean;
|
|
1495
1497
|
export let glShader: any;
|
|
@@ -1511,21 +1513,21 @@ declare module "littlejsengine" {
|
|
|
1511
1513
|
* @namespace Input
|
|
1512
1514
|
*/
|
|
1513
1515
|
/** Returns true if device key is down
|
|
1514
|
-
* @param {
|
|
1515
|
-
* @param {
|
|
1516
|
-
* @return {
|
|
1516
|
+
* @param {string|number} key
|
|
1517
|
+
* @param {number} [device]
|
|
1518
|
+
* @return {boolean}
|
|
1517
1519
|
* @memberof Input */
|
|
1518
1520
|
export function keyIsDown(key: string | number, device?: number): boolean;
|
|
1519
1521
|
/** Returns true if device key was pressed this frame
|
|
1520
|
-
* @param {
|
|
1521
|
-
* @param {
|
|
1522
|
-
* @return {
|
|
1522
|
+
* @param {string|number} key
|
|
1523
|
+
* @param {number} [device]
|
|
1524
|
+
* @return {boolean}
|
|
1523
1525
|
* @memberof Input */
|
|
1524
1526
|
export function keyWasPressed(key: string | number, device?: number): boolean;
|
|
1525
1527
|
/** Returns true if device key was released this frame
|
|
1526
|
-
* @param {
|
|
1527
|
-
* @param {
|
|
1528
|
-
* @return {
|
|
1528
|
+
* @param {string|number} key
|
|
1529
|
+
* @param {number} [device]
|
|
1530
|
+
* @return {boolean}
|
|
1529
1531
|
* @memberof Input */
|
|
1530
1532
|
export function keyWasReleased(key: string | number, device?: number): boolean;
|
|
1531
1533
|
/** Returns input vector from arrow keys or WASD if enabled
|
|
@@ -1545,21 +1547,21 @@ declare module "littlejsengine" {
|
|
|
1545
1547
|
* @namespace Input
|
|
1546
1548
|
*/
|
|
1547
1549
|
/** Returns true if device key is down
|
|
1548
|
-
* @param {
|
|
1549
|
-
* @param {
|
|
1550
|
-
* @return {
|
|
1550
|
+
* @param {string|number} key
|
|
1551
|
+
* @param {number} [device]
|
|
1552
|
+
* @return {boolean}
|
|
1551
1553
|
* @memberof Input */
|
|
1552
1554
|
export function mouseIsDown(key: string | number, device?: number): boolean;
|
|
1553
1555
|
/** Returns true if device key was pressed this frame
|
|
1554
|
-
* @param {
|
|
1555
|
-
* @param {
|
|
1556
|
-
* @return {
|
|
1556
|
+
* @param {string|number} key
|
|
1557
|
+
* @param {number} [device]
|
|
1558
|
+
* @return {boolean}
|
|
1557
1559
|
* @memberof Input */
|
|
1558
1560
|
export function mouseWasPressed(key: string | number, device?: number): boolean;
|
|
1559
1561
|
/** Returns true if device key was released this frame
|
|
1560
|
-
* @param {
|
|
1561
|
-
* @param {
|
|
1562
|
-
* @return {
|
|
1562
|
+
* @param {string|number} key
|
|
1563
|
+
* @param {number} [device]
|
|
1564
|
+
* @return {boolean}
|
|
1563
1565
|
* @memberof Input */
|
|
1564
1566
|
export function mouseWasReleased(key: string | number, device?: number): boolean;
|
|
1565
1567
|
/** Mouse pos in world space
|
|
@@ -1571,44 +1573,44 @@ declare module "littlejsengine" {
|
|
|
1571
1573
|
* @memberof Input */
|
|
1572
1574
|
export let mousePosScreen: Vector2;
|
|
1573
1575
|
/** Mouse wheel delta this frame
|
|
1574
|
-
* @type {
|
|
1576
|
+
* @type {number}
|
|
1575
1577
|
* @memberof Input */
|
|
1576
1578
|
export let mouseWheel: number;
|
|
1577
1579
|
/** Returns true if user is using gamepad (has more recently pressed a gamepad button)
|
|
1578
|
-
* @type {
|
|
1580
|
+
* @type {boolean}
|
|
1579
1581
|
* @memberof Input */
|
|
1580
1582
|
export let isUsingGamepad: boolean;
|
|
1581
1583
|
/** Prevents input continuing to the default browser handling (false by default)
|
|
1582
|
-
* @type {
|
|
1584
|
+
* @type {boolean}
|
|
1583
1585
|
* @memberof Input */
|
|
1584
1586
|
export let preventDefaultInput: boolean;
|
|
1585
1587
|
/** Returns true if gamepad button is down
|
|
1586
|
-
* @param {
|
|
1587
|
-
* @param {
|
|
1588
|
-
* @return {
|
|
1588
|
+
* @param {number} button
|
|
1589
|
+
* @param {number} [gamepad]
|
|
1590
|
+
* @return {boolean}
|
|
1589
1591
|
* @memberof Input */
|
|
1590
1592
|
export function gamepadIsDown(button: number, gamepad?: number): boolean;
|
|
1591
1593
|
/** Returns true if gamepad button was pressed
|
|
1592
|
-
* @param {
|
|
1593
|
-
* @param {
|
|
1594
|
-
* @return {
|
|
1594
|
+
* @param {number} button
|
|
1595
|
+
* @param {number} [gamepad]
|
|
1596
|
+
* @return {boolean}
|
|
1595
1597
|
* @memberof Input */
|
|
1596
1598
|
export function gamepadWasPressed(button: number, gamepad?: number): boolean;
|
|
1597
1599
|
/** Returns true if gamepad button was released
|
|
1598
|
-
* @param {
|
|
1599
|
-
* @param {
|
|
1600
|
-
* @return {
|
|
1600
|
+
* @param {number} button
|
|
1601
|
+
* @param {number} [gamepad]
|
|
1602
|
+
* @return {boolean}
|
|
1601
1603
|
* @memberof Input */
|
|
1602
1604
|
export function gamepadWasReleased(button: number, gamepad?: number): boolean;
|
|
1603
1605
|
/** Returns gamepad stick value
|
|
1604
|
-
* @param {
|
|
1605
|
-
* @param {
|
|
1606
|
+
* @param {number} stick
|
|
1607
|
+
* @param {number} [gamepad]
|
|
1606
1608
|
* @return {Vector2}
|
|
1607
1609
|
* @memberof Input */
|
|
1608
1610
|
export function gamepadStick(stick: number, gamepad?: number): Vector2;
|
|
1609
1611
|
export function gamepadsUpdate(): void;
|
|
1610
1612
|
/** Pulse the vibration hardware if it exists
|
|
1611
|
-
* @param {
|
|
1613
|
+
* @param {number|Array} [pattern] - single value in ms or vibration interval array
|
|
1612
1614
|
* @memberof Input */
|
|
1613
1615
|
export function vibrate(pattern?: number | any[]): void;
|
|
1614
1616
|
/** Cancel any ongoing vibration
|
|
@@ -1631,31 +1633,31 @@ declare module "littlejsengine" {
|
|
|
1631
1633
|
export class Sound {
|
|
1632
1634
|
/** Create a sound object and cache the zzfx samples for later use
|
|
1633
1635
|
* @param {Array} zzfxSound - Array of zzfx parameters, ex. [.5,.5]
|
|
1634
|
-
* @param {
|
|
1635
|
-
* @param {
|
|
1636
|
+
* @param {number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
|
|
1637
|
+
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
1636
1638
|
*/
|
|
1637
1639
|
constructor(zzfxSound: any[], range?: number, taper?: number);
|
|
1638
|
-
/** @property {
|
|
1640
|
+
/** @property {number} - World space max range of sound, will not play if camera is farther away */
|
|
1639
1641
|
range: number;
|
|
1640
|
-
/** @property {
|
|
1642
|
+
/** @property {number} - At what percentage of range should it start tapering off */
|
|
1641
1643
|
taper: number;
|
|
1642
|
-
/** @property {
|
|
1644
|
+
/** @property {number} - How much to randomize frequency each time sound plays */
|
|
1643
1645
|
randomness: any;
|
|
1644
1646
|
sampleChannels: any[][];
|
|
1645
1647
|
sampleRate: number;
|
|
1646
1648
|
/** Play the sound
|
|
1647
1649
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
1648
|
-
* @param {
|
|
1649
|
-
* @param {
|
|
1650
|
-
* @param {
|
|
1651
|
-
* @param {
|
|
1650
|
+
* @param {number} [volume] - How much to scale volume by (in addition to range fade)
|
|
1651
|
+
* @param {number} [pitch] - How much to scale pitch by (also adjusted by this.randomness)
|
|
1652
|
+
* @param {number} [randomnessScale] - How much to scale randomness
|
|
1653
|
+
* @param {boolean} [loop] - Should the sound loop
|
|
1652
1654
|
* @return {AudioBufferSourceNode} - The audio source node
|
|
1653
1655
|
*/
|
|
1654
1656
|
play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1655
1657
|
gainNode: GainNode;
|
|
1656
1658
|
source: AudioBufferSourceNode;
|
|
1657
1659
|
/** Set the sound volume of the most recently played instance of this sound
|
|
1658
|
-
* @param {
|
|
1660
|
+
* @param {number} [volume] - How much to scale volume by
|
|
1659
1661
|
*/
|
|
1660
1662
|
setVolume(volume?: number): void;
|
|
1661
1663
|
/** Stop the last instance of this sound that was played */
|
|
@@ -1665,18 +1667,18 @@ declare module "littlejsengine" {
|
|
|
1665
1667
|
*/
|
|
1666
1668
|
getSource(): AudioBufferSourceNode;
|
|
1667
1669
|
/** Play the sound as a note with a semitone offset
|
|
1668
|
-
* @param {
|
|
1670
|
+
* @param {number} semitoneOffset - How many semitones to offset pitch
|
|
1669
1671
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
1670
|
-
* @param {
|
|
1672
|
+
* @param {number} [volume=1] - How much to scale volume by (in addition to range fade)
|
|
1671
1673
|
* @return {AudioBufferSourceNode} - The audio source node
|
|
1672
1674
|
*/
|
|
1673
1675
|
playNote(semitoneOffset: number, pos?: Vector2, volume?: number): AudioBufferSourceNode;
|
|
1674
1676
|
/** Get how long this sound is in seconds
|
|
1675
|
-
* @return {
|
|
1677
|
+
* @return {number} - How long the sound is in seconds (undefined if loading)
|
|
1676
1678
|
*/
|
|
1677
1679
|
getDuration(): number;
|
|
1678
1680
|
/** Check if sound is loading, for sounds fetched from a url
|
|
1679
|
-
* @return {
|
|
1681
|
+
* @return {boolean} - True if sound is loading and not ready to play
|
|
1680
1682
|
*/
|
|
1681
1683
|
isLoading(): boolean;
|
|
1682
1684
|
}
|
|
@@ -1692,10 +1694,10 @@ declare module "littlejsengine" {
|
|
|
1692
1694
|
*/
|
|
1693
1695
|
export class SoundWave extends Sound {
|
|
1694
1696
|
/** Create a sound object and cache the wave file for later use
|
|
1695
|
-
* @param {
|
|
1696
|
-
* @param {
|
|
1697
|
-
* @param {
|
|
1698
|
-
* @param {
|
|
1697
|
+
* @param {string} filename - Filename of audio file to load
|
|
1698
|
+
* @param {number} [randomness] - How much to randomize frequency each time sound plays
|
|
1699
|
+
* @param {number} [range=soundDefaultRange] - World space max range of sound, will not play if camera is farther away
|
|
1700
|
+
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering off
|
|
1699
1701
|
* @param {Function} [onloadCallback] - callback function to call when sound is loaded
|
|
1700
1702
|
*/
|
|
1701
1703
|
constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: Function);
|
|
@@ -1732,30 +1734,30 @@ declare module "littlejsengine" {
|
|
|
1732
1734
|
*/
|
|
1733
1735
|
export class Music extends Sound {
|
|
1734
1736
|
/** Create a music object and cache the zzfx music samples for later use
|
|
1735
|
-
* @param {[Array, Array, Array,
|
|
1737
|
+
* @param {[Array, Array, Array, number]} zzfxMusic - Array of zzfx music parameters
|
|
1736
1738
|
*/
|
|
1737
1739
|
constructor(zzfxMusic: [any[], any[], any[], number]);
|
|
1738
1740
|
sampleChannels: any[];
|
|
1739
1741
|
/** Play the music
|
|
1740
|
-
* @param {
|
|
1741
|
-
* @param {
|
|
1742
|
+
* @param {number} [volume=1] - How much to scale volume by
|
|
1743
|
+
* @param {boolean} [loop] - True if the music should loop
|
|
1742
1744
|
* @return {AudioBufferSourceNode} - The audio source node
|
|
1743
1745
|
*/
|
|
1744
1746
|
playMusic(volume?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1745
1747
|
}
|
|
1746
1748
|
/** Play an mp3, ogg, or wav audio from a local file or url
|
|
1747
|
-
* @param {
|
|
1748
|
-
* @param {
|
|
1749
|
-
* @param {
|
|
1749
|
+
* @param {string} filename - Location of sound file to play
|
|
1750
|
+
* @param {number} [volume] - How much to scale volume by
|
|
1751
|
+
* @param {boolean} [loop] - True if the music should loop
|
|
1750
1752
|
* @return {SoundWave} - The sound object for this file
|
|
1751
1753
|
* @memberof Audio */
|
|
1752
1754
|
export function playAudioFile(filename: string, volume?: number, loop?: boolean): SoundWave;
|
|
1753
1755
|
/** Speak text with passed in settings
|
|
1754
|
-
* @param {
|
|
1755
|
-
* @param {
|
|
1756
|
-
* @param {
|
|
1757
|
-
* @param {
|
|
1758
|
-
* @param {
|
|
1756
|
+
* @param {string} text - The text to speak
|
|
1757
|
+
* @param {string} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
1758
|
+
* @param {number} [volume] - How much to scale volume by
|
|
1759
|
+
* @param {number} [rate] - How quickly to speak
|
|
1760
|
+
* @param {number} [pitch] - How much to change the pitch by
|
|
1759
1761
|
* @return {SpeechSynthesisUtterance} - The utterance that was spoken
|
|
1760
1762
|
* @memberof Audio */
|
|
1761
1763
|
export function speak(text: string, language?: string, volume?: number, rate?: number, pitch?: number): SpeechSynthesisUtterance;
|
|
@@ -1763,9 +1765,9 @@ declare module "littlejsengine" {
|
|
|
1763
1765
|
* @memberof Audio */
|
|
1764
1766
|
export function speakStop(): void;
|
|
1765
1767
|
/** Get frequency of a note on a musical scale
|
|
1766
|
-
* @param {
|
|
1767
|
-
* @param {
|
|
1768
|
-
* @return {
|
|
1768
|
+
* @param {number} semitoneOffset - How many semitones away from the root note
|
|
1769
|
+
* @param {number} [rootFrequency=220] - Frequency at semitone offset 0
|
|
1770
|
+
* @return {number} - The frequency of the note
|
|
1769
1771
|
* @memberof Audio */
|
|
1770
1772
|
export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
|
|
1771
1773
|
/**
|
|
@@ -1784,11 +1786,11 @@ declare module "littlejsengine" {
|
|
|
1784
1786
|
export let audioContext: AudioContext;
|
|
1785
1787
|
/** Play cached audio samples with given settings
|
|
1786
1788
|
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
|
|
1787
|
-
* @param {
|
|
1788
|
-
* @param {
|
|
1789
|
-
* @param {
|
|
1790
|
-
* @param {
|
|
1791
|
-
* @param {
|
|
1789
|
+
* @param {number} [volume] - How much to scale volume by
|
|
1790
|
+
* @param {number} [rate] - The playback rate to use
|
|
1791
|
+
* @param {number} [pan] - How much to apply stereo panning
|
|
1792
|
+
* @param {boolean} [loop] - True if the sound should loop when it reaches the end
|
|
1793
|
+
* @param {number} [sampleRate=44100] - Sample rate for the sound
|
|
1792
1794
|
* @param {GainNode} [gainNode] - Optional gain node for volume control while playing
|
|
1793
1795
|
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1794
1796
|
* @memberof Audio */
|
|
@@ -1833,9 +1835,9 @@ declare module "littlejsengine" {
|
|
|
1833
1835
|
* @param {Vector2} [pos=(0,0)] - World space position of the object
|
|
1834
1836
|
* @param {Vector2} [size=(1,1)] - World space size of the object
|
|
1835
1837
|
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
|
|
1836
|
-
* @param {
|
|
1838
|
+
* @param {number} [angle] - Angle the object is rotated by
|
|
1837
1839
|
* @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
|
|
1838
|
-
* @param {
|
|
1840
|
+
* @param {number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
1839
1841
|
*/
|
|
1840
1842
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
1841
1843
|
/** @property {Vector2} - World space position of the object */
|
|
@@ -1846,57 +1848,58 @@ declare module "littlejsengine" {
|
|
|
1846
1848
|
drawSize: any;
|
|
1847
1849
|
/** @property {TileInfo} - Tile info to render object (undefined is untextured) */
|
|
1848
1850
|
tileInfo: TileInfo;
|
|
1849
|
-
/** @property {
|
|
1851
|
+
/** @property {number} - Angle to rotate the object */
|
|
1850
1852
|
angle: number;
|
|
1851
1853
|
/** @property {Color} - Color to apply when rendered */
|
|
1852
1854
|
color: Color;
|
|
1853
1855
|
/** @property {Color} - Additive color to apply when rendered */
|
|
1854
1856
|
additiveColor: any;
|
|
1855
|
-
/** @property {
|
|
1857
|
+
/** @property {boolean} - Should it flip along y axis when rendered */
|
|
1856
1858
|
mirror: boolean;
|
|
1857
|
-
/** @property {
|
|
1859
|
+
/** @property {number} [mass=objectDefaultMass] - How heavy the object is, static if 0 */
|
|
1858
1860
|
mass: number;
|
|
1859
|
-
/** @property {
|
|
1861
|
+
/** @property {number} [damping=objectDefaultDamping] - How much to slow down velocity each frame (0-1) */
|
|
1860
1862
|
damping: number;
|
|
1861
|
-
/** @property {
|
|
1863
|
+
/** @property {number} [angleDamping=objectDefaultAngleDamping] - How much to slow down rotation each frame (0-1) */
|
|
1862
1864
|
angleDamping: number;
|
|
1863
|
-
/** @property {
|
|
1865
|
+
/** @property {number} [elasticity=objectDefaultElasticity] - How bouncy the object is when colliding (0-1) */
|
|
1864
1866
|
elasticity: number;
|
|
1865
|
-
/** @property {
|
|
1867
|
+
/** @property {number} [friction=objectDefaultFriction] - How much friction to apply when sliding (0-1) */
|
|
1866
1868
|
friction: number;
|
|
1867
|
-
/** @property {
|
|
1869
|
+
/** @property {number} - How much to scale gravity by for this object */
|
|
1868
1870
|
gravityScale: number;
|
|
1869
|
-
/** @property {
|
|
1871
|
+
/** @property {number} - Objects are sorted by render order */
|
|
1870
1872
|
renderOrder: number;
|
|
1871
1873
|
/** @property {Vector2} - Velocity of the object */
|
|
1872
1874
|
velocity: Vector2;
|
|
1873
|
-
/** @property {
|
|
1875
|
+
/** @property {number} - Angular velocity of the object */
|
|
1874
1876
|
angleVelocity: number;
|
|
1875
|
-
/** @property {
|
|
1877
|
+
/** @property {number} - Track when object was created */
|
|
1876
1878
|
spawnTime: number;
|
|
1877
|
-
/** @property {Array} - List of children of this object */
|
|
1879
|
+
/** @property {Array<EngineObject>} - List of children of this object */
|
|
1878
1880
|
children: any[];
|
|
1879
|
-
/** @property {
|
|
1881
|
+
/** @property {boolean} - Limit object speed using linear or circular math */
|
|
1880
1882
|
clampSpeedLinear: boolean;
|
|
1883
|
+
/** @property {EngineObject} - Object we are standing on, if any */
|
|
1884
|
+
groundObject: EngineObject | this;
|
|
1881
1885
|
/** @property {EngineObject} - Parent of object if in local space */
|
|
1882
1886
|
parent: any;
|
|
1883
1887
|
/** @property {Vector2} - Local position if child */
|
|
1884
1888
|
localPos: Vector2;
|
|
1885
|
-
/** @property {
|
|
1889
|
+
/** @property {number} - Local angle if child */
|
|
1886
1890
|
localAngle: number;
|
|
1887
|
-
/** @property {
|
|
1891
|
+
/** @property {boolean} - Object collides with the tile collision */
|
|
1888
1892
|
collideTiles: boolean;
|
|
1889
|
-
/** @property {
|
|
1893
|
+
/** @property {boolean} - Object collides with solid objects */
|
|
1890
1894
|
collideSolidObjects: boolean;
|
|
1891
|
-
/** @property {
|
|
1895
|
+
/** @property {boolean} - Object collides with and blocks other objects */
|
|
1892
1896
|
isSolid: boolean;
|
|
1893
|
-
/** @property {
|
|
1897
|
+
/** @property {boolean} - Object collides with raycasts */
|
|
1894
1898
|
collideRaycast: boolean;
|
|
1895
1899
|
/** Update the object transform, called automatically by engine even when paused */
|
|
1896
1900
|
updateTransforms(): void;
|
|
1897
1901
|
/** Update the object physics, called automatically by engine once each frame */
|
|
1898
1902
|
update(): void;
|
|
1899
|
-
groundObject: any;
|
|
1900
1903
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
1901
1904
|
render(): void;
|
|
1902
1905
|
/** Destroy this object, destroy it's children, detach it's parent, and mark it for removal */
|
|
@@ -1915,17 +1918,17 @@ declare module "littlejsengine" {
|
|
|
1915
1918
|
* @param {Vector2} vec - world space vector */
|
|
1916
1919
|
worldToLocalVector(vec: Vector2): Vector2;
|
|
1917
1920
|
/** Called to check if a tile collision should be resolved
|
|
1918
|
-
* @param {
|
|
1921
|
+
* @param {number} tileData - the value of the tile at the position
|
|
1919
1922
|
* @param {Vector2} pos - tile where the collision occurred
|
|
1920
|
-
* @return {
|
|
1923
|
+
* @return {boolean} - true if the collision should be resolved */
|
|
1921
1924
|
collideWithTile(tileData: number, pos: Vector2): boolean;
|
|
1922
1925
|
/** Called to check if a object collision should be resolved
|
|
1923
1926
|
* @param {EngineObject} object - the object to test against
|
|
1924
|
-
* @return {
|
|
1927
|
+
* @return {boolean} - true if the collision should be resolved
|
|
1925
1928
|
*/
|
|
1926
1929
|
collideWithObject(object: EngineObject): boolean;
|
|
1927
1930
|
/** How long since the object was created
|
|
1928
|
-
* @return {
|
|
1931
|
+
* @return {number} */
|
|
1929
1932
|
getAliveTime(): number;
|
|
1930
1933
|
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
1931
1934
|
* @param {Vector2} acceleration */
|
|
@@ -1934,24 +1937,24 @@ declare module "littlejsengine" {
|
|
|
1934
1937
|
* @param {Vector2} force */
|
|
1935
1938
|
applyForce(force: Vector2): void;
|
|
1936
1939
|
/** Get the direction of the mirror
|
|
1937
|
-
* @return {
|
|
1940
|
+
* @return {number} -1 if this.mirror is true, or 1 if not mirrored */
|
|
1938
1941
|
getMirrorSign(): number;
|
|
1939
1942
|
/** Attaches a child to this with a given local transform
|
|
1940
1943
|
* @param {EngineObject} child
|
|
1941
1944
|
* @param {Vector2} [localPos=(0,0)]
|
|
1942
|
-
* @param {
|
|
1945
|
+
* @param {number} [localAngle] */
|
|
1943
1946
|
addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
|
|
1944
1947
|
/** Removes a child from this one
|
|
1945
1948
|
* @param {EngineObject} child */
|
|
1946
1949
|
removeChild(child: EngineObject): void;
|
|
1947
1950
|
/** Set how this object collides
|
|
1948
|
-
* @param {
|
|
1949
|
-
* @param {
|
|
1950
|
-
* @param {
|
|
1951
|
-
* @param {
|
|
1951
|
+
* @param {boolean} [collideSolidObjects] - Does it collide with solid objects?
|
|
1952
|
+
* @param {boolean} [isSolid] - Does it collide with and block other objects? (expensive in large numbers)
|
|
1953
|
+
* @param {boolean} [collideTiles] - Does it collide with the tile collision?
|
|
1954
|
+
* @param {boolean} [collideRaycast] - Does it collide with raycasts? */
|
|
1952
1955
|
setCollision(collideSolidObjects?: boolean, isSolid?: boolean, collideTiles?: boolean, collideRaycast?: boolean): void;
|
|
1953
1956
|
/** Returns string containing info about this object for debugging
|
|
1954
|
-
* @return {
|
|
1957
|
+
* @return {string} */
|
|
1955
1958
|
toString(): string;
|
|
1956
1959
|
/** Render debug info for this object */
|
|
1957
1960
|
renderDebugInfo(): void;
|
|
@@ -1968,9 +1971,9 @@ declare module "littlejsengine" {
|
|
|
1968
1971
|
* @namespace TileCollision
|
|
1969
1972
|
*/
|
|
1970
1973
|
/** The tile collision layer grid, use setTileCollisionData and getTileCollisionData to access
|
|
1971
|
-
* @type {Array}
|
|
1974
|
+
* @type {Array<number>}
|
|
1972
1975
|
* @memberof TileCollision */
|
|
1973
|
-
export let tileCollision:
|
|
1976
|
+
export let tileCollision: Array<number>;
|
|
1974
1977
|
/** Size of the tile collision layer 2d grid
|
|
1975
1978
|
* @type {Vector2}
|
|
1976
1979
|
* @memberof TileCollision */
|
|
@@ -1981,19 +1984,19 @@ declare module "littlejsengine" {
|
|
|
1981
1984
|
export function initTileCollision(size: Vector2): void;
|
|
1982
1985
|
/** Set tile collision data for a given cell in the grid
|
|
1983
1986
|
* @param {Vector2} pos
|
|
1984
|
-
* @param {
|
|
1987
|
+
* @param {number} [data]
|
|
1985
1988
|
* @memberof TileCollision */
|
|
1986
1989
|
export function setTileCollisionData(pos: Vector2, data?: number): void;
|
|
1987
1990
|
/** Get tile collision data for a given cell in the grid
|
|
1988
1991
|
* @param {Vector2} pos
|
|
1989
|
-
* @return {
|
|
1992
|
+
* @return {number}
|
|
1990
1993
|
* @memberof TileCollision */
|
|
1991
1994
|
export function getTileCollisionData(pos: Vector2): number;
|
|
1992
1995
|
/** Check if collision with another object should occur
|
|
1993
1996
|
* @param {Vector2} pos
|
|
1994
1997
|
* @param {Vector2} [size=(0,0)]
|
|
1995
1998
|
* @param {EngineObject} [object]
|
|
1996
|
-
* @return {
|
|
1999
|
+
* @return {boolean}
|
|
1997
2000
|
* @memberof TileCollision */
|
|
1998
2001
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
1999
2002
|
/** Return the center of first tile hit, undefined if nothing was hit.
|
|
@@ -2016,16 +2019,16 @@ declare module "littlejsengine" {
|
|
|
2016
2019
|
*/
|
|
2017
2020
|
export class TileLayerData {
|
|
2018
2021
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
2019
|
-
* @param {
|
|
2020
|
-
* @param {
|
|
2021
|
-
* @param {
|
|
2022
|
+
* @param {number} [tile] - The tile to use, untextured if undefined
|
|
2023
|
+
* @param {number} [direction] - Integer direction of tile, in 90 degree increments
|
|
2024
|
+
* @param {boolean} [mirror] - If the tile should be mirrored along the x axis
|
|
2022
2025
|
* @param {Color} [color] - Color of the tile */
|
|
2023
2026
|
constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
|
|
2024
|
-
/** @property {
|
|
2027
|
+
/** @property {number} - The tile to use, untextured if undefined */
|
|
2025
2028
|
tile: number;
|
|
2026
|
-
/** @property {
|
|
2029
|
+
/** @property {number} - Integer direction of tile, in 90 degree increments */
|
|
2027
2030
|
direction: number;
|
|
2028
|
-
/** @property {
|
|
2031
|
+
/** @property {boolean} - If the tile should be mirrored along the x axis */
|
|
2029
2032
|
mirror: boolean;
|
|
2030
2033
|
/** @property {Color} - Color of the tile */
|
|
2031
2034
|
color: Color;
|
|
@@ -2050,7 +2053,7 @@ declare module "littlejsengine" {
|
|
|
2050
2053
|
* @param {Vector2} [size=tileCollisionSize] - World space size
|
|
2051
2054
|
* @param {TileInfo} [tileInfo] - Tile info for layer
|
|
2052
2055
|
* @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
|
|
2053
|
-
* @param {
|
|
2056
|
+
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2054
2057
|
*/
|
|
2055
2058
|
constructor(position?: Vector2, size?: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number);
|
|
2056
2059
|
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
@@ -2059,7 +2062,7 @@ declare module "littlejsengine" {
|
|
|
2059
2062
|
context: CanvasRenderingContext2D;
|
|
2060
2063
|
/** @property {Vector2} - How much to scale this layer when rendered */
|
|
2061
2064
|
scale: Vector2;
|
|
2062
|
-
/** @property {
|
|
2065
|
+
/** @property {boolean} - If true this layer will render to overlay canvas and appear above all objects */
|
|
2063
2066
|
isOverlay: boolean;
|
|
2064
2067
|
data: TileLayerData[];
|
|
2065
2068
|
/** Draw all the tile data to an offscreen canvas
|
|
@@ -2067,7 +2070,7 @@ declare module "littlejsengine" {
|
|
|
2067
2070
|
redraw(): void;
|
|
2068
2071
|
/** Call to start the redraw process
|
|
2069
2072
|
* - This can be used to manually update small parts of the level
|
|
2070
|
-
* @param {
|
|
2073
|
+
* @param {boolean} [clear] - Should it clear the canvas before drawing */
|
|
2071
2074
|
redrawStart(clear?: boolean): void;
|
|
2072
2075
|
/** Call to end the redraw process */
|
|
2073
2076
|
redrawEnd(): void;
|
|
@@ -2075,20 +2078,20 @@ declare module "littlejsengine" {
|
|
|
2075
2078
|
* This can be used to clear out tiles when they are destroyed
|
|
2076
2079
|
* Tiles can also be redrawn if inside a redrawStart/End block
|
|
2077
2080
|
* @param {Vector2} layerPos
|
|
2078
|
-
* @param {
|
|
2081
|
+
* @param {boolean} [clear] - should the old tile be cleared out
|
|
2079
2082
|
*/
|
|
2080
2083
|
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2081
2084
|
/** Draw directly to the 2D canvas in world space (bypass webgl)
|
|
2082
2085
|
* @param {Vector2} pos
|
|
2083
2086
|
* @param {Vector2} size
|
|
2084
|
-
* @param {
|
|
2085
|
-
* @param {
|
|
2087
|
+
* @param {number} angle
|
|
2088
|
+
* @param {boolean} mirror
|
|
2086
2089
|
* @param {Function} drawFunction */
|
|
2087
2090
|
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
2088
2091
|
/** Set data at a given position in the array
|
|
2089
2092
|
* @param {Vector2} layerPos - Local position in array
|
|
2090
2093
|
* @param {TileLayerData} data - Data to set
|
|
2091
|
-
* @param {
|
|
2094
|
+
* @param {boolean} [redraw] - Force the tile to redraw if true */
|
|
2092
2095
|
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
2093
2096
|
/** Get data at a given position in the array
|
|
2094
2097
|
* @param {Vector2} layerPos - Local position in array
|
|
@@ -2101,14 +2104,14 @@ declare module "littlejsengine" {
|
|
|
2101
2104
|
* @param {Vector2} [size=(1,1)]
|
|
2102
2105
|
* @param {TileInfo} [tileInfo]
|
|
2103
2106
|
* @param {Color} [color=(1,1,1,1)]
|
|
2104
|
-
* @param {
|
|
2105
|
-
* @param {
|
|
2107
|
+
* @param {number} [angle=0]
|
|
2108
|
+
* @param {boolean} [mirror=0] */
|
|
2106
2109
|
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2107
2110
|
/** Draw a rectangle directly onto the layer canvas in world space
|
|
2108
2111
|
* @param {Vector2} pos
|
|
2109
2112
|
* @param {Vector2} [size=(1,1)]
|
|
2110
2113
|
* @param {Color} [color=(1,1,1,1)]
|
|
2111
|
-
* @param {
|
|
2114
|
+
* @param {number} [angle=0] */
|
|
2112
2115
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2113
2116
|
}
|
|
2114
2117
|
/**
|
|
@@ -2155,11 +2158,11 @@ declare module "littlejsengine" {
|
|
|
2155
2158
|
* @param {Number} [particleConeAngle] - Cone for start particle angle
|
|
2156
2159
|
* @param {Number} [fadeRate] - How quick to fade particles at start/end in percent of life
|
|
2157
2160
|
* @param {Number} [randomness] - Apply extra randomness percent
|
|
2158
|
-
* @param {
|
|
2159
|
-
* @param {
|
|
2160
|
-
* @param {
|
|
2161
|
+
* @param {boolean} [collideTiles] - Do particles collide against tiles
|
|
2162
|
+
* @param {boolean} [additive] - Should particles use additive blend
|
|
2163
|
+
* @param {boolean} [randomColorLinear] - Should color be randomized linearly or across each component
|
|
2161
2164
|
* @param {Number} [renderOrder] - Render order for particles (additive is above other stuff by default)
|
|
2162
|
-
* @param {
|
|
2165
|
+
* @param {boolean} [localSpace] - Should it be in local space of emitter (world space is default)
|
|
2163
2166
|
*/
|
|
2164
2167
|
constructor(position: Vector2, angle?: number, emitSize?: number | Vector2, emitTime?: number, emitRate?: number, emitConeAngle?: number, tileInfo?: TileInfo, colorStartA?: Color, colorStartB?: Color, colorEndA?: Color, colorEndB?: Color, particleTime?: number, sizeStart?: number, sizeEnd?: number, speed?: number, angleSpeed?: number, damping?: number, angleDamping?: number, gravityScale?: number, particleConeAngle?: number, fadeRate?: number, randomness?: number, collideTiles?: boolean, additive?: boolean, randomColorLinear?: boolean, renderOrder?: number, localSpace?: boolean);
|
|
2165
2168
|
/** @property {Number|Vector2} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
@@ -2178,7 +2181,7 @@ declare module "littlejsengine" {
|
|
|
2178
2181
|
colorEndA: Color;
|
|
2179
2182
|
/** @property {Color} - Color at end of life 2, randomized between end colors */
|
|
2180
2183
|
colorEndB: Color;
|
|
2181
|
-
/** @property {
|
|
2184
|
+
/** @property {boolean} - Should color be randomized linearly or across each component */
|
|
2182
2185
|
randomColorLinear: boolean;
|
|
2183
2186
|
/** @property {Number} - How long particles live */
|
|
2184
2187
|
particleTime: number;
|
|
@@ -2196,9 +2199,9 @@ declare module "littlejsengine" {
|
|
|
2196
2199
|
fadeRate: number;
|
|
2197
2200
|
/** @property {Number} - Apply extra randomness percent */
|
|
2198
2201
|
randomness: number;
|
|
2199
|
-
/** @property {
|
|
2202
|
+
/** @property {boolean} - Should particles use additive blend */
|
|
2200
2203
|
additive: boolean;
|
|
2201
|
-
/** @property {
|
|
2204
|
+
/** @property {boolean} - Should it be in local space of emitter */
|
|
2202
2205
|
localSpace: boolean;
|
|
2203
2206
|
/** @property {Number} - If non zero the particle is drawn as a trail, stretched in the direction of velocity */
|
|
2204
2207
|
trailScale: number;
|
|
@@ -2229,7 +2232,7 @@ declare module "littlejsengine" {
|
|
|
2229
2232
|
* @param {Number} sizeStart - Size at start of life
|
|
2230
2233
|
* @param {Number} sizeEnd - Size at end of life
|
|
2231
2234
|
* @param {Number} fadeRate - How quick to fade in/out
|
|
2232
|
-
* @param {
|
|
2235
|
+
* @param {boolean} additive - Does it use additive blend mode
|
|
2233
2236
|
* @param {Number} trailScale - If a trail, how long to make it
|
|
2234
2237
|
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
2235
2238
|
* @param {Function} [destroyCallback] - Callback when particle dies
|
|
@@ -2247,7 +2250,7 @@ declare module "littlejsengine" {
|
|
|
2247
2250
|
sizeEndDelta: number;
|
|
2248
2251
|
/** @property {Number} - How quick to fade in/out */
|
|
2249
2252
|
fadeRate: number;
|
|
2250
|
-
/** @property {
|
|
2253
|
+
/** @property {boolean} - Is it additive */
|
|
2251
2254
|
additive: boolean;
|
|
2252
2255
|
/** @property {Number} - If a trail, how long to make it */
|
|
2253
2256
|
trailScale: number;
|
|
@@ -2268,7 +2271,7 @@ declare module "littlejsengine" {
|
|
|
2268
2271
|
* @memberof Medals */
|
|
2269
2272
|
export const medals: any;
|
|
2270
2273
|
/** Set to stop medals from being unlockable (like if cheats are enabled)
|
|
2271
|
-
* @type {
|
|
2274
|
+
* @type {boolean}
|
|
2272
2275
|
* @default
|
|
2273
2276
|
* @memberof Settings */
|
|
2274
2277
|
export let medalsPreventUnlock: boolean;
|
|
@@ -2307,7 +2310,7 @@ declare module "littlejsengine" {
|
|
|
2307
2310
|
description: string;
|
|
2308
2311
|
/** @property {String} - Icon for the medal */
|
|
2309
2312
|
icon: string;
|
|
2310
|
-
/** @property {
|
|
2313
|
+
/** @property {boolean} - Is the medal unlocked? */
|
|
2311
2314
|
unlocked: boolean;
|
|
2312
2315
|
image: HTMLImageElement;
|
|
2313
2316
|
/** Unlocks a medal if not already unlocked */
|