littlejsengine 1.13.4 → 1.14.4
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 +4 -3
- package/dist/littlejs.d.ts +395 -249
- package/dist/littlejs.esm.js +1550 -754
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +1528 -744
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +1504 -720
- package/examples/box2d/game.js +4 -4
- package/examples/box2d/gameObjects.js +1 -1
- package/examples/breakout/game.js +30 -25
- package/examples/breakoutTutorial/README.md +1 -1
- package/examples/breakoutTutorial/game.js +1 -1
- package/examples/electron/build.js +1 -1
- package/examples/electron/index.html +2 -2
- package/examples/empty/game.js +1 -1
- package/examples/htmlMenu/index.html +7 -7
- package/examples/index.html +208 -97
- package/examples/platformer/gameEffects.js +20 -25
- package/examples/platformer/gameLevel.js +6 -1
- package/examples/shorts/base.html +1 -1
- package/examples/shorts/flappyGame.js +2 -1
- package/examples/shorts/helloWorld.js +1 -1
- package/examples/shorts/music.js +106 -0
- package/examples/shorts/parallax.js +71 -0
- package/examples/shorts/piano.js +7 -8
- package/examples/shorts/postProcess.js +25 -8
- package/examples/shorts/shapes.js +12 -18
- package/examples/shorts/song.mp3 +0 -0
- package/examples/shorts/uiSystem.js +15 -8
- package/examples/starter/index.html +2 -2
- package/examples/stress/index.html +14 -7
- package/examples/style.css +14 -4
- package/examples/typescript/build.js +1 -1
- package/examples/uiSystem/game.js +11 -11
- package/package.json +1 -1
- package/plugins/box2d.js +12 -10
- package/plugins/drawUtilities.js +5 -5
- package/plugins/newgrounds.js +6 -6
- package/plugins/pluginExport.js +1 -1
- package/plugins/uiSystem.js +103 -79
- package/plugins/zzfxm.js +10 -10
- package/reference.md +94 -56
- package/src/engine.js +28 -24
- package/src/engineAudio.js +284 -109
- package/src/engineBuild.js +11 -11
- package/src/engineDebug.js +29 -29
- package/src/engineDraw.js +285 -112
- package/src/engineExport.js +28 -16
- package/src/engineInput.js +57 -67
- package/src/engineMedals.js +25 -25
- package/src/engineObject.js +28 -25
- package/src/engineParticles.js +59 -59
- package/src/engineRelease.js +1 -1
- package/src/engineSettings.js +20 -13
- package/src/engineTileLayer.js +34 -35
- package/src/engineUtilities.js +66 -59
- package/src/engineWebGL.js +466 -66
- /package/examples/shorts/{playSound.js → sound.js} +0 -0
package/dist/littlejs.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ declare module "littlejsengine" {
|
|
|
79
79
|
* // Basic engine startup
|
|
80
80
|
* engineInit(
|
|
81
81
|
* () => { console.log('Game initialized!'); }, // gameInit
|
|
82
|
-
* () => {
|
|
82
|
+
* () => { updateGameLogic(); }, // gameUpdate
|
|
83
83
|
* () => { updateUI(); }, // gameUpdatePost
|
|
84
84
|
* () => { drawBackground(); }, // gameRender
|
|
85
85
|
* () => { drawHUD(); }, // gameRenderPost
|
|
@@ -185,10 +185,10 @@ declare module "littlejsengine" {
|
|
|
185
185
|
* @param {Vector2} posA
|
|
186
186
|
* @param {Vector2} posB
|
|
187
187
|
* @param {string} [color]
|
|
188
|
-
* @param {number} [
|
|
188
|
+
* @param {number} [width]
|
|
189
189
|
* @param {number} [time]
|
|
190
190
|
* @memberof Debug */
|
|
191
|
-
export function debugLine(posA: Vector2, posB: Vector2, color?: string,
|
|
191
|
+
export function debugLine(posA: Vector2, posB: Vector2, color?: string, width?: number, time?: number): void;
|
|
192
192
|
/** Draw a debug combined axis aligned bounding box in world space
|
|
193
193
|
* @param {Vector2} posA
|
|
194
194
|
* @param {Vector2} sizeA
|
|
@@ -263,7 +263,7 @@ declare module "littlejsengine" {
|
|
|
263
263
|
* @memberof Settings */
|
|
264
264
|
export let cameraScale: number;
|
|
265
265
|
/** Enable applying color to tiles when using canvas2d
|
|
266
|
-
* - This is slower but should be the same as
|
|
266
|
+
* - This is slower but should be the same as WebGL rendering
|
|
267
267
|
* @type {boolean}
|
|
268
268
|
* @default
|
|
269
269
|
* @memberof Settings */
|
|
@@ -302,13 +302,12 @@ declare module "littlejsengine" {
|
|
|
302
302
|
* @default
|
|
303
303
|
* @memberof Settings */
|
|
304
304
|
export let fontDefault: string;
|
|
305
|
-
/** Enable to show the LittleJS splash screen
|
|
305
|
+
/** Enable to show the LittleJS splash screen on startup
|
|
306
306
|
* @type {boolean}
|
|
307
307
|
* @default
|
|
308
308
|
* @memberof Settings */
|
|
309
309
|
export let showSplashScreen: boolean;
|
|
310
310
|
/** Disables all rendering, audio, and input for servers
|
|
311
|
-
* - Must be set before startup to take effect
|
|
312
311
|
* @type {boolean}
|
|
313
312
|
* @default
|
|
314
313
|
* @memberof Settings */
|
|
@@ -368,8 +367,7 @@ declare module "littlejsengine" {
|
|
|
368
367
|
* @default
|
|
369
368
|
* @memberof Settings */
|
|
370
369
|
export let particleEmitRateScale: number;
|
|
371
|
-
/** Enable
|
|
372
|
-
* - Must be set before startup to take effect
|
|
370
|
+
/** Enable WebGL accelerated rendering
|
|
373
371
|
* @type {boolean}
|
|
374
372
|
* @default
|
|
375
373
|
* @memberof Settings */
|
|
@@ -379,19 +377,18 @@ declare module "littlejsengine" {
|
|
|
379
377
|
* @default
|
|
380
378
|
* @memberof Settings */
|
|
381
379
|
export let gamepadsEnable: boolean;
|
|
382
|
-
/** If true, the dpad input is also routed to the left analog stick (for better
|
|
380
|
+
/** If true, the dpad input is also routed to the left analog stick (for better accessibility)
|
|
383
381
|
* @type {boolean}
|
|
384
382
|
* @default
|
|
385
383
|
* @memberof Settings */
|
|
386
384
|
export let gamepadDirectionEmulateStick: boolean;
|
|
387
|
-
/** If true the WASD keys are also routed to the direction keys (for better
|
|
385
|
+
/** If true the WASD keys are also routed to the direction keys (for better accessibility)
|
|
388
386
|
* @type {boolean}
|
|
389
387
|
* @default
|
|
390
388
|
* @memberof Settings */
|
|
391
389
|
export let inputWASDEmulateDirection: boolean;
|
|
392
390
|
/** True if touch gamepad should appear on mobile devices
|
|
393
391
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
394
|
-
* - Must be set before startup to take effect
|
|
395
392
|
* @type {boolean}
|
|
396
393
|
* @default
|
|
397
394
|
* @memberof Settings */
|
|
@@ -464,7 +461,7 @@ declare module "littlejsengine" {
|
|
|
464
461
|
* @memberof Settings */
|
|
465
462
|
export function setCameraScale(scale: number): void;
|
|
466
463
|
/** Set if tiles should be colorized when using canvas2d
|
|
467
|
-
* This can be slower but results should look nearly identical to
|
|
464
|
+
* This can be slower but results should look nearly identical to WebGL rendering
|
|
468
465
|
* It can be enabled/disabled at any time
|
|
469
466
|
* Optimized for performance, and will use faster method if color is white or untextured
|
|
470
467
|
* @param {boolean} colorTiles
|
|
@@ -497,7 +494,7 @@ declare module "littlejsengine" {
|
|
|
497
494
|
* @param {string} font
|
|
498
495
|
* @memberof Settings */
|
|
499
496
|
export function setFontDefault(font: string): void;
|
|
500
|
-
/** Set if the LittleJS splash screen be shown on startup
|
|
497
|
+
/** Set if the LittleJS splash screen should be shown on startup
|
|
501
498
|
* @param {boolean} show
|
|
502
499
|
* @memberof Settings */
|
|
503
500
|
export function setShowSplashScreen(show: boolean): void;
|
|
@@ -505,7 +502,7 @@ declare module "littlejsengine" {
|
|
|
505
502
|
* @param {boolean} headless
|
|
506
503
|
* @memberof Settings */
|
|
507
504
|
export function setHeadlessMode(headless: boolean): void;
|
|
508
|
-
/** Set if
|
|
505
|
+
/** Set if WebGL rendering is enabled
|
|
509
506
|
* @param {boolean} enable
|
|
510
507
|
* @memberof Settings */
|
|
511
508
|
export function setGLEnable(enable: boolean): void;
|
|
@@ -533,7 +530,7 @@ declare module "littlejsengine" {
|
|
|
533
530
|
* @param {number} damp
|
|
534
531
|
* @memberof Settings */
|
|
535
532
|
export function setObjectDefaultAngleDamping(damp: number): void;
|
|
536
|
-
/** Set how much to bounce when a collision
|
|
533
|
+
/** Set how much to bounce when a collision occurs
|
|
537
534
|
* @param {number} restitution
|
|
538
535
|
* @memberof Settings */
|
|
539
536
|
export function setObjectDefaultRestitution(restitution: number): void;
|
|
@@ -723,7 +720,7 @@ declare module "littlejsengine" {
|
|
|
723
720
|
* @return {number}
|
|
724
721
|
* @memberof Utilities */
|
|
725
722
|
export function smoothStep(percent: number): number;
|
|
726
|
-
/** Returns the nearest power of two not less
|
|
723
|
+
/** Returns the nearest power of two not less than the value
|
|
727
724
|
* @param {number} value
|
|
728
725
|
* @return {number}
|
|
729
726
|
* @memberof Utilities */
|
|
@@ -1124,8 +1121,7 @@ declare module "littlejsengine" {
|
|
|
1124
1121
|
* let a = vec2(0, 1); // vector with coordinates (0, 1)
|
|
1125
1122
|
* a = vec2(5); // set a to (5, 5)
|
|
1126
1123
|
* b = vec2(); // set b to (0, 0)
|
|
1127
|
-
* @memberof Utilities
|
|
1128
|
-
*/
|
|
1124
|
+
* @memberof Utilities */
|
|
1129
1125
|
export function vec2(x?: number, y?: number): Vector2;
|
|
1130
1126
|
/**
|
|
1131
1127
|
* Create a color object with RGBA values, white by default
|
|
@@ -1144,29 +1140,25 @@ declare module "littlejsengine" {
|
|
|
1144
1140
|
* @param {number} [l=1] - lightness
|
|
1145
1141
|
* @param {number} [a=1] - alpha
|
|
1146
1142
|
* @return {Color}
|
|
1147
|
-
* @memberof Utilities
|
|
1148
|
-
*/
|
|
1143
|
+
* @memberof Utilities */
|
|
1149
1144
|
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
1150
1145
|
/**
|
|
1151
1146
|
* Check if object is a valid Color
|
|
1152
1147
|
* @param {any} c
|
|
1153
1148
|
* @return {boolean}
|
|
1154
|
-
* @memberof Utilities
|
|
1155
|
-
*/
|
|
1149
|
+
* @memberof Utilities */
|
|
1156
1150
|
export function isColor(c: any): boolean;
|
|
1157
1151
|
/**
|
|
1158
1152
|
* Check if object is a valid Vector2
|
|
1159
1153
|
* @param {any} v
|
|
1160
1154
|
* @return {boolean}
|
|
1161
|
-
* @memberof Utilities
|
|
1162
|
-
*/
|
|
1155
|
+
* @memberof Utilities */
|
|
1163
1156
|
export function isVector2(v: any): boolean;
|
|
1164
1157
|
/**
|
|
1165
1158
|
* Check if object is a valid number, not NaN or undefined, but it may be infinite
|
|
1166
1159
|
* @param {any} n
|
|
1167
1160
|
* @return {boolean}
|
|
1168
|
-
* @memberof Utilities
|
|
1169
|
-
*/
|
|
1161
|
+
* @memberof Utilities */
|
|
1170
1162
|
export function isNumber(n: any): boolean;
|
|
1171
1163
|
/** Color - White #ffffff
|
|
1172
1164
|
* @type {Color}
|
|
@@ -1224,6 +1216,10 @@ declare module "littlejsengine" {
|
|
|
1224
1216
|
* @type {Array<TextureInfo>}
|
|
1225
1217
|
* @memberof Draw */
|
|
1226
1218
|
export let textureInfos: Array<TextureInfo>;
|
|
1219
|
+
/** Keeps track of how many draw calls there were each frame for debugging
|
|
1220
|
+
* @type {number}
|
|
1221
|
+
* @memberof Draw */
|
|
1222
|
+
export let drawCount: number;
|
|
1227
1223
|
/**
|
|
1228
1224
|
* Create a tile info object using a grid based system
|
|
1229
1225
|
* - This can take vecs or floats for easier use and conversion
|
|
@@ -1238,8 +1234,7 @@ declare module "littlejsengine" {
|
|
|
1238
1234
|
* tile(5, 8) // a tile at index 5 using a tile size of 8
|
|
1239
1235
|
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
1240
1236
|
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
1241
|
-
* @memberof Draw
|
|
1242
|
-
*/
|
|
1237
|
+
* @memberof Draw */
|
|
1243
1238
|
export function tile(pos?: Vector2 | number, size?: Vector2 | number, textureIndex?: number, padding?: number): TileInfo;
|
|
1244
1239
|
/**
|
|
1245
1240
|
* Tile Info - Stores info about how to draw a tile
|
|
@@ -1275,7 +1270,7 @@ declare module "littlejsengine" {
|
|
|
1275
1270
|
/**
|
|
1276
1271
|
* Set this tile to use a full image
|
|
1277
1272
|
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1278
|
-
* @param {WebGLTexture} [glTexture] -
|
|
1273
|
+
* @param {WebGLTexture} [glTexture] - WebGL texture
|
|
1279
1274
|
* @return {TileInfo}
|
|
1280
1275
|
*/
|
|
1281
1276
|
setFullImage(image: HTMLImageElement | OffscreenCanvas, glTexture?: WebGLTexture): TileInfo;
|
|
@@ -1285,7 +1280,7 @@ declare module "littlejsengine" {
|
|
|
1285
1280
|
/**
|
|
1286
1281
|
* Create a TextureInfo, called automatically by the engine
|
|
1287
1282
|
* @param {HTMLImageElement|OffscreenCanvas} image
|
|
1288
|
-
* @param {WebGLTexture} [glTexture] -
|
|
1283
|
+
* @param {WebGLTexture} [glTexture] - WebGL texture
|
|
1289
1284
|
*/
|
|
1290
1285
|
constructor(image: HTMLImageElement | OffscreenCanvas, glTexture?: WebGLTexture);
|
|
1291
1286
|
/** @property {HTMLImageElement} - image source */
|
|
@@ -1294,7 +1289,7 @@ declare module "littlejsengine" {
|
|
|
1294
1289
|
size: Vector2;
|
|
1295
1290
|
/** @property {Vector2} - inverse of the size, cached for rendering */
|
|
1296
1291
|
sizeInverse: Vector2;
|
|
1297
|
-
/** @property {WebGLTexture} -
|
|
1292
|
+
/** @property {WebGLTexture} - WebGL texture */
|
|
1298
1293
|
glTexture: WebGLTexture;
|
|
1299
1294
|
createWebGLTexture(): void;
|
|
1300
1295
|
}
|
|
@@ -1327,6 +1322,14 @@ declare module "littlejsengine" {
|
|
|
1327
1322
|
* @type {CanvasRenderingContext2D}
|
|
1328
1323
|
* @memberof Draw */
|
|
1329
1324
|
export let mainContext: CanvasRenderingContext2D;
|
|
1325
|
+
/** The default canvas to use for drawing, usually mainCanvas
|
|
1326
|
+
* @type {HTMLCanvasElement|OffscreenCanvas}
|
|
1327
|
+
* @memberof Draw */
|
|
1328
|
+
export let drawCanvas: HTMLCanvasElement | OffscreenCanvas;
|
|
1329
|
+
/** The default 2d context to use for drawing, usually mainContext
|
|
1330
|
+
* @type {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}
|
|
1331
|
+
* @memberof Draw */
|
|
1332
|
+
export let drawContext: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
1330
1333
|
/** A canvas that appears on top of everything the same size as mainCanvas
|
|
1331
1334
|
* @type {HTMLCanvasElement}
|
|
1332
1335
|
* @memberof Draw */
|
|
@@ -1350,15 +1353,15 @@ declare module "littlejsengine" {
|
|
|
1350
1353
|
* @memberof Draw */
|
|
1351
1354
|
export function worldToScreen(worldPos: Vector2): Vector2;
|
|
1352
1355
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1353
|
-
* @param {Vector2}
|
|
1354
|
-
* @param {Vector2}
|
|
1355
|
-
* @param {TileInfo}[tileInfo]
|
|
1356
|
-
* @param {Color}
|
|
1357
|
-
* @param {number}
|
|
1358
|
-
* @param {boolean}
|
|
1359
|
-
* @param {Color}
|
|
1360
|
-
* @param {boolean}
|
|
1361
|
-
* @param {boolean}
|
|
1356
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
1357
|
+
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
|
|
1358
|
+
* @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
|
|
1359
|
+
* @param {Color} [color=(1,1,1,1)] - Color to modulate with
|
|
1360
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1361
|
+
* @param {boolean} [mirror] - Is image flipped along the Y axis?
|
|
1362
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any
|
|
1363
|
+
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering?
|
|
1364
|
+
* @param {boolean} [screenSpace=false] - Are the pos and size are in screen space?
|
|
1362
1365
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1363
1366
|
* @memberof Draw */
|
|
1364
1367
|
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;
|
|
@@ -1372,10 +1375,33 @@ declare module "littlejsengine" {
|
|
|
1372
1375
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1373
1376
|
* @memberof Draw */
|
|
1374
1377
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1378
|
+
/** Draw a rect centered on pos with a gradient from top to bottom
|
|
1379
|
+
* @param {Vector2} pos
|
|
1380
|
+
* @param {Vector2} [size=(1,1)]
|
|
1381
|
+
* @param {Color} [colorTop=(1,1,1,1)]
|
|
1382
|
+
* @param {Color} [colorBottom=(0,0,0,1)]
|
|
1383
|
+
* @param {number} [angle]
|
|
1384
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1385
|
+
* @param {boolean} [screenSpace]
|
|
1386
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1387
|
+
* @memberof Draw */
|
|
1388
|
+
export function drawRectGradient(pos: Vector2, size?: Vector2, colorTop?: Color, colorBottom?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1389
|
+
/** Draw connected lines between a series of points
|
|
1390
|
+
* @param {Array<Vector2>} points
|
|
1391
|
+
* @param {number} [width]
|
|
1392
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1393
|
+
* @param {boolean} [wrap] - Should the last point connect to the first?
|
|
1394
|
+
* @param {Vector2} [pos=(0,0)] - Offset to apply
|
|
1395
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1396
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1397
|
+
* @param {boolean} [screenSpace]
|
|
1398
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1399
|
+
* @memberof Draw */
|
|
1400
|
+
export function drawLineList(points: Array<Vector2>, width?: number, color?: Color, wrap?: boolean, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1375
1401
|
/** Draw colored line between two points
|
|
1376
1402
|
* @param {Vector2} posA
|
|
1377
1403
|
* @param {Vector2} posB
|
|
1378
|
-
* @param {number} [
|
|
1404
|
+
* @param {number} [width]
|
|
1379
1405
|
* @param {Color} [color=(1,1,1,1)]
|
|
1380
1406
|
* @param {Vector2} [pos=(0,0)] - Offset to apply
|
|
1381
1407
|
* @param {number} [angle] - Angle to rotate by
|
|
@@ -1383,7 +1409,7 @@ declare module "littlejsengine" {
|
|
|
1383
1409
|
* @param {boolean} [screenSpace]
|
|
1384
1410
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1385
1411
|
* @memberof Draw */
|
|
1386
|
-
export function drawLine(posA: Vector2, posB: Vector2,
|
|
1412
|
+
export function drawLine(posA: Vector2, posB: Vector2, width?: number, color?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1387
1413
|
/** Draw colored polygon using passed in points
|
|
1388
1414
|
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1389
1415
|
* @param {Color} [color=(1,1,1,1)]
|
|
@@ -1391,41 +1417,41 @@ declare module "littlejsengine" {
|
|
|
1391
1417
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1392
1418
|
* @param {Vector2} [pos=(0,0)] - Offset to apply
|
|
1393
1419
|
* @param {number} [angle] - Angle to rotate by
|
|
1394
|
-
* @param {boolean} [useWebGL]
|
|
1420
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1395
1421
|
* @param {boolean} [screenSpace]
|
|
1396
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context
|
|
1422
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1397
1423
|
* @memberof Draw */
|
|
1398
1424
|
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1399
1425
|
/** Draw colored ellipse using passed in point
|
|
1400
1426
|
* @param {Vector2} pos
|
|
1401
|
-
* @param {Vector2} [size=(1,1)]
|
|
1427
|
+
* @param {Vector2} [size=(1,1)] - Width and height diameter
|
|
1402
1428
|
* @param {Color} [color=(1,1,1,1)]
|
|
1403
1429
|
* @param {number} [angle]
|
|
1404
1430
|
* @param {number} [lineWidth]
|
|
1405
1431
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1406
|
-
* @param {boolean} [useWebGL]
|
|
1432
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1407
1433
|
* @param {boolean} [screenSpace]
|
|
1408
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context
|
|
1434
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1409
1435
|
* @memberof Draw */
|
|
1410
1436
|
export function drawEllipse(pos: Vector2, size?: Vector2, color?: Color, angle?: number, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1411
1437
|
/** Draw colored circle using passed in point
|
|
1412
1438
|
* @param {Vector2} pos
|
|
1413
|
-
* @param {number} [
|
|
1439
|
+
* @param {number} [size=1] - Diameter
|
|
1414
1440
|
* @param {Color} [color=(1,1,1,1)]
|
|
1415
1441
|
* @param {number} [lineWidth=0]
|
|
1416
1442
|
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1417
|
-
* @param {boolean} [useWebGL]
|
|
1418
|
-
* @param {boolean} [screenSpace
|
|
1419
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context
|
|
1443
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1444
|
+
* @param {boolean} [screenSpace]
|
|
1445
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1420
1446
|
* @memberof Draw */
|
|
1421
|
-
export function drawCircle(pos: Vector2,
|
|
1447
|
+
export function drawCircle(pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1422
1448
|
/** Draw directly to a 2d canvas context in world space
|
|
1423
1449
|
* @param {Vector2} pos
|
|
1424
1450
|
* @param {Vector2} size
|
|
1425
1451
|
* @param {number} angle
|
|
1426
1452
|
* @param {boolean} [mirror]
|
|
1427
1453
|
* @param {Function} [drawFunction]
|
|
1428
|
-
* @param {boolean}
|
|
1454
|
+
* @param {boolean} [screenSpace=false]
|
|
1429
1455
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1430
1456
|
* @memberof Draw */
|
|
1431
1457
|
export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
@@ -1490,34 +1516,41 @@ declare module "littlejsengine" {
|
|
|
1490
1516
|
* const font = new FontImage;
|
|
1491
1517
|
*
|
|
1492
1518
|
* // draw text
|
|
1493
|
-
* font.drawTextScreen(
|
|
1519
|
+
* font.drawTextScreen('LittleJS\nHello World!', vec2(200, 50));
|
|
1494
1520
|
*/
|
|
1495
1521
|
export class FontImage {
|
|
1496
1522
|
/** Create an image font
|
|
1497
1523
|
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
|
|
1498
1524
|
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1499
1525
|
* @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
|
|
1500
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext] - context to draw to
|
|
1501
1526
|
*/
|
|
1502
|
-
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D
|
|
1527
|
+
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D);
|
|
1503
1528
|
image: any;
|
|
1504
1529
|
tileSize: Vector2;
|
|
1505
1530
|
paddingSize: Vector2;
|
|
1506
|
-
context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
1507
1531
|
/** Draw text in world space using the image font
|
|
1508
1532
|
* @param {string} text
|
|
1509
1533
|
* @param {Vector2} pos
|
|
1510
1534
|
* @param {number} [scale=.25]
|
|
1511
1535
|
* @param {boolean} [center]
|
|
1536
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}[context=drawContext]
|
|
1537
|
+
*/
|
|
1538
|
+
drawText(text: string, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1539
|
+
/** Draw text on overlay canvas in world space using the image font
|
|
1540
|
+
* @param {string} text
|
|
1541
|
+
* @param {Vector2} pos
|
|
1542
|
+
* @param {number} [scale]
|
|
1543
|
+
* @param {boolean} [center]
|
|
1512
1544
|
*/
|
|
1513
|
-
|
|
1514
|
-
/** Draw text in screen space using the image font
|
|
1545
|
+
drawTextOverlay(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
1546
|
+
/** Draw text on overlay canvas in screen space using the image font
|
|
1515
1547
|
* @param {string} text
|
|
1516
1548
|
* @param {Vector2} pos
|
|
1517
1549
|
* @param {number} [scale]
|
|
1518
1550
|
* @param {boolean} [center]
|
|
1551
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1519
1552
|
*/
|
|
1520
|
-
drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean): void;
|
|
1553
|
+
drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1521
1554
|
}
|
|
1522
1555
|
/** Returns true if fullscreen mode is active
|
|
1523
1556
|
* @return {boolean}
|
|
@@ -1527,7 +1560,7 @@ declare module "littlejsengine" {
|
|
|
1527
1560
|
* @memberof Draw */
|
|
1528
1561
|
export function toggleFullscreen(): void;
|
|
1529
1562
|
/** Set the cursor style
|
|
1530
|
-
* @param {string} cursorStyle - CSS cursor style (auto, none, crosshair, etc)
|
|
1563
|
+
* @param {string} [cursorStyle] - CSS cursor style (auto, none, crosshair, etc)
|
|
1531
1564
|
* @memberof Draw */
|
|
1532
1565
|
export function setCursor(cursorStyle?: string): void;
|
|
1533
1566
|
/** Get the camera's visible area in world space
|
|
@@ -1536,8 +1569,8 @@ declare module "littlejsengine" {
|
|
|
1536
1569
|
export function getCameraSize(): Vector2;
|
|
1537
1570
|
/**
|
|
1538
1571
|
* LittleJS WebGL Interface
|
|
1539
|
-
* - All
|
|
1540
|
-
* - Will fall back to 2D canvas rendering if
|
|
1572
|
+
* - All WebGL used by the engine is wrapped up here
|
|
1573
|
+
* - Will fall back to 2D canvas rendering if WebGL is not supported
|
|
1541
1574
|
* - For normal stuff you won't need to see or call anything in this file
|
|
1542
1575
|
* - For advanced stuff there are helper functions to create shaders, textures, etc
|
|
1543
1576
|
* - Can be disabled with glEnable to revert to 2D canvas rendering
|
|
@@ -1550,23 +1583,28 @@ declare module "littlejsengine" {
|
|
|
1550
1583
|
* @type {HTMLCanvasElement}
|
|
1551
1584
|
* @memberof WebGL */
|
|
1552
1585
|
export let glCanvas: HTMLCanvasElement;
|
|
1553
|
-
/**
|
|
1586
|
+
/** WebGL2 context for `glCanvas`
|
|
1554
1587
|
* @type {WebGL2RenderingContext}
|
|
1555
1588
|
* @memberof WebGL */
|
|
1556
1589
|
export let glContext: WebGL2RenderingContext;
|
|
1590
|
+
/** Clear the canvas and setup the viewport
|
|
1591
|
+
* @memberof WebGL */
|
|
1592
|
+
export function glClearCanvas(): void;
|
|
1593
|
+
/** Set the WebGL texture, called automatically if using multiple textures
|
|
1594
|
+
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1595
|
+
* @param {WebGLTexture} texture
|
|
1596
|
+
* @param {boolean} [wrap] - Should the texture wrap or clamp
|
|
1597
|
+
* @memberof WebGL */
|
|
1598
|
+
export function glSetTexture(texture: WebGLTexture, wrap?: boolean): void;
|
|
1557
1599
|
/** Compile WebGL shader of the given type, will throw errors if in debug mode
|
|
1558
|
-
* @param {
|
|
1559
|
-
* @param {
|
|
1600
|
+
* @param {string} source
|
|
1601
|
+
* @param {number} type
|
|
1560
1602
|
* @return {WebGLShader}
|
|
1561
1603
|
* @memberof WebGL */
|
|
1562
1604
|
export function glCompileShader(source: string, type: number): WebGLShader;
|
|
1563
|
-
/** Flush any sprites still in the buffer and copy to main canvas
|
|
1564
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1565
|
-
* @memberof WebGL */
|
|
1566
|
-
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1567
1605
|
/** Create WebGL program with given shaders
|
|
1568
|
-
* @param {
|
|
1569
|
-
* @param {
|
|
1606
|
+
* @param {string} vsSource
|
|
1607
|
+
* @param {string} fsSource
|
|
1570
1608
|
* @return {WebGLProgram}
|
|
1571
1609
|
* @memberof WebGL */
|
|
1572
1610
|
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
|
|
@@ -1584,49 +1622,80 @@ declare module "littlejsengine" {
|
|
|
1584
1622
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} image
|
|
1585
1623
|
* @memberof WebGL */
|
|
1586
1624
|
export function glSetTextureData(texture: WebGLTexture, image: HTMLImageElement | HTMLCanvasElement | OffscreenCanvas): void;
|
|
1587
|
-
/** Add a sprite to the gl draw list, used by all gl draw functions
|
|
1588
|
-
* @param {Number} x
|
|
1589
|
-
* @param {Number} y
|
|
1590
|
-
* @param {Number} sizeX
|
|
1591
|
-
* @param {Number} sizeY
|
|
1592
|
-
* @param {Number} [angle]
|
|
1593
|
-
* @param {Number} [uv0X]
|
|
1594
|
-
* @param {Number} [uv0Y]
|
|
1595
|
-
* @param {Number} [uv1X]
|
|
1596
|
-
* @param {Number} [uv1Y]
|
|
1597
|
-
* @param {Number} [rgba=-1] - white is -1
|
|
1598
|
-
* @param {Number} [rgbaAdditive=0] - black is 0
|
|
1599
|
-
* @memberof WebGL */
|
|
1600
|
-
export function glDraw(x: number, y: number, sizeX: number, sizeY: number, angle?: number, uv0X?: number, uv0Y?: number, uv1X?: number, uv1Y?: number, rgba?: number, rgbaAdditive?: number): void;
|
|
1601
1625
|
/** Draw all sprites and clear out the buffer, called automatically by the system whenever necessary
|
|
1602
1626
|
* @memberof WebGL */
|
|
1603
1627
|
export function glFlush(): void;
|
|
1604
|
-
/**
|
|
1605
|
-
*
|
|
1606
|
-
* @param {WebGLTexture} texture
|
|
1607
|
-
* @param {boolean} wrap - Should the texture wrap or clamp
|
|
1628
|
+
/** Flush any sprites still in the buffer and copy to main canvas
|
|
1629
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
1608
1630
|
* @memberof WebGL */
|
|
1609
|
-
export function
|
|
1610
|
-
/** Set anti-aliasing for
|
|
1631
|
+
export function glCopyToContext(context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1632
|
+
/** Set anti-aliasing for WebGL canvas
|
|
1633
|
+
* Must be called before engineInit
|
|
1611
1634
|
* @param {boolean} [antialias]
|
|
1612
1635
|
* @memberof WebGL */
|
|
1613
1636
|
export function glSetAntialias(antialias?: boolean): void;
|
|
1614
|
-
/**
|
|
1637
|
+
/** Add a sprite to the gl draw list, used by all gl draw functions
|
|
1638
|
+
* @param {number} x
|
|
1639
|
+
* @param {number} y
|
|
1640
|
+
* @param {number} sizeX
|
|
1641
|
+
* @param {number} sizeY
|
|
1642
|
+
* @param {number} [angle]
|
|
1643
|
+
* @param {number} [uv0X]
|
|
1644
|
+
* @param {number} [uv0Y]
|
|
1645
|
+
* @param {number} [uv1X]
|
|
1646
|
+
* @param {number} [uv1Y]
|
|
1647
|
+
* @param {number} [rgba=-1] - white is -1
|
|
1648
|
+
* @param {number} [rgbaAdditive=0] - black is 0
|
|
1615
1649
|
* @memberof WebGL */
|
|
1616
|
-
export function
|
|
1617
|
-
/**
|
|
1650
|
+
export function glDraw(x: number, y: number, sizeX: number, sizeY: number, angle?: number, uv0X?: number, uv0Y?: number, uv1X?: number, uv1Y?: number, rgba?: number, rgbaAdditive?: number): void;
|
|
1651
|
+
/** Transform and add a polygon to the gl draw list
|
|
1652
|
+
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1653
|
+
* @param {number} rgba - Color of the polygon as a 32-bit integer
|
|
1654
|
+
* @param {number} x
|
|
1655
|
+
* @param {number} y
|
|
1656
|
+
* @param {number} sx
|
|
1657
|
+
* @param {number} sy
|
|
1658
|
+
* @param {number} angle
|
|
1659
|
+
* @param {boolean} [tristrip] - should tristrip algorithm be used
|
|
1660
|
+
* @memberof WebGL */
|
|
1661
|
+
export function glDrawPointsTransform(points: Array<Vector2>, rgba: number, x: number, y: number, sx: number, sy: number, angle: number, tristrip?: boolean): void;
|
|
1662
|
+
/** Transform and add a polygon to the gl draw list
|
|
1663
|
+
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1664
|
+
* @param {number} rgba - Color of the polygon as a 32-bit integer
|
|
1665
|
+
* @param {number} lineWidth - Width of the outline
|
|
1666
|
+
* @param {number} x
|
|
1667
|
+
* @param {number} y
|
|
1668
|
+
* @param {number} sx
|
|
1669
|
+
* @param {number} sy
|
|
1670
|
+
* @param {number} angle
|
|
1671
|
+
* @param {boolean} [wrap] - Should the outline connect the first and last points
|
|
1672
|
+
* @memberof WebGL */
|
|
1673
|
+
export function glDrawOutlineTransform(points: Array<Vector2>, rgba: number, lineWidth: number, x: number, y: number, sx: number, sy: number, angle: number, wrap?: boolean): void;
|
|
1674
|
+
/** Add a list of points to the gl draw list
|
|
1675
|
+
* @param {Array<Vector2>} points - Array of Vector2 points in tri strip order
|
|
1676
|
+
* @param {number} rgba - Color as a 32-bit integer
|
|
1677
|
+
* @memberof WebGL */
|
|
1678
|
+
export function glDrawPoints(points: Array<Vector2>, rgba: number): void;
|
|
1679
|
+
/** Add a list of colored points to the gl draw list
|
|
1680
|
+
* @param {Array<Vector2>} points - Array of Vector2 points in tri strip order
|
|
1681
|
+
* @param {Array<number>} pointColors - Array of 32-bit integer colors
|
|
1682
|
+
* @memberof WebGL */
|
|
1683
|
+
export function glDrawColoredPoints(points: Array<Vector2>, pointColors: Array<number>): void;
|
|
1684
|
+
/** Should WebGL be setup with anti-aliasing? must be set before calling engineInit
|
|
1618
1685
|
* @type {boolean}
|
|
1619
1686
|
* @memberof WebGL */
|
|
1620
1687
|
export let glAntialias: boolean;
|
|
1621
1688
|
export let glShader: any;
|
|
1689
|
+
export let glPolyShader: any;
|
|
1690
|
+
export let glPolyMode: any;
|
|
1691
|
+
export let glAdditive: any;
|
|
1692
|
+
export let glBatchAdditive: any;
|
|
1622
1693
|
export let glActiveTexture: any;
|
|
1623
1694
|
export let glArrayBuffer: any;
|
|
1624
1695
|
export let glGeometryBuffer: any;
|
|
1625
1696
|
export let glPositionData: any;
|
|
1626
1697
|
export let glColorData: any;
|
|
1627
|
-
export let
|
|
1628
|
-
export let glAdditive: any;
|
|
1629
|
-
export let glBatchAdditive: any;
|
|
1698
|
+
export let glBatchCount: any;
|
|
1630
1699
|
/**
|
|
1631
1700
|
* LittleJS Input System
|
|
1632
1701
|
* - Tracks keyboard down, pressed, and released
|
|
@@ -1765,6 +1834,28 @@ declare module "littlejsengine" {
|
|
|
1765
1834
|
* @return {boolean}
|
|
1766
1835
|
* @memberof Input */
|
|
1767
1836
|
export function pointerLockIsActive(): boolean;
|
|
1837
|
+
/**
|
|
1838
|
+
* LittleJS Audio System
|
|
1839
|
+
* - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a> - ZzFX Sound Effect Generator
|
|
1840
|
+
* - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a> - ZzFXM Music System
|
|
1841
|
+
* - Caches sounds and music for fast playback
|
|
1842
|
+
* - Can attenuate and apply stereo panning to sounds
|
|
1843
|
+
* - Ability to play mp3, ogg, and wave files
|
|
1844
|
+
* - Speech synthesis functions
|
|
1845
|
+
* @namespace Audio
|
|
1846
|
+
*/
|
|
1847
|
+
/** Audio context used by the engine
|
|
1848
|
+
* @type {AudioContext}
|
|
1849
|
+
* @memberof Audio */
|
|
1850
|
+
export let audioContext: AudioContext;
|
|
1851
|
+
/** Master gain node for all audio to pass through
|
|
1852
|
+
* @type {GainNode}
|
|
1853
|
+
* @memberof Audio */
|
|
1854
|
+
export let audioMasterGain: GainNode;
|
|
1855
|
+
/** Default sample rate used for sounds
|
|
1856
|
+
* @default 44100
|
|
1857
|
+
* @memberof Audio */
|
|
1858
|
+
export const audioDefaultSampleRate: 44100;
|
|
1768
1859
|
/**
|
|
1769
1860
|
* Sound Object - Stores a sound for later use and can be played positionally
|
|
1770
1861
|
*
|
|
@@ -1789,46 +1880,45 @@ declare module "littlejsengine" {
|
|
|
1789
1880
|
taper: number;
|
|
1790
1881
|
/** @property {number} - How much to randomize frequency each time sound plays */
|
|
1791
1882
|
randomness: any;
|
|
1792
|
-
|
|
1883
|
+
/** @property {number} - Sample rate for this sound */
|
|
1793
1884
|
sampleRate: number;
|
|
1885
|
+
/** @property {number} - Percentage of this sound currently loaded */
|
|
1886
|
+
loadedPercent: number;
|
|
1887
|
+
sampleChannels: any[][];
|
|
1794
1888
|
/** Play the sound
|
|
1795
|
-
*
|
|
1796
|
-
* @param {
|
|
1797
|
-
* @param {number} [pitch] - How much to scale pitch by (also adjusted by this.randomness)
|
|
1798
|
-
* @param {number} [randomnessScale] - How much to scale randomness
|
|
1799
|
-
* @param {boolean} [loop] - Should the sound loop
|
|
1800
|
-
* @return {AudioBufferSourceNode} - The audio source node
|
|
1801
|
-
*/
|
|
1802
|
-
play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1803
|
-
gainNode: GainNode;
|
|
1804
|
-
source: AudioBufferSourceNode;
|
|
1805
|
-
/** Set the sound volume of the most recently played instance of this sound
|
|
1889
|
+
* Sounds may not play until a user interaction occurs
|
|
1890
|
+
* @param {Vector2} [pos] - World space position to play the sound if any
|
|
1806
1891
|
* @param {number} [volume] - How much to scale volume by
|
|
1892
|
+
* @param {number} [pitch] - How much to scale pitch by
|
|
1893
|
+
* @param {number} [randomnessScale] - How much to scale pitch randomness
|
|
1894
|
+
* @param {boolean} [loop] - Should the sound loop?
|
|
1895
|
+
* @param {boolean} [paused] - Should the sound start paused
|
|
1896
|
+
* @return {SoundInstance} - The audio source node
|
|
1807
1897
|
*/
|
|
1808
|
-
|
|
1809
|
-
/**
|
|
1810
|
-
* @param {number}
|
|
1898
|
+
play(pos?: Vector2, volume?: number, pitch?: number, randomnessScale?: number, loop?: boolean, paused?: boolean): SoundInstance;
|
|
1899
|
+
/** Play a music track that loops by default
|
|
1900
|
+
* @param {number} [volume] - Volume to play the music at
|
|
1901
|
+
* @param {boolean} [loop] - Should the music loop?
|
|
1902
|
+
* @param {boolean} [paused] - Should the music start paused
|
|
1903
|
+
* @return {SoundInstance} - The audio source node
|
|
1811
1904
|
*/
|
|
1812
|
-
|
|
1813
|
-
/**
|
|
1814
|
-
*
|
|
1815
|
-
*/
|
|
1816
|
-
getSource(): AudioBufferSourceNode;
|
|
1817
|
-
/** Play the sound as a note with a semitone offset
|
|
1905
|
+
playMusic(volume?: number, loop?: boolean, paused?: boolean): SoundInstance;
|
|
1906
|
+
/** Play the sound as a musical note with a semitone offset
|
|
1907
|
+
* This can be used to play music with chromatic scales
|
|
1818
1908
|
* @param {number} semitoneOffset - How many semitones to offset pitch
|
|
1819
|
-
* @param {Vector2} [pos] - World space position to play the sound
|
|
1820
|
-
* @param {number} [volume=1] - How much to scale volume by
|
|
1821
|
-
* @return {
|
|
1909
|
+
* @param {Vector2} [pos] - World space position to play the sound if any
|
|
1910
|
+
* @param {number} [volume=1] - How much to scale volume by
|
|
1911
|
+
* @return {SoundInstance} - The audio source node
|
|
1822
1912
|
*/
|
|
1823
|
-
playNote(semitoneOffset: number, pos?: Vector2, volume?: number):
|
|
1913
|
+
playNote(semitoneOffset: number, pos?: Vector2, volume?: number): SoundInstance;
|
|
1824
1914
|
/** Get how long this sound is in seconds
|
|
1825
1915
|
* @return {number} - How long the sound is in seconds (undefined if loading)
|
|
1826
1916
|
*/
|
|
1827
1917
|
getDuration(): number;
|
|
1828
|
-
/** Check if sound is
|
|
1829
|
-
* @return {boolean} - True if sound is
|
|
1918
|
+
/** Check if sound is loaded, for sounds fetched from a url
|
|
1919
|
+
* @return {boolean} - True if sound is loaded and ready to play
|
|
1830
1920
|
*/
|
|
1831
|
-
|
|
1921
|
+
isLoaded(): boolean;
|
|
1832
1922
|
}
|
|
1833
1923
|
/**
|
|
1834
1924
|
* Sound Wave Object - Stores a wave sound for later use and can be played positionally
|
|
@@ -1856,13 +1946,82 @@ declare module "littlejsengine" {
|
|
|
1856
1946
|
* @return {Promise<void>} */
|
|
1857
1947
|
loadSound(filename: string): Promise<void>;
|
|
1858
1948
|
}
|
|
1859
|
-
/**
|
|
1860
|
-
*
|
|
1861
|
-
*
|
|
1862
|
-
*
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1865
|
-
|
|
1949
|
+
/**
|
|
1950
|
+
* Sound Instance - Wraps an AudioBufferSourceNode for individual sound control
|
|
1951
|
+
* Represents a single playing instance of a sound with pause/resume capabilities
|
|
1952
|
+
* @example
|
|
1953
|
+
* // Play a sound and get an instance for control
|
|
1954
|
+
* const jumpSound = new Sound([.5,.5,220]);
|
|
1955
|
+
* const instance = jumpSound.play();
|
|
1956
|
+
*
|
|
1957
|
+
* // Control the individual instance
|
|
1958
|
+
* instance.setVolume(.5);
|
|
1959
|
+
* instance.pause();
|
|
1960
|
+
* instance.unpause();
|
|
1961
|
+
* instance.stop();
|
|
1962
|
+
*/
|
|
1963
|
+
export class SoundInstance {
|
|
1964
|
+
/** Create a sound instance
|
|
1965
|
+
* @param {Sound} sound - The sound object
|
|
1966
|
+
* @param {number} [volume] - How much to scale volume by
|
|
1967
|
+
* @param {number} [rate] - The playback rate to use
|
|
1968
|
+
* @param {number} [pan] - How much to apply stereo panning
|
|
1969
|
+
* @param {boolean} [loop] - Should the sound loop?
|
|
1970
|
+
* @param {boolean} [paused] - Should the sound start paused? */
|
|
1971
|
+
constructor(sound: Sound, volume?: number, rate?: number, pan?: number, loop?: boolean, paused?: boolean);
|
|
1972
|
+
/** @property {Sound} - The sound object */
|
|
1973
|
+
sound: Sound;
|
|
1974
|
+
/** @property {number} - How much to scale volume by */
|
|
1975
|
+
volume: number;
|
|
1976
|
+
/** @property {number} - The playback rate to use */
|
|
1977
|
+
rate: number;
|
|
1978
|
+
/** @property {number} - How much to apply stereo panning */
|
|
1979
|
+
pan: number;
|
|
1980
|
+
/** @property {boolean} - Should the sound loop */
|
|
1981
|
+
loop: boolean;
|
|
1982
|
+
/** @property {number} - Timestamp for audio context when paused */
|
|
1983
|
+
pausedTime: number;
|
|
1984
|
+
/** @property {number} - Timestamp for audio context when started */
|
|
1985
|
+
startTime: number;
|
|
1986
|
+
/** @property {GainNode} - Gain node for the sound */
|
|
1987
|
+
gainNode: GainNode;
|
|
1988
|
+
/** @property {AudioBufferSourceNode} - Source node of the audio */
|
|
1989
|
+
source: AudioBufferSourceNode;
|
|
1990
|
+
onendedCallback: (source: any) => void;
|
|
1991
|
+
/** Start playing the sound instance from the offset time
|
|
1992
|
+
* @param {number} [offset] - Offset in seconds to start playback from
|
|
1993
|
+
*/
|
|
1994
|
+
start(offset?: number): void;
|
|
1995
|
+
/** Set the volume of this sound instance
|
|
1996
|
+
* @param {number} volume */
|
|
1997
|
+
setVolume(volume: number): void;
|
|
1998
|
+
/** Stop this sound instance and reset position to the start */
|
|
1999
|
+
stop(fadeTime?: number): void;
|
|
2000
|
+
/** Pause this sound instance */
|
|
2001
|
+
pause(): void;
|
|
2002
|
+
/** Unpauses this sound instance */
|
|
2003
|
+
resume(): void;
|
|
2004
|
+
/** Check if this instance is currently playing
|
|
2005
|
+
* @return {boolean} - True if playing
|
|
2006
|
+
*/
|
|
2007
|
+
isPlaying(): boolean;
|
|
2008
|
+
/** Check if this instance is paused and was not stopped
|
|
2009
|
+
* @return {boolean} - True if paused
|
|
2010
|
+
*/
|
|
2011
|
+
isPaused(): boolean;
|
|
2012
|
+
/** Get the current playback time in seconds
|
|
2013
|
+
* @return {number} - Current playback time
|
|
2014
|
+
*/
|
|
2015
|
+
getCurrentTime(): number;
|
|
2016
|
+
/** Get the total duration of this sound
|
|
2017
|
+
* @return {number} - Total duration in seconds
|
|
2018
|
+
*/
|
|
2019
|
+
getDuration(): number;
|
|
2020
|
+
/** Get source of this sound instance
|
|
2021
|
+
* @return {AudioBufferSourceNode}
|
|
2022
|
+
*/
|
|
2023
|
+
getSource(): AudioBufferSourceNode;
|
|
2024
|
+
}
|
|
1866
2025
|
/** Speak text with passed in settings
|
|
1867
2026
|
* @param {string} text - The text to speak
|
|
1868
2027
|
* @param {string} [language] - The language/accent to use (examples: en, it, ru, ja, zh)
|
|
@@ -1889,9 +2048,11 @@ declare module "littlejsengine" {
|
|
|
1889
2048
|
* @param {boolean} [loop] - True if the sound should loop when it reaches the end
|
|
1890
2049
|
* @param {number} [sampleRate=44100] - Sample rate for the sound
|
|
1891
2050
|
* @param {GainNode} [gainNode] - Optional gain node for volume control while playing
|
|
2051
|
+
* @param {number} [offset] - Offset in seconds to start playback from
|
|
2052
|
+
* @param {Function} [onended] - Callback for when the sound ends
|
|
1892
2053
|
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1893
2054
|
* @memberof Audio */
|
|
1894
|
-
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode): AudioBufferSourceNode;
|
|
2055
|
+
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean, sampleRate?: number, gainNode?: GainNode, offset?: number, onended?: Function): AudioBufferSourceNode;
|
|
1895
2056
|
/** Generate and play a ZzFX sound
|
|
1896
2057
|
*
|
|
1897
2058
|
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
@@ -1922,27 +2083,8 @@ declare module "littlejsengine" {
|
|
|
1922
2083
|
* @param {number} [tremolo] - Trembling effect, rate controlled by repeat time (percent)
|
|
1923
2084
|
* @param {number} [filter] - Filter cutoff frequency, positive for HPF, negative for LPF (Hz)
|
|
1924
2085
|
* @return {Array} - Array of audio samples
|
|
1925
|
-
* @memberof Audio
|
|
1926
|
-
*/
|
|
1927
|
-
export function zzfxG(volume?: number, randomness?: number, frequency?: number, attack?: number, sustain?: number, release?: number, shape?: number, shapeCurve?: number, slide?: number, deltaSlide?: number, pitchJump?: number, pitchJumpTime?: number, repeatTime?: number, noise?: number, modulation?: number, bitCrush?: number, delay?: number, sustainVolume?: number, decay?: number, tremolo?: number, filter?: number): any[];
|
|
1928
|
-
/** Sample rate used for all ZzFX sounds
|
|
1929
|
-
* @default 44100
|
|
1930
2086
|
* @memberof Audio */
|
|
1931
|
-
export
|
|
1932
|
-
/**
|
|
1933
|
-
* LittleJS Audio System
|
|
1934
|
-
* - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a> - ZzFX Sound Effect Generator
|
|
1935
|
-
* - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a> - ZzFXM Music System
|
|
1936
|
-
* - Caches sounds and music for fast playback
|
|
1937
|
-
* - Can attenuate and apply stereo panning to sounds
|
|
1938
|
-
* - Ability to play mp3, ogg, and wave files
|
|
1939
|
-
* - Speech synthesis functions
|
|
1940
|
-
* @namespace Audio
|
|
1941
|
-
*/
|
|
1942
|
-
/** Audio context used by the engine
|
|
1943
|
-
* @type {AudioContext}
|
|
1944
|
-
* @memberof Audio */
|
|
1945
|
-
export let audioContext: AudioContext;
|
|
2087
|
+
export function zzfxG(volume?: number, randomness?: number, frequency?: number, attack?: number, sustain?: number, release?: number, shape?: number, shapeCurve?: number, slide?: number, deltaSlide?: number, pitchJump?: number, pitchJumpTime?: number, repeatTime?: number, noise?: number, modulation?: number, bitCrush?: number, delay?: number, sustainVolume?: number, decay?: number, tremolo?: number, filter?: number): any[];
|
|
1946
2088
|
/**
|
|
1947
2089
|
* LittleJS Object System
|
|
1948
2090
|
*/
|
|
@@ -2108,14 +2250,13 @@ declare module "littlejsengine" {
|
|
|
2108
2250
|
* - Caches arrays of tiles to off screen canvas for fast rendering
|
|
2109
2251
|
* - Unlimited numbers of layers, allocates canvases as needed
|
|
2110
2252
|
* - Tile layers can be drawn to using their context with canvas2d
|
|
2111
|
-
* - Drawn directly to the main canvas without using WebGL
|
|
2112
2253
|
* - Tile layers can also have collision with EngineObjects
|
|
2113
2254
|
* @namespace TileCollision
|
|
2114
2255
|
*/
|
|
2115
2256
|
/** Keep track of all tile layers with collision
|
|
2116
2257
|
* @type {Array<TileCollisionLayer>}
|
|
2117
2258
|
* @memberof TileCollision */
|
|
2118
|
-
export
|
|
2259
|
+
export const tileCollisionLayers: Array<TileCollisionLayer>;
|
|
2119
2260
|
/** Get tile collision data for a given cell in the grid
|
|
2120
2261
|
* @param {Vector2} pos
|
|
2121
2262
|
* @return {number}
|
|
@@ -2179,7 +2320,7 @@ declare module "littlejsengine" {
|
|
|
2179
2320
|
/**
|
|
2180
2321
|
* Canvas Layer - cached off screen rendering system
|
|
2181
2322
|
* - Contains an offscreen canvas that can be rendered to
|
|
2182
|
-
* -
|
|
2323
|
+
* - WebGL rendering is optional, call useWebGL to enable
|
|
2183
2324
|
* @extends EngineObject
|
|
2184
2325
|
* @example
|
|
2185
2326
|
* const canvasLayer = new CanvasLayer(vec2(), vec2(200,100));
|
|
@@ -2197,7 +2338,7 @@ declare module "littlejsengine" {
|
|
|
2197
2338
|
canvas: OffscreenCanvas;
|
|
2198
2339
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2199
2340
|
context: OffscreenCanvasRenderingContext2D;
|
|
2200
|
-
/** @property {WebGLTexture} - Texture if using
|
|
2341
|
+
/** @property {WebGLTexture} - Texture if using WebGL for this layer, call useWebGL to enable */
|
|
2201
2342
|
glTexture: WebGLTexture;
|
|
2202
2343
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2203
2344
|
* @param {Vector2} pos - Center in world space
|
|
@@ -2210,7 +2351,7 @@ declare module "littlejsengine" {
|
|
|
2210
2351
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2211
2352
|
* @memberof Draw */
|
|
2212
2353
|
draw(pos: Vector2, size?: Vector2, angle?: number, color?: Color, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2213
|
-
/** Draw onto the layer canvas in world space (bypass
|
|
2354
|
+
/** Draw onto the layer canvas in world space (bypass WebGL)
|
|
2214
2355
|
* @param {Vector2} pos
|
|
2215
2356
|
* @param {Vector2} size
|
|
2216
2357
|
* @param {number} angle
|
|
@@ -2231,8 +2372,8 @@ declare module "littlejsengine" {
|
|
|
2231
2372
|
* @param {Color} [color=(1,1,1,1)]
|
|
2232
2373
|
* @param {number} [angle=0] */
|
|
2233
2374
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2234
|
-
/** Create or update the
|
|
2235
|
-
* @param {boolean} [enable] - enable
|
|
2375
|
+
/** Create or update the WebGL texture for this layer
|
|
2376
|
+
* @param {boolean} [enable] - enable WebGL rendering and update the texture */
|
|
2236
2377
|
useWebGL(enable?: boolean): void;
|
|
2237
2378
|
}
|
|
2238
2379
|
/**
|
|
@@ -2288,7 +2429,7 @@ declare module "littlejsengine" {
|
|
|
2288
2429
|
* Tile Collision Layer - a tile layer with collision
|
|
2289
2430
|
* - adds collision data and functions to TileLayer
|
|
2290
2431
|
* - there can be multiple tile collision layers
|
|
2291
|
-
* - tile
|
|
2432
|
+
* - tile collision layers should not overlap each other
|
|
2292
2433
|
* @extends TileLayer
|
|
2293
2434
|
*/
|
|
2294
2435
|
export class TileCollisionLayer extends TileLayer {
|
|
@@ -2350,41 +2491,41 @@ declare module "littlejsengine" {
|
|
|
2350
2491
|
export class ParticleEmitter extends EngineObject {
|
|
2351
2492
|
/** Create a particle system with the given settings
|
|
2352
2493
|
* @param {Vector2} position - World space position of the emitter
|
|
2353
|
-
* @param {
|
|
2354
|
-
* @param {
|
|
2355
|
-
* @param {
|
|
2356
|
-
* @param {
|
|
2357
|
-
* @param {
|
|
2494
|
+
* @param {number} [angle] - Angle to emit the particles
|
|
2495
|
+
* @param {number|Vector2} [emitSize] - World space size of the emitter (float for circle diameter, vec2 for rect)
|
|
2496
|
+
* @param {number} [emitTime] - How long to stay alive (0 is forever)
|
|
2497
|
+
* @param {number} [emitRate] - How many particles per second to spawn, does not emit if 0
|
|
2498
|
+
* @param {number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
2358
2499
|
* @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
|
|
2359
2500
|
* @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
|
|
2360
2501
|
* @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
|
|
2361
2502
|
* @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
|
|
2362
2503
|
* @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
|
|
2363
|
-
* @param {
|
|
2364
|
-
* @param {
|
|
2365
|
-
* @param {
|
|
2366
|
-
* @param {
|
|
2367
|
-
* @param {
|
|
2368
|
-
* @param {
|
|
2369
|
-
* @param {
|
|
2370
|
-
* @param {
|
|
2371
|
-
* @param {
|
|
2372
|
-
* @param {
|
|
2373
|
-
* @param {
|
|
2504
|
+
* @param {number} [particleTime] - How long particles live
|
|
2505
|
+
* @param {number} [sizeStart] - How big are particles at start
|
|
2506
|
+
* @param {number} [sizeEnd] - How big are particles at end
|
|
2507
|
+
* @param {number} [speed] - How fast are particles when spawned
|
|
2508
|
+
* @param {number} [angleSpeed] - How fast are particles rotating
|
|
2509
|
+
* @param {number} [damping] - How much to dampen particle speed
|
|
2510
|
+
* @param {number} [angleDamping] - How much to dampen particle angular speed
|
|
2511
|
+
* @param {number} [gravityScale] - How much gravity effect particles
|
|
2512
|
+
* @param {number} [particleConeAngle] - Cone for start particle angle
|
|
2513
|
+
* @param {number} [fadeRate] - How quick to fade particles at start/end in percent of life
|
|
2514
|
+
* @param {number} [randomness] - Apply extra randomness percent
|
|
2374
2515
|
* @param {boolean} [collideTiles] - Do particles collide against tiles
|
|
2375
2516
|
* @param {boolean} [additive] - Should particles use additive blend
|
|
2376
2517
|
* @param {boolean} [randomColorLinear] - Should color be randomized linearly or across each component
|
|
2377
|
-
* @param {
|
|
2518
|
+
* @param {number} [renderOrder] - Render order for particles (additive is above other stuff by default)
|
|
2378
2519
|
* @param {boolean} [localSpace] - Should it be in local space of emitter (world space is default)
|
|
2379
2520
|
*/
|
|
2380
2521
|
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);
|
|
2381
|
-
/** @property {
|
|
2522
|
+
/** @property {number|Vector2} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
2382
2523
|
emitSize: number | Vector2;
|
|
2383
|
-
/** @property {
|
|
2524
|
+
/** @property {number} - How long to stay alive (0 is forever) */
|
|
2384
2525
|
emitTime: number;
|
|
2385
|
-
/** @property {
|
|
2526
|
+
/** @property {number} - How many particles per second to spawn, does not emit if 0 */
|
|
2386
2527
|
emitRate: number;
|
|
2387
|
-
/** @property {
|
|
2528
|
+
/** @property {number} - Local angle to apply velocity to particles from emitter */
|
|
2388
2529
|
emitConeAngle: number;
|
|
2389
2530
|
/** @property {Color} - Color at start of life 1, randomized between start colors */
|
|
2390
2531
|
colorStartA: Color;
|
|
@@ -2396,33 +2537,33 @@ declare module "littlejsengine" {
|
|
|
2396
2537
|
colorEndB: Color;
|
|
2397
2538
|
/** @property {boolean} - Should color be randomized linearly or across each component */
|
|
2398
2539
|
randomColorLinear: boolean;
|
|
2399
|
-
/** @property {
|
|
2540
|
+
/** @property {number} - How long particles live */
|
|
2400
2541
|
particleTime: number;
|
|
2401
|
-
/** @property {
|
|
2542
|
+
/** @property {number} - How big are particles at start */
|
|
2402
2543
|
sizeStart: number;
|
|
2403
|
-
/** @property {
|
|
2544
|
+
/** @property {number} - How big are particles at end */
|
|
2404
2545
|
sizeEnd: number;
|
|
2405
|
-
/** @property {
|
|
2546
|
+
/** @property {number} - How fast are particles when spawned */
|
|
2406
2547
|
speed: number;
|
|
2407
|
-
/** @property {
|
|
2548
|
+
/** @property {number} - How fast are particles rotating */
|
|
2408
2549
|
angleSpeed: number;
|
|
2409
|
-
/** @property {
|
|
2550
|
+
/** @property {number} - Cone for start particle angle */
|
|
2410
2551
|
particleConeAngle: number;
|
|
2411
|
-
/** @property {
|
|
2552
|
+
/** @property {number} - How quick to fade in particles at start/end in percent of life */
|
|
2412
2553
|
fadeRate: number;
|
|
2413
|
-
/** @property {
|
|
2554
|
+
/** @property {number} - Apply extra randomness percent */
|
|
2414
2555
|
randomness: number;
|
|
2415
2556
|
/** @property {boolean} - Should particles use additive blend */
|
|
2416
2557
|
additive: boolean;
|
|
2417
2558
|
/** @property {boolean} - Should it be in local space of emitter */
|
|
2418
2559
|
localSpace: boolean;
|
|
2419
|
-
/** @property {
|
|
2560
|
+
/** @property {number} - If non zero the particle is drawn as a trail, stretched in the direction of velocity */
|
|
2420
2561
|
trailScale: number;
|
|
2421
2562
|
/** @property {Function} - Callback when particle is destroyed */
|
|
2422
2563
|
particleDestroyCallback: any;
|
|
2423
2564
|
/** @property {Function} - Callback when particle is created */
|
|
2424
2565
|
particleCreateCallback: any;
|
|
2425
|
-
/** @property {
|
|
2566
|
+
/** @property {number} - Track particle emit time */
|
|
2426
2567
|
emitTimeBuffer: number;
|
|
2427
2568
|
/** Spawn one particle
|
|
2428
2569
|
* @return {Particle} */
|
|
@@ -2438,15 +2579,15 @@ declare module "littlejsengine" {
|
|
|
2438
2579
|
* Typically this is created automatically by a ParticleEmitter
|
|
2439
2580
|
* @param {Vector2} position - World space position of the particle
|
|
2440
2581
|
* @param {TileInfo} tileInfo - Tile info to render particles
|
|
2441
|
-
* @param {
|
|
2582
|
+
* @param {number} angle - Angle to rotate the particle
|
|
2442
2583
|
* @param {Color} colorStart - Color at start of life
|
|
2443
2584
|
* @param {Color} colorEnd - Color at end of life
|
|
2444
|
-
* @param {
|
|
2445
|
-
* @param {
|
|
2446
|
-
* @param {
|
|
2447
|
-
* @param {
|
|
2585
|
+
* @param {number} lifeTime - How long to live for
|
|
2586
|
+
* @param {number} sizeStart - Size at start of life
|
|
2587
|
+
* @param {number} sizeEnd - Size at end of life
|
|
2588
|
+
* @param {number} fadeRate - How quick to fade in/out
|
|
2448
2589
|
* @param {boolean} additive - Does it use additive blend mode
|
|
2449
|
-
* @param {
|
|
2590
|
+
* @param {number} trailScale - If a trail, how long to make it
|
|
2450
2591
|
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
2451
2592
|
* @param {Function} [destroyCallback] - Callback when particle dies
|
|
2452
2593
|
*/
|
|
@@ -2455,17 +2596,17 @@ declare module "littlejsengine" {
|
|
|
2455
2596
|
colorStart: Color;
|
|
2456
2597
|
/** @property {Color} - Calculated change in color */
|
|
2457
2598
|
colorEndDelta: Color;
|
|
2458
|
-
/** @property {
|
|
2599
|
+
/** @property {number} - How long to live for */
|
|
2459
2600
|
lifeTime: number;
|
|
2460
|
-
/** @property {
|
|
2601
|
+
/** @property {number} - Size at start of life */
|
|
2461
2602
|
sizeStart: number;
|
|
2462
|
-
/** @property {
|
|
2603
|
+
/** @property {number} - Calculated change in size */
|
|
2463
2604
|
sizeEndDelta: number;
|
|
2464
|
-
/** @property {
|
|
2605
|
+
/** @property {number} - How quick to fade in/out */
|
|
2465
2606
|
fadeRate: number;
|
|
2466
2607
|
/** @property {boolean} - Is it additive */
|
|
2467
2608
|
additive: boolean;
|
|
2468
|
-
/** @property {
|
|
2609
|
+
/** @property {number} - If a trail, how long to make it */
|
|
2469
2610
|
trailScale: number;
|
|
2470
2611
|
/** @property {ParticleEmitter} - Parent emitter if local space */
|
|
2471
2612
|
localSpaceEmitter: ParticleEmitter;
|
|
@@ -2491,7 +2632,7 @@ declare module "littlejsengine" {
|
|
|
2491
2632
|
/** Initialize medals with a save name used for storage
|
|
2492
2633
|
* - Call this after creating all medals
|
|
2493
2634
|
* - Checks if medals are unlocked
|
|
2494
|
-
* @param {
|
|
2635
|
+
* @param {string} saveName
|
|
2495
2636
|
* @memberof Medals */
|
|
2496
2637
|
export function medalsInit(saveName: string): void;
|
|
2497
2638
|
/**
|
|
@@ -2508,20 +2649,20 @@ declare module "littlejsengine" {
|
|
|
2508
2649
|
*/
|
|
2509
2650
|
export class Medal {
|
|
2510
2651
|
/** Create a medal object and adds it to the list of medals
|
|
2511
|
-
* @param {
|
|
2512
|
-
* @param {
|
|
2513
|
-
* @param {
|
|
2514
|
-
* @param {
|
|
2515
|
-
* @param {
|
|
2652
|
+
* @param {number} id - The unique identifier of the medal
|
|
2653
|
+
* @param {string} name - Name of the medal
|
|
2654
|
+
* @param {string} [description] - Description of the medal
|
|
2655
|
+
* @param {string} [icon] - Icon for the medal
|
|
2656
|
+
* @param {string} [src] - Image location for the medal
|
|
2516
2657
|
*/
|
|
2517
2658
|
constructor(id: number, name: string, description?: string, icon?: string, src?: string);
|
|
2518
|
-
/** @property {
|
|
2659
|
+
/** @property {number} - The unique identifier of the medal */
|
|
2519
2660
|
id: number;
|
|
2520
|
-
/** @property {
|
|
2661
|
+
/** @property {string} - Name of the medal */
|
|
2521
2662
|
name: string;
|
|
2522
|
-
/** @property {
|
|
2663
|
+
/** @property {string} - Description of the medal */
|
|
2523
2664
|
description: string;
|
|
2524
|
-
/** @property {
|
|
2665
|
+
/** @property {string} - Icon for the medal */
|
|
2525
2666
|
icon: string;
|
|
2526
2667
|
/** @property {boolean} - Is the medal unlocked? */
|
|
2527
2668
|
unlocked: boolean;
|
|
@@ -2529,12 +2670,12 @@ declare module "littlejsengine" {
|
|
|
2529
2670
|
/** Unlocks a medal if not already unlocked */
|
|
2530
2671
|
unlock(): void;
|
|
2531
2672
|
/** Render a medal
|
|
2532
|
-
* @param {
|
|
2673
|
+
* @param {number} [hidePercent] - How much to slide the medal off screen
|
|
2533
2674
|
*/
|
|
2534
2675
|
render(hidePercent?: number): void;
|
|
2535
2676
|
/** Render the icon for a medal
|
|
2536
2677
|
* @param {Vector2} pos - Screen space position
|
|
2537
|
-
* @param {
|
|
2678
|
+
* @param {number} size - Screen space size
|
|
2538
2679
|
*/
|
|
2539
2680
|
renderIcon(pos: Vector2, size: number): void;
|
|
2540
2681
|
storageKey(): string;
|
|
@@ -2584,7 +2725,7 @@ declare module "littlejsengine" {
|
|
|
2584
2725
|
* @param {number} id - The scoreboard id
|
|
2585
2726
|
* @param {string} [user] - A user's id or name
|
|
2586
2727
|
* @param {number} [social] - If true, only social scores will be loaded
|
|
2587
|
-
* @param {number} [skip] - Number of scores to skip
|
|
2728
|
+
* @param {number} [skip] - Number of scores to skip over
|
|
2588
2729
|
* @param {number} [limit] - Number of scores to include in the list
|
|
2589
2730
|
* @return {Object} - The response JSON object
|
|
2590
2731
|
*/
|
|
@@ -2672,9 +2813,9 @@ declare module "littlejsengine" {
|
|
|
2672
2813
|
*/
|
|
2673
2814
|
constructor(zzfxMusic: [any[], any[], any[], number]);
|
|
2674
2815
|
sampleChannels: any[];
|
|
2675
|
-
/** Play the music
|
|
2676
|
-
* @param {number} [volume
|
|
2677
|
-
* @param {boolean} [loop] -
|
|
2816
|
+
/** Play the music that loops by default
|
|
2817
|
+
* @param {number} [volume] - Volume to play the music at
|
|
2818
|
+
* @param {boolean} [loop] - Should the music loop?
|
|
2678
2819
|
* @return {AudioBufferSourceNode} - The audio source node
|
|
2679
2820
|
*/
|
|
2680
2821
|
playMusic(volume?: number, loop?: boolean): AudioBufferSourceNode;
|
|
@@ -2736,7 +2877,7 @@ declare module "littlejsengine" {
|
|
|
2736
2877
|
* @param {Color} [color=uiSystem.defaultColor]
|
|
2737
2878
|
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2738
2879
|
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2739
|
-
* @param {number} [
|
|
2880
|
+
* @param {number} [cornerRadius=uiSystem.defaultCornerRadius] */
|
|
2740
2881
|
drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, cornerRadius?: number): void;
|
|
2741
2882
|
/** Draw a line to the UI context
|
|
2742
2883
|
* @param {Vector2} posA
|
|
@@ -2778,27 +2919,35 @@ declare module "littlejsengine" {
|
|
|
2778
2919
|
pos: Vector2;
|
|
2779
2920
|
/** @property {Vector2} - Screen space size of the object */
|
|
2780
2921
|
size: Vector2;
|
|
2781
|
-
/** @property {Color} -
|
|
2922
|
+
/** @property {Color} - Color of the object */
|
|
2782
2923
|
color: Color;
|
|
2783
|
-
/** @property {
|
|
2924
|
+
/** @property {string} - Text for this ui object */
|
|
2925
|
+
text: any;
|
|
2926
|
+
/** @property {Color} - Color when disabled */
|
|
2927
|
+
disabledColor: Color;
|
|
2928
|
+
/** @property {boolean} - Is this object disabled? */
|
|
2929
|
+
disabled: boolean;
|
|
2930
|
+
/** @property {Color} - Color for text */
|
|
2784
2931
|
textColor: Color;
|
|
2785
|
-
/** @property {Color} -
|
|
2932
|
+
/** @property {Color} - Color used when hovering over the object */
|
|
2786
2933
|
hoverColor: Color;
|
|
2787
|
-
/** @property {Color} -
|
|
2934
|
+
/** @property {Color} - Color for line drawing */
|
|
2788
2935
|
lineColor: Color;
|
|
2789
|
-
/** @property {number} -
|
|
2936
|
+
/** @property {number} - Width for line drawing */
|
|
2790
2937
|
lineWidth: number;
|
|
2791
|
-
/** @property {
|
|
2938
|
+
/** @property {number} - Corner radius for rounded rects */
|
|
2939
|
+
cornerRadius: number;
|
|
2940
|
+
/** @property {string} - Font for this objecct */
|
|
2792
2941
|
font: string;
|
|
2793
|
-
/** @property {number} -
|
|
2942
|
+
/** @property {number} - Override for text height */
|
|
2794
2943
|
textHeight: any;
|
|
2795
|
-
/** @property {boolean} -
|
|
2944
|
+
/** @property {boolean} - Should this object be drawn */
|
|
2796
2945
|
visible: boolean;
|
|
2797
|
-
/** @property {Array<UIObject>} -
|
|
2946
|
+
/** @property {Array<UIObject>} - A list of this object's children */
|
|
2798
2947
|
children: any[];
|
|
2799
|
-
/** @property {UIObject} -
|
|
2948
|
+
/** @property {UIObject} - This object's parent, position is in parent space */
|
|
2800
2949
|
parent: any;
|
|
2801
|
-
/** @property {number} - Extra size added
|
|
2950
|
+
/** @property {number} - Extra size added to make small buttons easier to touch on mobile devices */
|
|
2802
2951
|
extraTouchSize: number;
|
|
2803
2952
|
/** @property {Sound} - Sound when interactive element is pressed */
|
|
2804
2953
|
soundPress: any;
|
|
@@ -2824,7 +2973,7 @@ declare module "littlejsengine" {
|
|
|
2824
2973
|
update(): void;
|
|
2825
2974
|
/** Render the object, called automatically by plugin once each frame */
|
|
2826
2975
|
render(): void;
|
|
2827
|
-
/** Special update
|
|
2976
|
+
/** Special update when object is not visible */
|
|
2828
2977
|
updateInvisible(): void;
|
|
2829
2978
|
/** Called when the mouse enters the object */
|
|
2830
2979
|
onEnter(): void;
|
|
@@ -2852,9 +3001,7 @@ declare module "littlejsengine" {
|
|
|
2852
3001
|
* @param {string} [font=uiSystem.defaultFont]
|
|
2853
3002
|
*/
|
|
2854
3003
|
constructor(pos?: Vector2, size?: Vector2, text?: string, align?: string, font?: string);
|
|
2855
|
-
/** @property {string} */
|
|
2856
3004
|
text: string;
|
|
2857
|
-
/** @property {string} */
|
|
2858
3005
|
align: string;
|
|
2859
3006
|
}
|
|
2860
3007
|
/**
|
|
@@ -2890,12 +3037,7 @@ declare module "littlejsengine" {
|
|
|
2890
3037
|
* @param {Color} [color=uiSystem.defaultButtonColor]
|
|
2891
3038
|
*/
|
|
2892
3039
|
constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
|
|
2893
|
-
/** @property {string} */
|
|
2894
3040
|
text: string;
|
|
2895
|
-
/** @property {Color} */
|
|
2896
|
-
disabledColor: Color;
|
|
2897
|
-
/** @property {boolean} */
|
|
2898
|
-
disabled: boolean;
|
|
2899
3041
|
}
|
|
2900
3042
|
/**
|
|
2901
3043
|
* UICheckbox - A UI object that acts as a checkbox
|
|
@@ -2906,10 +3048,13 @@ declare module "littlejsengine" {
|
|
|
2906
3048
|
* @param {Vector2} [pos]
|
|
2907
3049
|
* @param {Vector2} [size]
|
|
2908
3050
|
* @param {boolean} [checked]
|
|
3051
|
+
* @param {string} [text]
|
|
3052
|
+
* @param {Color} [color=uiSystem.defaultButtonColor]
|
|
2909
3053
|
*/
|
|
2910
|
-
constructor(pos?: Vector2, size?: Vector2, checked?: boolean);
|
|
2911
|
-
/** @property {boolean} */
|
|
3054
|
+
constructor(pos?: Vector2, size?: Vector2, checked?: boolean, text?: string, color?: Color);
|
|
3055
|
+
/** @property {boolean} - Current percentage value of this scrollbar 0-1 */
|
|
2912
3056
|
checked: boolean;
|
|
3057
|
+
text: string;
|
|
2913
3058
|
}
|
|
2914
3059
|
/**
|
|
2915
3060
|
* UIScrollbar - A UI object that acts as a scrollbar
|
|
@@ -2925,12 +3070,11 @@ declare module "littlejsengine" {
|
|
|
2925
3070
|
* @param {Color} [handleColor=WHITE]
|
|
2926
3071
|
*/
|
|
2927
3072
|
constructor(pos?: Vector2, size?: Vector2, value?: number, text?: string, color?: Color, handleColor?: Color);
|
|
2928
|
-
/** @property {number} */
|
|
3073
|
+
/** @property {number} - Current percentage value of this scrollbar 0-1 */
|
|
2929
3074
|
value: number;
|
|
2930
|
-
/** @property {
|
|
2931
|
-
text: string;
|
|
2932
|
-
/** @property {Color} */
|
|
3075
|
+
/** @property {Color} - Color for the handle part of the scrollbar */
|
|
2933
3076
|
handleColor: Color;
|
|
3077
|
+
text: string;
|
|
2934
3078
|
}
|
|
2935
3079
|
/**
|
|
2936
3080
|
* LittleJS Box2D Physics Plugin
|
|
@@ -2960,7 +3104,9 @@ declare module "littlejsengine" {
|
|
|
2960
3104
|
* @param {boolean} enable
|
|
2961
3105
|
* @memberof Box2D */
|
|
2962
3106
|
export function box2dSetDebug(enable: boolean): void;
|
|
2963
|
-
/** Box2d Init - Call with await
|
|
3107
|
+
/** Box2d Init - Call with await to init box2d
|
|
3108
|
+
* @example
|
|
3109
|
+
* await box2dInit();
|
|
2964
3110
|
* @return {Promise<Box2dPlugin>}
|
|
2965
3111
|
* @memberof Box2D */
|
|
2966
3112
|
export function box2dInit(): Promise<Box2dPlugin>;
|
|
@@ -3808,7 +3954,7 @@ declare module "littlejsengine" {
|
|
|
3808
3954
|
getCorrectionFactor(): number;
|
|
3809
3955
|
}
|
|
3810
3956
|
/** Draw a scalable nine-slice UI element in world space
|
|
3811
|
-
* This function can apply color and additive color if
|
|
3957
|
+
* This function can apply color and additive color if WebGL is enabled
|
|
3812
3958
|
* @param {Vector2} pos - World space position
|
|
3813
3959
|
* @param {Vector2} size - World space size
|
|
3814
3960
|
* @param {TileInfo} startTile - Starting tile for the nine-slice pattern
|
|
@@ -3839,7 +3985,7 @@ declare module "littlejsengine" {
|
|
|
3839
3985
|
* @memberof DrawUtilities */
|
|
3840
3986
|
export function drawNineSliceScreen(pos: Vector2, size: Vector2, startTile: TileInfo, borderSize?: number, extraSpace?: number, angle?: number): void;
|
|
3841
3987
|
/** Draw a scalable three-slice UI element in world space
|
|
3842
|
-
* This function can apply color and additive color if
|
|
3988
|
+
* This function can apply color and additive color if WebGL is enabled
|
|
3843
3989
|
* @param {Vector2} pos - World space position
|
|
3844
3990
|
* @param {Vector2} size - World space size
|
|
3845
3991
|
* @param {TileInfo} startTile - Starting tile for the three-slice pattern
|