littlejsengine 1.17.5 → 1.17.11
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/LICENSE +10 -10
- package/dist/littlejs.d.ts +189 -97
- package/dist/littlejs.esm.js +637 -477
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +633 -476
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +631 -474
- package/examples/electron/index.html +2 -2
- package/examples/games.jpg +0 -0
- package/examples/index.html +2 -2
- package/examples/logo.png +0 -0
- package/examples/logo2.png +0 -0
- package/examples/particles/index.html +1 -1
- package/examples/platformer/gameEffects.js +3 -3
- package/examples/screenshot.jpg +0 -0
- package/examples/shorts/base.html +1 -1
- package/examples/shorts/colors.js +1 -1
- package/examples/shorts/fontImage.js +1 -1
- package/examples/shorts/fps.js +1 -1
- package/examples/shorts/music.js +3 -2
- package/examples/shorts/musicPlayer.js +2 -1
- package/examples/shorts/parallax.js +2 -2
- package/examples/shorts/tiltedView.js +1 -1
- package/examples/starter/index.html +2 -2
- package/package.json +1 -1
- package/plugins/box2d.js +6 -7
- package/plugins/pluginExport.js +2 -1
- package/plugins/postProcess.js +1 -1
- package/plugins/uiSystem.js +33 -21
- package/reference.md +6 -6
- package/src/engine.js +106 -152
- package/src/engineAudio.js +5 -5
- package/src/engineDebug.js +1 -1
- package/src/engineDraw.js +36 -14
- package/src/engineExport.js +2 -0
- package/src/engineInput.js +1 -1
- package/src/engineMath.js +6 -4
- package/src/engineObject.js +24 -24
- package/src/engineParticles.js +241 -118
- package/src/engineTileLayer.js +66 -48
- package/src/engineUtilities.js +105 -78
- package/plugins/Box2D_License.txt +0 -17
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
MIT License
|
|
1
|
+
LittleJS Engine License (MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021 Frank Force
|
|
3
|
+
Copyright (c) 2021 Frank Force http://www.frankforce.com
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -22,12 +22,12 @@ SOFTWARE.
|
|
|
22
22
|
|
|
23
23
|
-------------------------------------------------------------------------------
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Copyright (c)
|
|
25
|
+
Box2D License
|
|
26
|
+
|
|
27
|
+
Copyright (c) 2006-2013 Erin Catto http://www.gphysics.com
|
|
28
28
|
|
|
29
29
|
This software is provided 'as-is', without any express or implied
|
|
30
|
-
warranty.
|
|
30
|
+
warranty. In no event will the authors be held liable for any damages
|
|
31
31
|
arising from the use of this software.
|
|
32
32
|
|
|
33
33
|
Permission is granted to anyone to use this software for any purpose,
|
|
@@ -35,9 +35,9 @@ including commercial applications, and to alter it and redistribute it
|
|
|
35
35
|
freely, subject to the following restrictions:
|
|
36
36
|
|
|
37
37
|
1. The origin of this software must not be misrepresented; you must not
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
claim that you wrote the original software. If you use this software
|
|
39
|
+
in a product, an acknowledgment in the product documentation would be
|
|
40
|
+
appreciated but is not required.
|
|
41
41
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
42
|
-
|
|
42
|
+
misrepresented as being the original software.
|
|
43
43
|
3. This notice may not be removed or altered from any source distribution.
|
package/dist/littlejs.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ declare module "littlejsengine" {
|
|
|
27
27
|
* - Function called when a sound ends
|
|
28
28
|
*/
|
|
29
29
|
export type AudioEndedCallback = (source: AudioBufferSourceNode) => any;
|
|
30
|
+
/**
|
|
31
|
+
* - Function to handle a tile collision test
|
|
32
|
+
*/
|
|
33
|
+
export type TileCollisionCallback = (tileData: number, pos: Vector2) => any;
|
|
30
34
|
/**
|
|
31
35
|
* - Function that processes a medal
|
|
32
36
|
*/
|
|
@@ -34,7 +38,11 @@ declare module "littlejsengine" {
|
|
|
34
38
|
/**
|
|
35
39
|
* - Function that processes a particle
|
|
36
40
|
*/
|
|
37
|
-
export type
|
|
41
|
+
export type ParticleCallback = (particle: Particle) => any;
|
|
42
|
+
/**
|
|
43
|
+
* - Collide callback for particles
|
|
44
|
+
*/
|
|
45
|
+
export type ParticleCollideCallback = (particle: Particle, tileData: number, pos: Vector2) => any;
|
|
38
46
|
/**
|
|
39
47
|
* LittleJS - The Tiny Fast JavaScript Game Engine
|
|
40
48
|
* MIT License - Copyright 2021 Frank Force
|
|
@@ -137,8 +145,11 @@ declare module "littlejsengine" {
|
|
|
137
145
|
* @memberof Engine */
|
|
138
146
|
export function engineObjectsUpdate(): void;
|
|
139
147
|
/** Destroy and remove all objects
|
|
148
|
+
* - This can be used to clear out all objects when restarting a level
|
|
149
|
+
* - Objects can override their destroy function to do cleanup or stick around
|
|
150
|
+
* @param {boolean} [immediate] - should attached effects be allowed to die off?
|
|
140
151
|
* @memberof Engine */
|
|
141
|
-
export function engineObjectsDestroy(): void;
|
|
152
|
+
export function engineObjectsDestroy(immediate?: boolean): void;
|
|
142
153
|
/** Collects all object within a given area
|
|
143
154
|
* @param {Vector2} [pos] - Center of test area, or undefined for all objects
|
|
144
155
|
* @param {Vector2|number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
@@ -889,12 +900,6 @@ declare module "littlejsengine" {
|
|
|
889
900
|
* @return {number} - Value waving between 0 and amplitude
|
|
890
901
|
* @memberof Math */
|
|
891
902
|
export function wave(frequency?: number, amplitude?: number, t?: number, offset?: number): number;
|
|
892
|
-
/**
|
|
893
|
-
* LittleJS Utility Classes and Functions
|
|
894
|
-
* - General purpose utilities
|
|
895
|
-
* - Timer - tracks time automatically
|
|
896
|
-
* @namespace Utilities
|
|
897
|
-
*/
|
|
898
903
|
/** Formats seconds to mm:ss style for display purposes
|
|
899
904
|
* @param {number} t - time in seconds
|
|
900
905
|
* @return {string}
|
|
@@ -929,6 +934,17 @@ declare module "littlejsengine" {
|
|
|
929
934
|
* @param {Function} [callback] - Called when share is complete
|
|
930
935
|
* @memberof Utilities */
|
|
931
936
|
export function shareURL(title: string, url: string, callback?: Function): void;
|
|
937
|
+
/** Read save data from local storage
|
|
938
|
+
* @param {string} saveName - unique name for the game/save
|
|
939
|
+
* @param {Object} [defaultSaveData] - default values for save
|
|
940
|
+
* @return {Object}
|
|
941
|
+
* @memberof Utilities */
|
|
942
|
+
export function readSaveData(saveName: string, defaultSaveData?: any): any;
|
|
943
|
+
/** Write save data to local storage
|
|
944
|
+
* @param {string} saveName - unique name for the game/save
|
|
945
|
+
* @param {Object} saveData - object containing data to be saved
|
|
946
|
+
* @memberof Utilities */
|
|
947
|
+
export function writeSaveData(saveName: string, saveData: any): void;
|
|
932
948
|
/** Random global functions
|
|
933
949
|
* @namespace Random */
|
|
934
950
|
/** Returns a random value between the two values passed in
|
|
@@ -1265,6 +1281,12 @@ declare module "littlejsengine" {
|
|
|
1265
1281
|
* @return {boolean} */
|
|
1266
1282
|
isValid(): boolean;
|
|
1267
1283
|
}
|
|
1284
|
+
/**
|
|
1285
|
+
* LittleJS Utility Classes and Functions
|
|
1286
|
+
* - General purpose utilities
|
|
1287
|
+
* - Timer - tracks time automatically
|
|
1288
|
+
* @namespace Utilities
|
|
1289
|
+
*/
|
|
1268
1290
|
/**
|
|
1269
1291
|
* Timer object tracks how long has passed since it was set
|
|
1270
1292
|
* @memberof Engine
|
|
@@ -1368,7 +1390,9 @@ declare module "littlejsengine" {
|
|
|
1368
1390
|
* @memberof Math */
|
|
1369
1391
|
export function isNumber(n: any): boolean;
|
|
1370
1392
|
/**
|
|
1371
|
-
* Check if object
|
|
1393
|
+
* Check if object can be converted to a string (has a toString method)
|
|
1394
|
+
* - Returns true for strings, numbers, and most objects
|
|
1395
|
+
* - Returns false for null and undefined
|
|
1372
1396
|
* @param {any} s
|
|
1373
1397
|
* @return {boolean}
|
|
1374
1398
|
* @memberof Math */
|
|
@@ -1383,7 +1407,7 @@ declare module "littlejsengine" {
|
|
|
1383
1407
|
* @type {Color}
|
|
1384
1408
|
* @memberof Math */
|
|
1385
1409
|
export const WHITE: Color;
|
|
1386
|
-
/** Color - Clear White #
|
|
1410
|
+
/** Color - Clear White #ffffff00 with 0 alpha
|
|
1387
1411
|
* @type {Color}
|
|
1388
1412
|
* @memberof Math */
|
|
1389
1413
|
export const CLEAR_WHITE: Color;
|
|
@@ -1391,7 +1415,7 @@ declare module "littlejsengine" {
|
|
|
1391
1415
|
* @type {Color}
|
|
1392
1416
|
* @memberof Math */
|
|
1393
1417
|
export const BLACK: Color;
|
|
1394
|
-
/** Color - Clear Black #
|
|
1418
|
+
/** Color - Clear Black #00000000 with 0 alpha
|
|
1395
1419
|
* @type {Color}
|
|
1396
1420
|
* @memberof Math */
|
|
1397
1421
|
export const CLEAR_BLACK: Color;
|
|
@@ -1488,7 +1512,7 @@ declare module "littlejsengine" {
|
|
|
1488
1512
|
*/
|
|
1489
1513
|
setFullImage(textureInfo?: TextureInfo): TileInfo;
|
|
1490
1514
|
/**
|
|
1491
|
-
* Returns a tile info for an index using this tile as
|
|
1515
|
+
* Returns a tile info for an index using this tile as reference
|
|
1492
1516
|
* @param {Vector2|number} [index=0]
|
|
1493
1517
|
* @return {TileInfo}
|
|
1494
1518
|
*/
|
|
@@ -1778,7 +1802,7 @@ declare module "littlejsengine" {
|
|
|
1778
1802
|
*/
|
|
1779
1803
|
export class FontImage {
|
|
1780
1804
|
/** Create an image font
|
|
1781
|
-
* @param {TileInfo} tileInfo - Tile info of first
|
|
1805
|
+
* @param {TileInfo} tileInfo - Tile info of first character in font
|
|
1782
1806
|
*/
|
|
1783
1807
|
constructor(tileInfo: TileInfo);
|
|
1784
1808
|
/** @property {TileInfo} - Tile info for the font */
|
|
@@ -2213,8 +2237,8 @@ declare module "littlejsengine" {
|
|
|
2213
2237
|
isLoaded(): boolean;
|
|
2214
2238
|
/** Loads a sound from a URL and decodes it into sample data.
|
|
2215
2239
|
* @param {string} filename
|
|
2216
|
-
* @return {Promise
|
|
2217
|
-
loadSound(filename: string): Promise<
|
|
2240
|
+
* @return {Promise} */
|
|
2241
|
+
loadSound(filename: string): Promise<any>;
|
|
2218
2242
|
}
|
|
2219
2243
|
/**
|
|
2220
2244
|
* Sound Instance - Wraps an AudioBufferSourceNode for individual sound control
|
|
@@ -2228,7 +2252,7 @@ declare module "littlejsengine" {
|
|
|
2228
2252
|
* // Control the individual instance
|
|
2229
2253
|
* instance.setVolume(.5);
|
|
2230
2254
|
* instance.pause();
|
|
2231
|
-
* instance.
|
|
2255
|
+
* instance.resume();
|
|
2232
2256
|
* instance.stop();
|
|
2233
2257
|
*/
|
|
2234
2258
|
export class SoundInstance {
|
|
@@ -2270,14 +2294,14 @@ declare module "littlejsengine" {
|
|
|
2270
2294
|
stop(fadeTime?: number): void;
|
|
2271
2295
|
/** Pause this sound instance */
|
|
2272
2296
|
pause(): void;
|
|
2273
|
-
/**
|
|
2297
|
+
/** Resume this sound instance */
|
|
2274
2298
|
resume(): void;
|
|
2275
2299
|
/** Check if this instance is currently playing
|
|
2276
2300
|
* @return {boolean} - True if playing
|
|
2277
2301
|
*/
|
|
2278
2302
|
isPlaying(): boolean;
|
|
2279
|
-
/** Check if this instance is paused
|
|
2280
|
-
* @return {boolean} - True if
|
|
2303
|
+
/** Check if this instance is paused or stopped (not currently playing)
|
|
2304
|
+
* @return {boolean} - True if not playing
|
|
2281
2305
|
*/
|
|
2282
2306
|
isPaused(): boolean;
|
|
2283
2307
|
/** Get the current playback time in seconds
|
|
@@ -2416,15 +2440,17 @@ declare module "littlejsengine" {
|
|
|
2416
2440
|
additiveColor: any;
|
|
2417
2441
|
/** @property {boolean} - Should it flip along y axis when rendered */
|
|
2418
2442
|
mirror: boolean;
|
|
2419
|
-
/** @property {
|
|
2443
|
+
/** @property {boolean} - Has object been destroyed? */
|
|
2444
|
+
destroyed: boolean;
|
|
2445
|
+
/** @property {number} - How heavy the object is, static if 0 */
|
|
2420
2446
|
mass: number;
|
|
2421
|
-
/** @property {number}
|
|
2447
|
+
/** @property {number} - How much to slow down velocity each frame (0-1) */
|
|
2422
2448
|
damping: number;
|
|
2423
|
-
/** @property {number}
|
|
2449
|
+
/** @property {number} - How much to slow down rotation each frame (0-1) */
|
|
2424
2450
|
angleDamping: number;
|
|
2425
|
-
/** @property {number}
|
|
2451
|
+
/** @property {number} - How bouncy the object is when colliding (0-1) */
|
|
2426
2452
|
restitution: number;
|
|
2427
|
-
/** @property {number}
|
|
2453
|
+
/** @property {number} - How much friction to apply when sliding (0-1) */
|
|
2428
2454
|
friction: number;
|
|
2429
2455
|
/** @property {number} - How much to scale gravity by for this object */
|
|
2430
2456
|
gravityScale: number;
|
|
@@ -2464,9 +2490,9 @@ declare module "littlejsengine" {
|
|
|
2464
2490
|
update(): void;
|
|
2465
2491
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
2466
2492
|
render(): void;
|
|
2467
|
-
/** Destroy this object, destroy its children, detach its parent, and mark it for removal
|
|
2468
|
-
|
|
2469
|
-
|
|
2493
|
+
/** Destroy this object, destroy its children, detach its parent, and mark it for removal
|
|
2494
|
+
* @param {boolean} [immediate] - should attached effects be allowed to die off? */
|
|
2495
|
+
destroy(immediate?: boolean): void;
|
|
2470
2496
|
/** Convert from local space to world space
|
|
2471
2497
|
* @param {Vector2} pos - local space point */
|
|
2472
2498
|
localToWorld(pos: Vector2): Vector2;
|
|
@@ -2525,7 +2551,7 @@ declare module "littlejsengine" {
|
|
|
2525
2551
|
* @param {EngineObject} child */
|
|
2526
2552
|
removeChild(child: EngineObject): void;
|
|
2527
2553
|
/** Check if overlapping another engine object
|
|
2528
|
-
* Collisions are
|
|
2554
|
+
* Collisions are resolved to prevent overlaps
|
|
2529
2555
|
* @param {EngineObject} object
|
|
2530
2556
|
* @return {boolean} */
|
|
2531
2557
|
isOverlappingObject(object: EngineObject): boolean;
|
|
@@ -2560,27 +2586,34 @@ declare module "littlejsengine" {
|
|
|
2560
2586
|
export const tileCollisionLayers: Array<TileCollisionLayer>;
|
|
2561
2587
|
/** Get tile collision data for a given cell in the grid
|
|
2562
2588
|
* @param {Vector2} pos
|
|
2589
|
+
* @param {boolean} [solidOnly] - Only check solid layers?
|
|
2563
2590
|
* @return {number}
|
|
2564
2591
|
* @memberof TileLayers */
|
|
2565
|
-
export function tileCollisionGetData(pos: Vector2): number;
|
|
2592
|
+
export function tileCollisionGetData(pos: Vector2, solidOnly?: boolean): number;
|
|
2566
2593
|
/** Check if a tile layer collides with another object
|
|
2567
|
-
* @param {Vector2}
|
|
2568
|
-
* @param {Vector2}
|
|
2569
|
-
* @param {EngineObject} [
|
|
2570
|
-
* @param {boolean}
|
|
2594
|
+
* @param {Vector2} pos
|
|
2595
|
+
* @param {Vector2} [size=vec2()]
|
|
2596
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2597
|
+
* @param {boolean} [solidOnly] - Only check solid layers?
|
|
2571
2598
|
* @return {TileCollisionLayer}
|
|
2572
2599
|
* @memberof TileLayers */
|
|
2573
|
-
export function tileCollisionTest(pos: Vector2, size?: Vector2,
|
|
2600
|
+
export function tileCollisionTest(pos: Vector2, size?: Vector2, callbackObject?: EngineObject | TileCollisionCallback, solidOnly?: boolean): TileCollisionLayer;
|
|
2601
|
+
/**
|
|
2602
|
+
* @callback TileCollisionCallback - Function to handle a tile collision test
|
|
2603
|
+
* @param {number} tileData - the value of the tile at the position
|
|
2604
|
+
* @param {Vector2} pos - world space position of tile where the collision occurred
|
|
2605
|
+
* @memberof TileLayers
|
|
2606
|
+
*/
|
|
2574
2607
|
/** Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
|
|
2575
|
-
* The point will be inside the colliding tile if it hits
|
|
2576
|
-
* @param {Vector2}
|
|
2577
|
-
* @param {Vector2}
|
|
2578
|
-
* @param {EngineObject} [
|
|
2579
|
-
* @param {Vector2}
|
|
2580
|
-
* @param {boolean}
|
|
2608
|
+
* The point will be inside the colliding tile if it hits
|
|
2609
|
+
* @param {Vector2} posStart
|
|
2610
|
+
* @param {Vector2} posEnd
|
|
2611
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2612
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2613
|
+
* @param {boolean} [solidOnly=true] - Only check solid layers?
|
|
2581
2614
|
* @return {Vector2|undefined} - position of the center of the tile hit or undefined if no hit
|
|
2582
2615
|
* @memberof TileLayers */
|
|
2583
|
-
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2,
|
|
2616
|
+
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, callbackObject?: EngineObject | TileCollisionCallback, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
|
|
2584
2617
|
/**
|
|
2585
2618
|
* Load tile layers from exported data
|
|
2586
2619
|
* @param {Object} tileMapData - Level data from exported data
|
|
@@ -2645,6 +2678,8 @@ declare module "littlejsengine" {
|
|
|
2645
2678
|
context: OffscreenCanvasRenderingContext2D;
|
|
2646
2679
|
/** @property {TextureInfo} - Texture info to use for this object rendering */
|
|
2647
2680
|
textureInfo: TextureInfo;
|
|
2681
|
+
/** Destroy this canvas layer */
|
|
2682
|
+
destroy(): void;
|
|
2648
2683
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2649
2684
|
* @param {Vector2} pos - Center in world space
|
|
2650
2685
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2790,30 +2825,41 @@ declare module "littlejsengine" {
|
|
|
2790
2825
|
/** Check if collision with another object should occur
|
|
2791
2826
|
* @param {Vector2} pos
|
|
2792
2827
|
* @param {Vector2} [size=vec2()]
|
|
2793
|
-
* @param {EngineObject} [object
|
|
2828
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2794
2829
|
* @return {boolean} */
|
|
2795
|
-
collisionTest(pos: Vector2, size?: Vector2,
|
|
2830
|
+
collisionTest(pos: Vector2, size?: Vector2, callbackObject?: EngineObject | TileCollisionCallback): boolean;
|
|
2796
2831
|
/** Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
|
|
2797
2832
|
* The point will be inside the colliding tile if it hits (may have a tiny shift)
|
|
2798
|
-
* @param {Vector2}
|
|
2799
|
-
* @param {Vector2}
|
|
2800
|
-
* @param {EngineObject} [
|
|
2801
|
-
* @param {Vector2}
|
|
2833
|
+
* @param {Vector2} posStart
|
|
2834
|
+
* @param {Vector2} posEnd
|
|
2835
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2836
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2802
2837
|
* @return {Vector2|undefined} */
|
|
2803
|
-
collisionRaycast(posStart: Vector2, posEnd: Vector2,
|
|
2838
|
+
collisionRaycast(posStart: Vector2, posEnd: Vector2, callbackObject?: EngineObject | TileCollisionCallback, normal?: Vector2): Vector2 | undefined;
|
|
2804
2839
|
}
|
|
2805
2840
|
/**
|
|
2806
2841
|
* LittleJS Particle System
|
|
2842
|
+
* - A simple but fast and flexible particle system
|
|
2843
|
+
* - Lightweight Particles are created and managed by ParticleEmitters
|
|
2844
|
+
* - The particle design tool can be used to help create emitters
|
|
2845
|
+
* @namespace Particles
|
|
2807
2846
|
*/
|
|
2808
2847
|
/**
|
|
2809
|
-
* @callback
|
|
2848
|
+
* @callback ParticleCallback - Function that processes a particle
|
|
2810
2849
|
* @param {Particle} particle
|
|
2811
|
-
* @memberof
|
|
2850
|
+
* @memberof Particles
|
|
2851
|
+
*/
|
|
2852
|
+
/**
|
|
2853
|
+
* @callback ParticleCollideCallback - Collide callback for particles
|
|
2854
|
+
* @param {Particle} particle
|
|
2855
|
+
* @param {number} tileData
|
|
2856
|
+
* @param {Vector2} pos
|
|
2857
|
+
* @memberof Particles
|
|
2812
2858
|
*/
|
|
2813
2859
|
/**
|
|
2814
2860
|
* Particle Emitter - Spawns particles with the given settings
|
|
2815
2861
|
* @extends EngineObject
|
|
2816
|
-
* @memberof
|
|
2862
|
+
* @memberof Particles
|
|
2817
2863
|
* @example
|
|
2818
2864
|
* // create a particle emitter
|
|
2819
2865
|
* let pos = vec2(2,3);
|
|
@@ -2830,7 +2876,7 @@ declare module "littlejsengine" {
|
|
|
2830
2876
|
*/
|
|
2831
2877
|
export class ParticleEmitter extends EngineObject {
|
|
2832
2878
|
/** Create a particle system with the given settings
|
|
2833
|
-
* @param {Vector2}
|
|
2879
|
+
* @param {Vector2} pos - World space position of the emitter
|
|
2834
2880
|
* @param {number} [angle] - Angle to emit the particles
|
|
2835
2881
|
* @param {number|Vector2} [emitSize] - World space size of the emitter (float for circle diameter, vec2 for rect)
|
|
2836
2882
|
* @param {number} [emitTime] - How long to stay alive (0 is forever)
|
|
@@ -2858,9 +2904,11 @@ declare module "littlejsengine" {
|
|
|
2858
2904
|
* @param {number} [renderOrder] - Render order for particles (additive is above other stuff by default)
|
|
2859
2905
|
* @param {boolean} [localSpace] - Should it be in local space of emitter (world space is default)
|
|
2860
2906
|
*/
|
|
2861
|
-
constructor(
|
|
2907
|
+
constructor(pos: 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);
|
|
2908
|
+
/** @property {boolean} - Should particles be emitted in a circle */
|
|
2909
|
+
emitCircle: boolean;
|
|
2862
2910
|
/** @property {number|Vector2} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
2863
|
-
emitSize:
|
|
2911
|
+
emitSize: Vector2;
|
|
2864
2912
|
/** @property {number} - How long to stay alive (0 is forever) */
|
|
2865
2913
|
emitTime: number;
|
|
2866
2914
|
/** @property {number} - How many particles per second to spawn, does not emit if 0 */
|
|
@@ -2899,64 +2947,86 @@ declare module "littlejsengine" {
|
|
|
2899
2947
|
localSpace: boolean;
|
|
2900
2948
|
/** @property {number} - If non zero the particle is drawn as a trail, stretched in the direction of velocity */
|
|
2901
2949
|
trailScale: number;
|
|
2902
|
-
/** @property {
|
|
2903
|
-
particleDestroyCallback: any;
|
|
2904
|
-
/** @property {ParticleCallbackFunction} - Callback when particle is created */
|
|
2950
|
+
/** @property {ParticleCallback} - Callback when particle is created */
|
|
2905
2951
|
particleCreateCallback: any;
|
|
2906
|
-
/** @property {
|
|
2907
|
-
|
|
2952
|
+
/** @property {ParticleCallback} - Callback when particle is destroyed */
|
|
2953
|
+
particleDestroyCallback: any;
|
|
2954
|
+
/** @property {ParticleCollideCallback} - Callback when particle collides */
|
|
2955
|
+
particleCollideCallback: any;
|
|
2908
2956
|
/** @property {number} - Percentage of velocity to pass to particles (0-1) */
|
|
2909
2957
|
velocityInheritance: number;
|
|
2958
|
+
/** @property {number} - Track particle emit time */
|
|
2959
|
+
emitTimeBuffer: number;
|
|
2960
|
+
/** @property {Array<Particle>} - Array of particles for this emitter */
|
|
2961
|
+
particles: any[];
|
|
2910
2962
|
previousAngle: number;
|
|
2911
2963
|
previousPos: Vector2;
|
|
2912
2964
|
/** Spawn one particle
|
|
2913
2965
|
* @return {Particle} */
|
|
2914
2966
|
emitParticle(): Particle;
|
|
2967
|
+
/** is emitter actively spawning */
|
|
2968
|
+
isActive(): boolean;
|
|
2915
2969
|
}
|
|
2916
2970
|
/**
|
|
2917
2971
|
* Particle Object - Created automatically by Particle Emitters
|
|
2918
|
-
* @
|
|
2919
|
-
* @memberof Engine
|
|
2972
|
+
* @memberof Particles
|
|
2920
2973
|
*/
|
|
2921
|
-
export class Particle
|
|
2974
|
+
export class Particle {
|
|
2922
2975
|
/**
|
|
2923
2976
|
* Create a particle with the passed in settings
|
|
2924
2977
|
* Typically this is created automatically by a ParticleEmitter
|
|
2925
|
-
* @param {
|
|
2926
|
-
* @param {
|
|
2927
|
-
* @param {number}
|
|
2928
|
-
* @param {Color}
|
|
2929
|
-
* @param {Color}
|
|
2930
|
-
* @param {number}
|
|
2931
|
-
* @param {number}
|
|
2932
|
-
* @param {number}
|
|
2933
|
-
* @param {
|
|
2934
|
-
* @param {
|
|
2935
|
-
* @param {number} trailScale - If a trail, how long to make it
|
|
2936
|
-
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
2937
|
-
* @param {ParticleCallbackFunction} [destroyCallback] - Callback when particle dies
|
|
2978
|
+
* @param {ParticleEmitter} emitter - The emitter that created this particle
|
|
2979
|
+
* @param {Vector2} pos - World or local space position
|
|
2980
|
+
* @param {number} angle - Angle of the particle
|
|
2981
|
+
* @param {Color} colorStart - Color at start of life
|
|
2982
|
+
* @param {Color} colorEnd - Color at end of life
|
|
2983
|
+
* @param {number} lifeTime - How long to live for
|
|
2984
|
+
* @param {number} sizeStart - Size at start of life
|
|
2985
|
+
* @param {number} sizeEnd - Size at end of life
|
|
2986
|
+
* @param {Vector2} [velocity] - Velocity of the particle
|
|
2987
|
+
* @param {number} [angleVelocity] - Angular speed of the particle
|
|
2938
2988
|
*/
|
|
2939
|
-
constructor(
|
|
2940
|
-
/** @property {
|
|
2989
|
+
constructor(emitter: ParticleEmitter, pos: Vector2, angle: number, colorStart: Color, colorEnd: Color, lifeTime: number, sizeStart: number, sizeEnd: number, velocity?: Vector2, angleVelocity?: number);
|
|
2990
|
+
/** @property {ParticleEmitter} */
|
|
2991
|
+
emitter: ParticleEmitter;
|
|
2992
|
+
/** @property {Vector2} */
|
|
2993
|
+
pos: Vector2;
|
|
2994
|
+
/** @property {number} */
|
|
2995
|
+
angle: number;
|
|
2996
|
+
/** @property {Vector2} */
|
|
2997
|
+
size: Vector2;
|
|
2998
|
+
/** @property {Color} */
|
|
2999
|
+
color: Color;
|
|
3000
|
+
/** @property {Color} */
|
|
2941
3001
|
colorStart: Color;
|
|
2942
|
-
/** @property {Color}
|
|
3002
|
+
/** @property {Color} */
|
|
2943
3003
|
colorEnd: Color;
|
|
2944
|
-
/** @property {number}
|
|
3004
|
+
/** @property {number} */
|
|
2945
3005
|
lifeTime: number;
|
|
2946
|
-
/** @property {number}
|
|
3006
|
+
/** @property {number} */
|
|
2947
3007
|
sizeStart: number;
|
|
2948
|
-
/** @property {number}
|
|
3008
|
+
/** @property {number} */
|
|
2949
3009
|
sizeEnd: number;
|
|
2950
|
-
/** @property {
|
|
2951
|
-
|
|
2952
|
-
/** @property {
|
|
2953
|
-
|
|
2954
|
-
/** @property {number}
|
|
2955
|
-
|
|
2956
|
-
/** @property {
|
|
2957
|
-
|
|
2958
|
-
/** @property {
|
|
2959
|
-
|
|
3010
|
+
/** @property {Vector2} */
|
|
3011
|
+
velocity: Vector2;
|
|
3012
|
+
/** @property {number} */
|
|
3013
|
+
angleVelocity: number;
|
|
3014
|
+
/** @property {number} */
|
|
3015
|
+
spawnTime: number;
|
|
3016
|
+
/** @property {boolean} */
|
|
3017
|
+
mirror: boolean;
|
|
3018
|
+
/** @property {EngineObject} */
|
|
3019
|
+
groundObject: TileCollisionLayer;
|
|
3020
|
+
/** @property {boolean} */
|
|
3021
|
+
destroyed: boolean;
|
|
3022
|
+
/** @property {TileInfo} */
|
|
3023
|
+
tileInfo: TileInfo;
|
|
3024
|
+
/** Update the particle */
|
|
3025
|
+
update(): void;
|
|
3026
|
+
/** Destroy this particle */
|
|
3027
|
+
destroy(): void;
|
|
3028
|
+
/** Render the particle, automatically called each frame */
|
|
3029
|
+
render(): void;
|
|
2960
3030
|
}
|
|
2961
3031
|
/**
|
|
2962
3032
|
* LittleJS Medal System
|
|
@@ -3112,7 +3182,7 @@ declare module "littlejsengine" {
|
|
|
3112
3182
|
export class PostProcessPlugin {
|
|
3113
3183
|
/** Create global post processing shader
|
|
3114
3184
|
* @param {string} shaderCode
|
|
3115
|
-
* @param {boolean} [includeMainCanvas] - combine
|
|
3185
|
+
* @param {boolean} [includeMainCanvas] - combine mainCanvas onto glCanvas
|
|
3116
3186
|
* @param {boolean} [feedbackTexture] - use glCanvas from previous frame as the texture
|
|
3117
3187
|
* @example
|
|
3118
3188
|
* // create the post process plugin object
|
|
@@ -3255,7 +3325,7 @@ declare module "littlejsengine" {
|
|
|
3255
3325
|
nativeHeight: number;
|
|
3256
3326
|
/** @property {UIObject} - Object currently selected by navigation (gamepad or keyboard) */
|
|
3257
3327
|
navigationObject: any;
|
|
3258
|
-
/** @property {Timer} -
|
|
3328
|
+
/** @property {Timer} - Cool down timer for navigation inputs */
|
|
3259
3329
|
navigationTimer: Timer;
|
|
3260
3330
|
/** @property {number} - Time between navigation inputs in seconds */
|
|
3261
3331
|
navigationDelay: number;
|
|
@@ -3399,7 +3469,7 @@ declare module "littlejsengine" {
|
|
|
3399
3469
|
lineWidth: number;
|
|
3400
3470
|
/** @property {number} - Corner radius for rounded rects */
|
|
3401
3471
|
cornerRadius: number;
|
|
3402
|
-
/** @property {string} - Font for this
|
|
3472
|
+
/** @property {string} - Font for this object */
|
|
3403
3473
|
font: string;
|
|
3404
3474
|
/** @property {string} - Font style for this object or undefined */
|
|
3405
3475
|
fontStyle: any;
|
|
@@ -3591,6 +3661,8 @@ declare module "littlejsengine" {
|
|
|
3591
3661
|
value: number;
|
|
3592
3662
|
/** @property {Color} - Color for the handle part of the scrollbar */
|
|
3593
3663
|
handleColor: Color;
|
|
3664
|
+
/** @property {boolean} - Should it fill up like a progress bar? */
|
|
3665
|
+
fillMode: boolean;
|
|
3594
3666
|
text: string;
|
|
3595
3667
|
}
|
|
3596
3668
|
/**
|
|
@@ -3598,7 +3670,7 @@ declare module "littlejsengine" {
|
|
|
3598
3670
|
* @extends UIObject
|
|
3599
3671
|
* @example
|
|
3600
3672
|
* // Create a video player UI object
|
|
3601
|
-
* const video = new VideoPlayerUIObject(vec2(400, 300), vec2(320, 240), '
|
|
3673
|
+
* const video = new VideoPlayerUIObject(vec2(400, 300), vec2(320, 240), 'video.mp4', true);
|
|
3602
3674
|
* video.play();
|
|
3603
3675
|
* @memberof UISystem
|
|
3604
3676
|
*/
|
|
@@ -3797,6 +3869,8 @@ declare module "littlejsengine" {
|
|
|
3797
3869
|
edgeLists: any[];
|
|
3798
3870
|
/** @property {Array<Object>} - List of all edge loops for default box2d drawing */
|
|
3799
3871
|
edgeLoops: any[];
|
|
3872
|
+
/** Destroy this object and its physics body */
|
|
3873
|
+
destroy(): void;
|
|
3800
3874
|
/** Draws all this object's fixtures
|
|
3801
3875
|
* @param {Color} [color]
|
|
3802
3876
|
* @param {Color} [lineColor]
|
|
@@ -4008,11 +4082,11 @@ declare module "littlejsengine" {
|
|
|
4008
4082
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
4009
4083
|
}
|
|
4010
4084
|
/**
|
|
4011
|
-
* Box2D
|
|
4085
|
+
* Box2D Kinematic Object - Box2d with a kinematic physics body
|
|
4012
4086
|
* @extends Box2dObject
|
|
4013
4087
|
* @memberof Box2D
|
|
4014
4088
|
*/
|
|
4015
|
-
export class
|
|
4089
|
+
export class Box2dKinematicObject extends Box2dObject {
|
|
4016
4090
|
/** Create a LittleJS object with Box2d physics
|
|
4017
4091
|
* @param {Vector2} [pos]
|
|
4018
4092
|
* @param {Vector2} [size]
|
|
@@ -4022,6 +4096,24 @@ declare module "littlejsengine" {
|
|
|
4022
4096
|
* @param {number} [renderOrder] */
|
|
4023
4097
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
4024
4098
|
}
|
|
4099
|
+
/**
|
|
4100
|
+
* Box2d Tile Layer
|
|
4101
|
+
* - adds Box2d support to tile layers
|
|
4102
|
+
* - creates static box2d fixtures for solid tiles
|
|
4103
|
+
* @extends Box2dObject
|
|
4104
|
+
* @memberof Box2D
|
|
4105
|
+
*/
|
|
4106
|
+
export class Box2dTileLayer extends Box2dObject {
|
|
4107
|
+
/** Create a Box2d tile layer object
|
|
4108
|
+
* @param {TileCollisionLayer} tileLayer - Tile layer for this object */
|
|
4109
|
+
constructor(tileLayer: TileCollisionLayer);
|
|
4110
|
+
/** @property {TileLayer} - The tile layer */
|
|
4111
|
+
tileLayer: TileCollisionLayer;
|
|
4112
|
+
/** Create box2d collision fixtures for solid tiles
|
|
4113
|
+
* @param {number} [friction]
|
|
4114
|
+
* @param {number} [restitution] */
|
|
4115
|
+
buildCollision(friction?: number, restitution?: number): void;
|
|
4116
|
+
}
|
|
4025
4117
|
/**
|
|
4026
4118
|
* Box2D Raycast Result
|
|
4027
4119
|
* - Holds results from a box2d raycast queries
|