littlejsengine 1.17.1 → 1.17.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +10 -10
- package/dist/littlejs.d.ts +254 -171
- package/dist/littlejs.esm.js +892 -628
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +889 -626
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +885 -622
- package/examples/box2d/gameObjects.js +3 -3
- package/examples/electron/index.html +2 -2
- package/examples/index.html +10 -9
- package/examples/logo.png +0 -0
- package/examples/logo2.png +0 -0
- package/examples/module/build.bat +7 -0
- package/examples/module/build.js +121 -0
- package/examples/particles/index.html +1 -1
- package/examples/platformer/game.js +1 -1
- package/examples/platformer/gameEffects.js +5 -10
- package/examples/platformer/gameLevel.js +3 -3
- package/examples/puzzle/game.js +2 -2
- package/examples/shorts/base.html +4 -1
- package/examples/shorts/box2dPool.js +2 -2
- package/examples/shorts/box2dTileLayer.js +48 -0
- package/examples/shorts/colors.js +1 -1
- package/examples/shorts/fps.js +1 -1
- package/examples/shorts/music.js +5 -4
- package/examples/shorts/musicPlayer.js +4 -3
- package/examples/shorts/parallax.js +2 -2
- package/examples/shorts/tiltedView.js +1 -1
- package/examples/starter/index.html +2 -2
- package/package.json +5 -5
- package/plugins/box2d.js +166 -63
- package/plugins/pluginExport.js +1 -1
- package/plugins/postProcess.js +1 -1
- package/plugins/uiSystem.js +33 -20
- package/plugins/zzfxm.js +2 -2
- package/reference.md +9 -8
- package/src/engine.js +111 -134
- package/src/engineAudio.js +44 -58
- package/src/engineDebug.js +4 -4
- package/src/engineDraw.js +7 -4
- package/src/engineExport.js +2 -1
- package/src/engineInput.js +5 -5
- package/src/engineMath.js +9 -9
- package/src/engineObject.js +25 -25
- package/src/engineParticles.js +241 -118
- package/src/engineTileLayer.js +117 -88
- package/src/engineUtilities.js +105 -78
- package/src/engineWebGL.js +2 -2
- package/plugins/Box2D_License.txt +0 -17
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
|
|
@@ -123,11 +131,11 @@ declare module "littlejsengine" {
|
|
|
123
131
|
* @example
|
|
124
132
|
* // Basic engine startup
|
|
125
133
|
* engineInit(
|
|
126
|
-
* ()
|
|
127
|
-
* ()
|
|
128
|
-
* ()
|
|
129
|
-
* ()
|
|
130
|
-
* ()
|
|
134
|
+
* ()=> { LOG('Game initialized!'); }, // gameInit
|
|
135
|
+
* ()=> { updateGameLogic(); }, // gameUpdate
|
|
136
|
+
* ()=> { updateUI(); }, // gameUpdatePost
|
|
137
|
+
* ()=> { drawBackground(); }, // gameRender
|
|
138
|
+
* ()=> { drawHUD(); }, // gameRenderPost
|
|
131
139
|
* ['tiles.png', 'tilesLevel.png'] // images to load
|
|
132
140
|
* );
|
|
133
141
|
* @memberof Engine */
|
|
@@ -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
|
|
@@ -203,13 +214,13 @@ declare module "littlejsengine" {
|
|
|
203
214
|
/** Asserts if the expression is false, does nothing in release builds
|
|
204
215
|
* Halts execution if the assert fails and throws an error
|
|
205
216
|
* @param {boolean} assert
|
|
206
|
-
* @param {...Object}
|
|
217
|
+
* @param {...Object} output - error message output
|
|
207
218
|
* @memberof Debug */
|
|
208
|
-
export function ASSERT(assert: boolean, ...output
|
|
219
|
+
export function ASSERT(assert: boolean, ...output: any[]): void;
|
|
209
220
|
/** Log to console if debug is enabled, does nothing in release builds
|
|
210
|
-
* @param {...Object}
|
|
221
|
+
* @param {...Object} output - message output
|
|
211
222
|
* @memberof Debug */
|
|
212
|
-
export function LOG(...output
|
|
223
|
+
export function LOG(...output: any[]): void;
|
|
213
224
|
/** Draw a debug rectangle in world space
|
|
214
225
|
* @param {Vector2} pos
|
|
215
226
|
* @param {Vector2} [size=vec2(0)]
|
|
@@ -734,22 +745,22 @@ declare module "littlejsengine" {
|
|
|
734
745
|
* @memberof Math */
|
|
735
746
|
export const PI: number;
|
|
736
747
|
/** Returns absolute value of value passed in
|
|
737
|
-
* @param {number}
|
|
748
|
+
* @param {number} x
|
|
738
749
|
* @return {number}
|
|
739
750
|
* @memberof Math */
|
|
740
751
|
export const abs: (x: number) => number;
|
|
741
752
|
/** Returns floored value of value passed in
|
|
742
|
-
* @param {number}
|
|
753
|
+
* @param {number} x
|
|
743
754
|
* @return {number}
|
|
744
755
|
* @memberof Math */
|
|
745
756
|
export const floor: (x: number) => number;
|
|
746
757
|
/** Returns ceiled value of value passed in
|
|
747
|
-
* @param {number}
|
|
758
|
+
* @param {number} x
|
|
748
759
|
* @return {number}
|
|
749
760
|
* @memberof Math */
|
|
750
761
|
export const ceil: (x: number) => number;
|
|
751
762
|
/** Returns rounded value passed in
|
|
752
|
-
* @param {number}
|
|
763
|
+
* @param {number} x
|
|
753
764
|
* @return {number}
|
|
754
765
|
* @memberof Math */
|
|
755
766
|
export const round: (x: number) => number;
|
|
@@ -764,7 +775,7 @@ declare module "littlejsengine" {
|
|
|
764
775
|
* @memberof Math */
|
|
765
776
|
export const max: (...values: number[]) => number;
|
|
766
777
|
/** Returns the sign of value passed in
|
|
767
|
-
* @param {number}
|
|
778
|
+
* @param {number} x
|
|
768
779
|
* @return {number}
|
|
769
780
|
* @memberof Math */
|
|
770
781
|
export const sign: (x: number) => number;
|
|
@@ -774,22 +785,22 @@ declare module "littlejsengine" {
|
|
|
774
785
|
* @memberof Math */
|
|
775
786
|
export const hypot: (...values: number[]) => number;
|
|
776
787
|
/** Returns log2 of value passed in
|
|
777
|
-
* @param {number}
|
|
788
|
+
* @param {number} x
|
|
778
789
|
* @return {number}
|
|
779
790
|
* @memberof Math */
|
|
780
791
|
export const log2: (x: number) => number;
|
|
781
792
|
/** Returns sin of value passed in
|
|
782
|
-
* @param {number}
|
|
793
|
+
* @param {number} x
|
|
783
794
|
* @return {number}
|
|
784
795
|
* @memberof Math */
|
|
785
796
|
export const sin: (x: number) => number;
|
|
786
797
|
/** Returns cos of value passed in
|
|
787
|
-
* @param {number}
|
|
798
|
+
* @param {number} x
|
|
788
799
|
* @return {number}
|
|
789
800
|
* @memberof Math */
|
|
790
801
|
export const cos: (x: number) => number;
|
|
791
802
|
/** Returns tan of value passed in
|
|
792
|
-
* @param {number}
|
|
803
|
+
* @param {number} x
|
|
793
804
|
* @return {number}
|
|
794
805
|
* @memberof Math */
|
|
795
806
|
export const tan: (x: number) => number;
|
|
@@ -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
|
|
@@ -1488,7 +1510,7 @@ declare module "littlejsengine" {
|
|
|
1488
1510
|
*/
|
|
1489
1511
|
setFullImage(textureInfo?: TextureInfo): TileInfo;
|
|
1490
1512
|
/**
|
|
1491
|
-
* Returns a tile info for an index using this tile as
|
|
1513
|
+
* Returns a tile info for an index using this tile as reference
|
|
1492
1514
|
* @param {Vector2|number} [index=0]
|
|
1493
1515
|
* @return {TileInfo}
|
|
1494
1516
|
*/
|
|
@@ -1778,7 +1800,7 @@ declare module "littlejsengine" {
|
|
|
1778
1800
|
*/
|
|
1779
1801
|
export class FontImage {
|
|
1780
1802
|
/** Create an image font
|
|
1781
|
-
* @param {TileInfo} tileInfo - Tile info of first
|
|
1803
|
+
* @param {TileInfo} tileInfo - Tile info of first character in font
|
|
1782
1804
|
*/
|
|
1783
1805
|
constructor(tileInfo: TileInfo);
|
|
1784
1806
|
/** @property {TileInfo} - Tile info for the font */
|
|
@@ -2132,24 +2154,38 @@ declare module "littlejsengine" {
|
|
|
2132
2154
|
* @memberof Audio */
|
|
2133
2155
|
export const audioDefaultSampleRate: 44100;
|
|
2134
2156
|
/**
|
|
2135
|
-
* Sound Object - Stores a sound for later
|
|
2157
|
+
* Sound Object - Stores a sound for later
|
|
2158
|
+
* - this can be used to load and play wave, mp3, and ogg files
|
|
2159
|
+
* - it can also create sounds using the ZzFX sound generator
|
|
2160
|
+
* - can attenuate and apply stereo panning to sounds
|
|
2161
|
+
* - sound instance control with pause/resume capability
|
|
2136
2162
|
*
|
|
2137
2163
|
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
2138
2164
|
* @memberof Audio
|
|
2139
2165
|
* @example
|
|
2140
|
-
* //
|
|
2166
|
+
* // load an audio asset file
|
|
2167
|
+
* const sound_example = new Sound('sound.mp3');
|
|
2168
|
+
*
|
|
2169
|
+
* // create a zzfx sound
|
|
2141
2170
|
* const sound_example = new Sound([.5,.5]);
|
|
2142
2171
|
*
|
|
2143
|
-
* // play
|
|
2172
|
+
* // play a sound
|
|
2144
2173
|
* sound_example.play();
|
|
2145
2174
|
*/
|
|
2146
2175
|
export class Sound {
|
|
2147
|
-
/**
|
|
2148
|
-
*
|
|
2176
|
+
/**
|
|
2177
|
+
* @callback SoundLoadCallback - Function called when sound is loaded
|
|
2178
|
+
* @param {Sound} sound
|
|
2179
|
+
* @memberof Audio
|
|
2180
|
+
*/
|
|
2181
|
+
/** Create a sound object and cache the audio for later use
|
|
2182
|
+
* @param {string|Array} [asset] - Filename of audio file or zzfx array
|
|
2183
|
+
* @param {number} [randomness] - How much to randomize frequency each time sound plays, for zzfx sounds the zzfx default is used if undefined
|
|
2149
2184
|
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
2150
2185
|
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
2186
|
+
* @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
|
|
2151
2187
|
*/
|
|
2152
|
-
constructor(
|
|
2188
|
+
constructor(asset?: string | any[], randomness?: number, range?: number, taper?: number, onloadCallback?: (sound: Sound) => Sound);
|
|
2153
2189
|
/** @property {number} - World space max range of sound */
|
|
2154
2190
|
range: number;
|
|
2155
2191
|
/** @property {number} - At what percentage of range should it start tapering */
|
|
@@ -2160,6 +2196,8 @@ declare module "littlejsengine" {
|
|
|
2160
2196
|
sampleRate: number;
|
|
2161
2197
|
/** @property {number} - Percentage of this sound currently loaded */
|
|
2162
2198
|
loadedPercent: number;
|
|
2199
|
+
/** @property {SoundLoadCallback} - function to call when sound is loaded */
|
|
2200
|
+
onloadCallback: (sound: Sound) => Sound;
|
|
2163
2201
|
sampleChannels: any[][];
|
|
2164
2202
|
/** Play the sound
|
|
2165
2203
|
* Sounds may not play until a user interaction occurs
|
|
@@ -2176,7 +2214,7 @@ declare module "littlejsengine" {
|
|
|
2176
2214
|
* @param {number} [volume] - Volume to play the music at
|
|
2177
2215
|
* @param {boolean} [loop] - Should the music loop?
|
|
2178
2216
|
* @param {boolean} [paused] - Should the music start paused
|
|
2179
|
-
* @return {SoundInstance} - The
|
|
2217
|
+
* @return {SoundInstance} - The sound instance
|
|
2180
2218
|
*/
|
|
2181
2219
|
playMusic(volume?: number, loop?: boolean, paused?: boolean): SoundInstance;
|
|
2182
2220
|
/** Play the sound as a musical note with a semitone offset
|
|
@@ -2184,7 +2222,7 @@ declare module "littlejsengine" {
|
|
|
2184
2222
|
* @param {number} [semitoneOffset=0] - How many semitones to offset pitch
|
|
2185
2223
|
* @param {Vector2} [pos] - World space position to play the sound if any
|
|
2186
2224
|
* @param {number} [volume=1] - How much to scale volume by
|
|
2187
|
-
* @return {SoundInstance} - The
|
|
2225
|
+
* @return {SoundInstance} - The sound instance
|
|
2188
2226
|
*/
|
|
2189
2227
|
playNote(semitoneOffset?: number, pos?: Vector2, volume?: number): SoundInstance;
|
|
2190
2228
|
/** Get how long this sound is in seconds
|
|
@@ -2195,36 +2233,7 @@ declare module "littlejsengine" {
|
|
|
2195
2233
|
* @return {boolean} - True if sound is loaded and ready to play
|
|
2196
2234
|
*/
|
|
2197
2235
|
isLoaded(): boolean;
|
|
2198
|
-
|
|
2199
|
-
/**
|
|
2200
|
-
* Sound Wave Object - Loads and stores an audio file for later use
|
|
2201
|
-
* - this can be used to load and play wave, mp3, and ogg files
|
|
2202
|
-
* @extends Sound
|
|
2203
|
-
* @memberof Audio
|
|
2204
|
-
* @example
|
|
2205
|
-
* // load an audio asset file
|
|
2206
|
-
* const sound_example = new SoundWave('sound.mp3');
|
|
2207
|
-
*
|
|
2208
|
-
* // play the sound
|
|
2209
|
-
* sound_example.play();
|
|
2210
|
-
*/
|
|
2211
|
-
export class SoundWave extends Sound {
|
|
2212
|
-
/**
|
|
2213
|
-
* @callback SoundLoadCallback - Function called when sound is loaded
|
|
2214
|
-
* @param {SoundWave} sound
|
|
2215
|
-
* @memberof Audio
|
|
2216
|
-
*/
|
|
2217
|
-
/** Create a sound object and cache the wave file for later use
|
|
2218
|
-
* @param {string} filename - Filename of audio file to load
|
|
2219
|
-
* @param {number} [randomness] - How much to randomize frequency each time sound plays
|
|
2220
|
-
* @param {number} [range=soundDefaultRange] - World space max range of sound
|
|
2221
|
-
* @param {number} [taper=soundDefaultTaper] - At what percentage of range should it start tapering
|
|
2222
|
-
* @param {SoundLoadCallback} [onloadCallback] - callback function to call when sound is loaded
|
|
2223
|
-
*/
|
|
2224
|
-
constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: (sound: SoundWave) => SoundWave);
|
|
2225
|
-
/** @property {SoundLoadCallback} - callback function to call when sound is loaded */
|
|
2226
|
-
onloadCallback: (sound: SoundWave) => SoundWave;
|
|
2227
|
-
/** Loads a sound from a URL and decodes it into sample data. Must be used with await!
|
|
2236
|
+
/** Loads a sound from a URL and decodes it into sample data.
|
|
2228
2237
|
* @param {string} filename
|
|
2229
2238
|
* @return {Promise<void>} */
|
|
2230
2239
|
loadSound(filename: string): Promise<void>;
|
|
@@ -2429,15 +2438,17 @@ declare module "littlejsengine" {
|
|
|
2429
2438
|
additiveColor: any;
|
|
2430
2439
|
/** @property {boolean} - Should it flip along y axis when rendered */
|
|
2431
2440
|
mirror: boolean;
|
|
2432
|
-
/** @property {
|
|
2441
|
+
/** @property {boolean} - Has object been destroyed? */
|
|
2442
|
+
destroyed: boolean;
|
|
2443
|
+
/** @property {number} - How heavy the object is, static if 0 */
|
|
2433
2444
|
mass: number;
|
|
2434
|
-
/** @property {number}
|
|
2445
|
+
/** @property {number} - How much to slow down velocity each frame (0-1) */
|
|
2435
2446
|
damping: number;
|
|
2436
|
-
/** @property {number}
|
|
2447
|
+
/** @property {number} - How much to slow down rotation each frame (0-1) */
|
|
2437
2448
|
angleDamping: number;
|
|
2438
|
-
/** @property {number}
|
|
2449
|
+
/** @property {number} - How bouncy the object is when colliding (0-1) */
|
|
2439
2450
|
restitution: number;
|
|
2440
|
-
/** @property {number}
|
|
2451
|
+
/** @property {number} - How much friction to apply when sliding (0-1) */
|
|
2441
2452
|
friction: number;
|
|
2442
2453
|
/** @property {number} - How much to scale gravity by for this object */
|
|
2443
2454
|
gravityScale: number;
|
|
@@ -2477,9 +2488,9 @@ declare module "littlejsengine" {
|
|
|
2477
2488
|
update(): void;
|
|
2478
2489
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
2479
2490
|
render(): void;
|
|
2480
|
-
/** Destroy this object, destroy its children, detach its parent, and mark it for removal
|
|
2481
|
-
|
|
2482
|
-
|
|
2491
|
+
/** Destroy this object, destroy its children, detach its parent, and mark it for removal
|
|
2492
|
+
* @param {boolean} [immediate] - should attached effects be allowed to die off? */
|
|
2493
|
+
destroy(immediate?: boolean): void;
|
|
2483
2494
|
/** Convert from local space to world space
|
|
2484
2495
|
* @param {Vector2} pos - local space point */
|
|
2485
2496
|
localToWorld(pos: Vector2): Vector2;
|
|
@@ -2538,7 +2549,7 @@ declare module "littlejsengine" {
|
|
|
2538
2549
|
* @param {EngineObject} child */
|
|
2539
2550
|
removeChild(child: EngineObject): void;
|
|
2540
2551
|
/** Check if overlapping another engine object
|
|
2541
|
-
* Collisions are
|
|
2552
|
+
* Collisions are resolved to prevent overlaps
|
|
2542
2553
|
* @param {EngineObject} object
|
|
2543
2554
|
* @return {boolean} */
|
|
2544
2555
|
isOverlappingObject(object: EngineObject): boolean;
|
|
@@ -2573,27 +2584,34 @@ declare module "littlejsengine" {
|
|
|
2573
2584
|
export const tileCollisionLayers: Array<TileCollisionLayer>;
|
|
2574
2585
|
/** Get tile collision data for a given cell in the grid
|
|
2575
2586
|
* @param {Vector2} pos
|
|
2587
|
+
* @param {boolean} [solidOnly] - Only check solid layers?
|
|
2576
2588
|
* @return {number}
|
|
2577
2589
|
* @memberof TileLayers */
|
|
2578
|
-
export function tileCollisionGetData(pos: Vector2): number;
|
|
2590
|
+
export function tileCollisionGetData(pos: Vector2, solidOnly?: boolean): number;
|
|
2579
2591
|
/** Check if a tile layer collides with another object
|
|
2580
|
-
* @param {Vector2}
|
|
2581
|
-
* @param {Vector2}
|
|
2582
|
-
* @param {EngineObject} [
|
|
2583
|
-
* @param {boolean}
|
|
2592
|
+
* @param {Vector2} pos
|
|
2593
|
+
* @param {Vector2} [size=vec2()]
|
|
2594
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2595
|
+
* @param {boolean} [solidOnly] - Only check solid layers?
|
|
2584
2596
|
* @return {TileCollisionLayer}
|
|
2585
2597
|
* @memberof TileLayers */
|
|
2586
|
-
export function tileCollisionTest(pos: Vector2, size?: Vector2,
|
|
2598
|
+
export function tileCollisionTest(pos: Vector2, size?: Vector2, callbackObject?: EngineObject | TileCollisionCallback, solidOnly?: boolean): TileCollisionLayer;
|
|
2599
|
+
/**
|
|
2600
|
+
* @callback TileCollisionCallback - Function to handle a tile collision test
|
|
2601
|
+
* @param {number} tileData - the value of the tile at the position
|
|
2602
|
+
* @param {Vector2} pos - world space position of tile where the collision occurred
|
|
2603
|
+
* @memberof TileLayers
|
|
2604
|
+
*/
|
|
2587
2605
|
/** Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
|
|
2588
|
-
* The point will be inside the colliding tile if it hits
|
|
2589
|
-
* @param {Vector2}
|
|
2590
|
-
* @param {Vector2}
|
|
2591
|
-
* @param {EngineObject} [
|
|
2592
|
-
* @param {Vector2}
|
|
2593
|
-
* @param {boolean}
|
|
2606
|
+
* The point will be inside the colliding tile if it hits
|
|
2607
|
+
* @param {Vector2} posStart
|
|
2608
|
+
* @param {Vector2} posEnd
|
|
2609
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2610
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2611
|
+
* @param {boolean} [solidOnly=true] - Only check solid layers?
|
|
2594
2612
|
* @return {Vector2|undefined} - position of the center of the tile hit or undefined if no hit
|
|
2595
2613
|
* @memberof TileLayers */
|
|
2596
|
-
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2,
|
|
2614
|
+
export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, callbackObject?: EngineObject | TileCollisionCallback, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
|
|
2597
2615
|
/**
|
|
2598
2616
|
* Load tile layers from exported data
|
|
2599
2617
|
* @param {Object} tileMapData - Level data from exported data
|
|
@@ -2644,20 +2662,22 @@ declare module "littlejsengine" {
|
|
|
2644
2662
|
*/
|
|
2645
2663
|
export class CanvasLayer extends EngineObject {
|
|
2646
2664
|
/** Create a canvas layer object
|
|
2647
|
-
* @param {Vector2} [
|
|
2665
|
+
* @param {Vector2} [pos] - World space position of the layer
|
|
2648
2666
|
* @param {Vector2} [size] - World space size of the layer
|
|
2649
2667
|
* @param {number} [angle] - Angle the layer is rotated by
|
|
2650
2668
|
* @param {number} [renderOrder] - Objects sorted by renderOrder
|
|
2651
2669
|
* @param {Vector2} [canvasSize] - Default size of canvas, can be changed later
|
|
2652
2670
|
* @param {boolean} [useWebGL] - Should this layer use WebGL for rendering
|
|
2653
2671
|
*/
|
|
2654
|
-
constructor(
|
|
2672
|
+
constructor(pos?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2, useWebGL?: boolean);
|
|
2655
2673
|
/** @property {HTMLCanvasElement} - The canvas used by this layer */
|
|
2656
2674
|
canvas: OffscreenCanvas;
|
|
2657
2675
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2658
2676
|
context: OffscreenCanvasRenderingContext2D;
|
|
2659
2677
|
/** @property {TextureInfo} - Texture info to use for this object rendering */
|
|
2660
2678
|
textureInfo: TextureInfo;
|
|
2679
|
+
/** Destroy this canvas layer */
|
|
2680
|
+
destroy(): void;
|
|
2661
2681
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2662
2682
|
* @param {Vector2} pos - Center in world space
|
|
2663
2683
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2703,12 +2723,13 @@ declare module "littlejsengine" {
|
|
|
2703
2723
|
*/
|
|
2704
2724
|
export class TileLayer extends CanvasLayer {
|
|
2705
2725
|
/** Create a tile layer object
|
|
2706
|
-
* @param {Vector2}
|
|
2726
|
+
* @param {Vector2} pos - World space position
|
|
2707
2727
|
* @param {Vector2} size - World space size
|
|
2708
2728
|
* @param {TileInfo} [tileInfo] - Default tile info for layer (used for size and texture)
|
|
2709
2729
|
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2730
|
+
* @param {boolean} [useWebGL] - Should this layer use WebGL for rendering
|
|
2710
2731
|
*/
|
|
2711
|
-
constructor(
|
|
2732
|
+
constructor(pos: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number, useWebGL?: boolean);
|
|
2712
2733
|
/** @property {Array<TileLayerData>} - Default tile info for layer */
|
|
2713
2734
|
data: TileLayerData[];
|
|
2714
2735
|
/** @property {boolean} - Is this layer using a webgl texture? */
|
|
@@ -2722,14 +2743,14 @@ declare module "littlejsengine" {
|
|
|
2722
2743
|
redrawStart(clear?: boolean): void;
|
|
2723
2744
|
/** Call to end the redraw process */
|
|
2724
2745
|
redrawEnd(): void;
|
|
2725
|
-
/** Draw the tile at a given position in the tile
|
|
2746
|
+
/** Draw the tile at a given position in the tile layer
|
|
2726
2747
|
* This can be used to clear out tiles when they are destroyed
|
|
2727
2748
|
* Tiles can also be redrawn if inside a redrawStart/End block
|
|
2728
2749
|
* @param {Vector2} layerPos
|
|
2729
2750
|
* @param {boolean} [clear] - should the old tile be cleared out
|
|
2730
2751
|
*/
|
|
2731
2752
|
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2732
|
-
/** Draw the tile at a given position in the tile
|
|
2753
|
+
/** Draw the tile at a given position in the tile layer
|
|
2733
2754
|
* This can be used to clear tiles when they are destroyed
|
|
2734
2755
|
* For better performance use drawTileData inside a redrawStart/End block
|
|
2735
2756
|
* @param {Vector2} layerPos
|
|
@@ -2762,6 +2783,10 @@ declare module "littlejsengine" {
|
|
|
2762
2783
|
* @param {TileLayerData} data - Data to set
|
|
2763
2784
|
* @param {boolean} [redraw] - Force the tile to redraw if true */
|
|
2764
2785
|
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
2786
|
+
/** Clear data at a given position in the array
|
|
2787
|
+
* @param {Vector2} layerPos - Local position in array
|
|
2788
|
+
* @param {boolean} [redraw] - Force the tile to redraw if true */
|
|
2789
|
+
clearData(layerPos: Vector2, redraw?: boolean): void;
|
|
2765
2790
|
/** Get data at a given position in the array
|
|
2766
2791
|
* @param {Vector2} layerPos - Local position in array
|
|
2767
2792
|
* @return {TileLayerData} */
|
|
@@ -2784,41 +2809,55 @@ declare module "littlejsengine" {
|
|
|
2784
2809
|
/** Clear and initialize tile collision to new size
|
|
2785
2810
|
* @param {Vector2} size - width and height of tile collision 2d grid */
|
|
2786
2811
|
initCollision(size: Vector2): void;
|
|
2787
|
-
/** Set tile collision data for a given cell in the
|
|
2788
|
-
* @param {Vector2}
|
|
2812
|
+
/** Set tile collision data for a given cell in the layer
|
|
2813
|
+
* @param {Vector2} layerPos
|
|
2789
2814
|
* @param {number} [data] */
|
|
2790
|
-
setCollisionData(
|
|
2791
|
-
/**
|
|
2792
|
-
* @param {Vector2}
|
|
2815
|
+
setCollisionData(layerPos: Vector2, data?: number): void;
|
|
2816
|
+
/** Clear tile collision data for a given cell in the layer
|
|
2817
|
+
* @param {Vector2} layerPos */
|
|
2818
|
+
clearCollisionData(layerPos: Vector2): void;
|
|
2819
|
+
/** Get tile collision data for a given cell in the layer
|
|
2820
|
+
* @param {Vector2} layerPos
|
|
2793
2821
|
* @return {number} */
|
|
2794
|
-
getCollisionData(
|
|
2822
|
+
getCollisionData(layerPos: Vector2): number;
|
|
2795
2823
|
/** Check if collision with another object should occur
|
|
2796
2824
|
* @param {Vector2} pos
|
|
2797
2825
|
* @param {Vector2} [size=vec2()]
|
|
2798
|
-
* @param {EngineObject} [object
|
|
2826
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2799
2827
|
* @return {boolean} */
|
|
2800
|
-
collisionTest(pos: Vector2, size?: Vector2,
|
|
2828
|
+
collisionTest(pos: Vector2, size?: Vector2, callbackObject?: EngineObject | TileCollisionCallback): boolean;
|
|
2801
2829
|
/** Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
|
|
2802
2830
|
* The point will be inside the colliding tile if it hits (may have a tiny shift)
|
|
2803
|
-
* @param {Vector2}
|
|
2804
|
-
* @param {Vector2}
|
|
2805
|
-
* @param {EngineObject} [
|
|
2806
|
-
* @param {Vector2}
|
|
2831
|
+
* @param {Vector2} posStart
|
|
2832
|
+
* @param {Vector2} posEnd
|
|
2833
|
+
* @param {EngineObject|TileCollisionCallback} [callbackObject] - Callback, engine object, or undefined
|
|
2834
|
+
* @param {Vector2} [normal] - Optional normal of the surface hit
|
|
2807
2835
|
* @return {Vector2|undefined} */
|
|
2808
|
-
collisionRaycast(posStart: Vector2, posEnd: Vector2,
|
|
2836
|
+
collisionRaycast(posStart: Vector2, posEnd: Vector2, callbackObject?: EngineObject | TileCollisionCallback, normal?: Vector2): Vector2 | undefined;
|
|
2809
2837
|
}
|
|
2810
2838
|
/**
|
|
2811
2839
|
* LittleJS Particle System
|
|
2840
|
+
* - A simple but fast and flexible particle system
|
|
2841
|
+
* - Lightweight Particles are created and managed by ParticleEmitters
|
|
2842
|
+
* - The particle design tool can be used to help create emitters
|
|
2843
|
+
* @namespace Particles
|
|
2812
2844
|
*/
|
|
2813
2845
|
/**
|
|
2814
|
-
* @callback
|
|
2846
|
+
* @callback ParticleCallback - Function that processes a particle
|
|
2815
2847
|
* @param {Particle} particle
|
|
2816
|
-
* @memberof
|
|
2848
|
+
* @memberof Particles
|
|
2849
|
+
*/
|
|
2850
|
+
/**
|
|
2851
|
+
* @callback ParticleCollideCallback - Collide callback for particles
|
|
2852
|
+
* @param {Particle} particle
|
|
2853
|
+
* @param {number} tileData
|
|
2854
|
+
* @param {Vector2} pos
|
|
2855
|
+
* @memberof Particles
|
|
2817
2856
|
*/
|
|
2818
2857
|
/**
|
|
2819
2858
|
* Particle Emitter - Spawns particles with the given settings
|
|
2820
2859
|
* @extends EngineObject
|
|
2821
|
-
* @memberof
|
|
2860
|
+
* @memberof Particles
|
|
2822
2861
|
* @example
|
|
2823
2862
|
* // create a particle emitter
|
|
2824
2863
|
* let pos = vec2(2,3);
|
|
@@ -2835,7 +2874,7 @@ declare module "littlejsengine" {
|
|
|
2835
2874
|
*/
|
|
2836
2875
|
export class ParticleEmitter extends EngineObject {
|
|
2837
2876
|
/** Create a particle system with the given settings
|
|
2838
|
-
* @param {Vector2}
|
|
2877
|
+
* @param {Vector2} pos - World space position of the emitter
|
|
2839
2878
|
* @param {number} [angle] - Angle to emit the particles
|
|
2840
2879
|
* @param {number|Vector2} [emitSize] - World space size of the emitter (float for circle diameter, vec2 for rect)
|
|
2841
2880
|
* @param {number} [emitTime] - How long to stay alive (0 is forever)
|
|
@@ -2863,9 +2902,11 @@ declare module "littlejsengine" {
|
|
|
2863
2902
|
* @param {number} [renderOrder] - Render order for particles (additive is above other stuff by default)
|
|
2864
2903
|
* @param {boolean} [localSpace] - Should it be in local space of emitter (world space is default)
|
|
2865
2904
|
*/
|
|
2866
|
-
constructor(
|
|
2905
|
+
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);
|
|
2906
|
+
/** @property {boolean} - Should particles be emitted in a circle */
|
|
2907
|
+
emitCircle: boolean;
|
|
2867
2908
|
/** @property {number|Vector2} - World space size of the emitter (float for circle diameter, vec2 for rect) */
|
|
2868
|
-
emitSize:
|
|
2909
|
+
emitSize: Vector2;
|
|
2869
2910
|
/** @property {number} - How long to stay alive (0 is forever) */
|
|
2870
2911
|
emitTime: number;
|
|
2871
2912
|
/** @property {number} - How many particles per second to spawn, does not emit if 0 */
|
|
@@ -2904,64 +2945,86 @@ declare module "littlejsengine" {
|
|
|
2904
2945
|
localSpace: boolean;
|
|
2905
2946
|
/** @property {number} - If non zero the particle is drawn as a trail, stretched in the direction of velocity */
|
|
2906
2947
|
trailScale: number;
|
|
2907
|
-
/** @property {
|
|
2908
|
-
particleDestroyCallback: any;
|
|
2909
|
-
/** @property {ParticleCallbackFunction} - Callback when particle is created */
|
|
2948
|
+
/** @property {ParticleCallback} - Callback when particle is created */
|
|
2910
2949
|
particleCreateCallback: any;
|
|
2911
|
-
/** @property {
|
|
2912
|
-
|
|
2950
|
+
/** @property {ParticleCallback} - Callback when particle is destroyed */
|
|
2951
|
+
particleDestroyCallback: any;
|
|
2952
|
+
/** @property {ParticleCollideCallback} - Callback when particle collides */
|
|
2953
|
+
particleCollideCallback: any;
|
|
2913
2954
|
/** @property {number} - Percentage of velocity to pass to particles (0-1) */
|
|
2914
2955
|
velocityInheritance: number;
|
|
2956
|
+
/** @property {number} - Track particle emit time */
|
|
2957
|
+
emitTimeBuffer: number;
|
|
2958
|
+
/** @property {Array<Particle>} - Array of particles for this emitter */
|
|
2959
|
+
particles: any[];
|
|
2915
2960
|
previousAngle: number;
|
|
2916
2961
|
previousPos: Vector2;
|
|
2917
2962
|
/** Spawn one particle
|
|
2918
2963
|
* @return {Particle} */
|
|
2919
2964
|
emitParticle(): Particle;
|
|
2965
|
+
/** is emitter actively spawning */
|
|
2966
|
+
isActive(): boolean;
|
|
2920
2967
|
}
|
|
2921
2968
|
/**
|
|
2922
2969
|
* Particle Object - Created automatically by Particle Emitters
|
|
2923
|
-
* @
|
|
2924
|
-
* @memberof Engine
|
|
2970
|
+
* @memberof Particles
|
|
2925
2971
|
*/
|
|
2926
|
-
export class Particle
|
|
2972
|
+
export class Particle {
|
|
2927
2973
|
/**
|
|
2928
2974
|
* Create a particle with the passed in settings
|
|
2929
2975
|
* Typically this is created automatically by a ParticleEmitter
|
|
2930
|
-
* @param {
|
|
2931
|
-
* @param {
|
|
2932
|
-
* @param {number}
|
|
2933
|
-
* @param {Color}
|
|
2934
|
-
* @param {Color}
|
|
2935
|
-
* @param {number}
|
|
2936
|
-
* @param {number}
|
|
2937
|
-
* @param {number}
|
|
2938
|
-
* @param {
|
|
2939
|
-
* @param {
|
|
2940
|
-
* @param {number} trailScale - If a trail, how long to make it
|
|
2941
|
-
* @param {ParticleEmitter} [localSpaceEmitter] - Parent emitter if local space
|
|
2942
|
-
* @param {ParticleCallbackFunction} [destroyCallback] - Callback when particle dies
|
|
2976
|
+
* @param {ParticleEmitter} emitter - The emitter that created this particle
|
|
2977
|
+
* @param {Vector2} pos - World or local space position
|
|
2978
|
+
* @param {number} angle - Angle of the particle
|
|
2979
|
+
* @param {Color} colorStart - Color at start of life
|
|
2980
|
+
* @param {Color} colorEnd - Color at end of life
|
|
2981
|
+
* @param {number} lifeTime - How long to live for
|
|
2982
|
+
* @param {number} sizeStart - Size at start of life
|
|
2983
|
+
* @param {number} sizeEnd - Size at end of life
|
|
2984
|
+
* @param {Vector2} [velocity] - Velocity of the particle
|
|
2985
|
+
* @param {number} [angleVelocity] - Angular speed of the particle
|
|
2943
2986
|
*/
|
|
2944
|
-
constructor(
|
|
2945
|
-
/** @property {
|
|
2987
|
+
constructor(emitter: ParticleEmitter, pos: Vector2, angle: number, colorStart: Color, colorEnd: Color, lifeTime: number, sizeStart: number, sizeEnd: number, velocity?: Vector2, angleVelocity?: number);
|
|
2988
|
+
/** @property {ParticleEmitter} */
|
|
2989
|
+
emitter: ParticleEmitter;
|
|
2990
|
+
/** @property {Vector2} */
|
|
2991
|
+
pos: Vector2;
|
|
2992
|
+
/** @property {number} */
|
|
2993
|
+
angle: number;
|
|
2994
|
+
/** @property {Vector2} */
|
|
2995
|
+
size: Vector2;
|
|
2996
|
+
/** @property {Color} */
|
|
2997
|
+
color: Color;
|
|
2998
|
+
/** @property {Color} */
|
|
2946
2999
|
colorStart: Color;
|
|
2947
|
-
/** @property {Color}
|
|
3000
|
+
/** @property {Color} */
|
|
2948
3001
|
colorEnd: Color;
|
|
2949
|
-
/** @property {number}
|
|
3002
|
+
/** @property {number} */
|
|
2950
3003
|
lifeTime: number;
|
|
2951
|
-
/** @property {number}
|
|
3004
|
+
/** @property {number} */
|
|
2952
3005
|
sizeStart: number;
|
|
2953
|
-
/** @property {number}
|
|
3006
|
+
/** @property {number} */
|
|
2954
3007
|
sizeEnd: number;
|
|
2955
|
-
/** @property {
|
|
2956
|
-
|
|
2957
|
-
/** @property {
|
|
2958
|
-
|
|
2959
|
-
/** @property {number}
|
|
2960
|
-
|
|
2961
|
-
/** @property {
|
|
2962
|
-
|
|
2963
|
-
/** @property {
|
|
2964
|
-
|
|
3008
|
+
/** @property {Vector2} */
|
|
3009
|
+
velocity: Vector2;
|
|
3010
|
+
/** @property {number} */
|
|
3011
|
+
angleVelocity: number;
|
|
3012
|
+
/** @property {number} */
|
|
3013
|
+
spawnTime: number;
|
|
3014
|
+
/** @property {boolean} */
|
|
3015
|
+
mirror: boolean;
|
|
3016
|
+
/** @property {EngineObject} */
|
|
3017
|
+
groundObject: TileCollisionLayer;
|
|
3018
|
+
/** @property {boolean} */
|
|
3019
|
+
destroyed: boolean;
|
|
3020
|
+
/** @property {TileInfo} */
|
|
3021
|
+
tileInfo: TileInfo;
|
|
3022
|
+
/** Update the particle */
|
|
3023
|
+
update(): void;
|
|
3024
|
+
/** Destroy this particle */
|
|
3025
|
+
destroy(): void;
|
|
3026
|
+
/** Render the particle, automatically called each frame */
|
|
3027
|
+
render(): void;
|
|
2965
3028
|
}
|
|
2966
3029
|
/**
|
|
2967
3030
|
* LittleJS Medal System
|
|
@@ -3117,7 +3180,7 @@ declare module "littlejsengine" {
|
|
|
3117
3180
|
export class PostProcessPlugin {
|
|
3118
3181
|
/** Create global post processing shader
|
|
3119
3182
|
* @param {string} shaderCode
|
|
3120
|
-
* @param {boolean} [includeMainCanvas] - combine
|
|
3183
|
+
* @param {boolean} [includeMainCanvas] - combine mainCanvas onto glCanvas
|
|
3121
3184
|
* @param {boolean} [feedbackTexture] - use glCanvas from previous frame as the texture
|
|
3122
3185
|
* @example
|
|
3123
3186
|
* // create the post process plugin object
|
|
@@ -3176,9 +3239,9 @@ declare module "littlejsengine" {
|
|
|
3176
3239
|
/** Play the music that loops by default
|
|
3177
3240
|
* @param {number} [volume] - Volume to play the music at
|
|
3178
3241
|
* @param {boolean} [loop] - Should the music loop?
|
|
3179
|
-
* @return {
|
|
3242
|
+
* @return {SoundInstance} - The sound instance
|
|
3180
3243
|
*/
|
|
3181
|
-
playMusic(volume?: number, loop?: boolean):
|
|
3244
|
+
playMusic(volume?: number, loop?: boolean): SoundInstance;
|
|
3182
3245
|
}
|
|
3183
3246
|
/**
|
|
3184
3247
|
* LittleJS User Interface Plugin
|
|
@@ -3205,9 +3268,9 @@ declare module "littlejsengine" {
|
|
|
3205
3268
|
export let uiDebug: number;
|
|
3206
3269
|
/** Enable UI system debug drawing
|
|
3207
3270
|
* 0=off, 1=normal, 2=show invisible
|
|
3208
|
-
* @param {number|boolean}
|
|
3271
|
+
* @param {number|boolean} debugMode
|
|
3209
3272
|
* @memberof UISystem */
|
|
3210
|
-
export function uiSetDebug(debugMode:
|
|
3273
|
+
export function uiSetDebug(debugMode: number | boolean): void;
|
|
3211
3274
|
/**
|
|
3212
3275
|
* UI System Global Object
|
|
3213
3276
|
* @memberof UISystem
|
|
@@ -3260,7 +3323,7 @@ declare module "littlejsengine" {
|
|
|
3260
3323
|
nativeHeight: number;
|
|
3261
3324
|
/** @property {UIObject} - Object currently selected by navigation (gamepad or keyboard) */
|
|
3262
3325
|
navigationObject: any;
|
|
3263
|
-
/** @property {Timer} -
|
|
3326
|
+
/** @property {Timer} - Cool down timer for navigation inputs */
|
|
3264
3327
|
navigationTimer: Timer;
|
|
3265
3328
|
/** @property {number} - Time between navigation inputs in seconds */
|
|
3266
3329
|
navigationDelay: number;
|
|
@@ -3404,7 +3467,7 @@ declare module "littlejsengine" {
|
|
|
3404
3467
|
lineWidth: number;
|
|
3405
3468
|
/** @property {number} - Corner radius for rounded rects */
|
|
3406
3469
|
cornerRadius: number;
|
|
3407
|
-
/** @property {string} - Font for this
|
|
3470
|
+
/** @property {string} - Font for this object */
|
|
3408
3471
|
font: string;
|
|
3409
3472
|
/** @property {string} - Font style for this object or undefined */
|
|
3410
3473
|
fontStyle: any;
|
|
@@ -3596,6 +3659,8 @@ declare module "littlejsengine" {
|
|
|
3596
3659
|
value: number;
|
|
3597
3660
|
/** @property {Color} - Color for the handle part of the scrollbar */
|
|
3598
3661
|
handleColor: Color;
|
|
3662
|
+
/** @property {boolean} - Should it fill up like a progress bar? */
|
|
3663
|
+
fillMode: boolean;
|
|
3599
3664
|
text: string;
|
|
3600
3665
|
}
|
|
3601
3666
|
/**
|
|
@@ -3603,20 +3668,20 @@ declare module "littlejsengine" {
|
|
|
3603
3668
|
* @extends UIObject
|
|
3604
3669
|
* @example
|
|
3605
3670
|
* // Create a video player UI object
|
|
3606
|
-
* const video = new VideoPlayerUIObject(vec2(400, 300), vec2(320, 240), '
|
|
3671
|
+
* const video = new VideoPlayerUIObject(vec2(400, 300), vec2(320, 240), 'video.mp4', true);
|
|
3607
3672
|
* video.play();
|
|
3608
3673
|
* @memberof UISystem
|
|
3609
3674
|
*/
|
|
3610
3675
|
export class UIVideo extends UIObject {
|
|
3611
3676
|
/** Create a video player UI object
|
|
3612
|
-
* @param {Vector2}
|
|
3613
|
-
* @param {Vector2}
|
|
3677
|
+
* @param {Vector2} pos
|
|
3678
|
+
* @param {Vector2} size
|
|
3614
3679
|
* @param {string} src - Video file path or URL
|
|
3615
3680
|
* @param {boolean} [autoplay=false] - Start playing immediately?
|
|
3616
3681
|
* @param {boolean} [loop=false] - Loop the video?
|
|
3617
3682
|
* @param {number} [volume=1] - Volume percent scaled by global volume (0-1)
|
|
3618
3683
|
*/
|
|
3619
|
-
constructor(pos
|
|
3684
|
+
constructor(pos: Vector2, size: Vector2, src: string, autoplay?: boolean, loop?: boolean, volume?: number);
|
|
3620
3685
|
/** @property {number} - The video volume */
|
|
3621
3686
|
volume: number;
|
|
3622
3687
|
/** @property {HTMLVideoElement} - The video player */
|
|
@@ -3670,6 +3735,7 @@ declare module "littlejsengine" {
|
|
|
3670
3735
|
* - Contact begin and end callbacks
|
|
3671
3736
|
* - Wraps b2Vec2 type to/from Vector2
|
|
3672
3737
|
* - Raycasting and querying
|
|
3738
|
+
* - Box2dTileLayer for grid based collision
|
|
3673
3739
|
* - Every type of joint
|
|
3674
3740
|
* - Debug physics drawing
|
|
3675
3741
|
* @namespace Box2D
|
|
@@ -3702,8 +3768,11 @@ declare module "littlejsengine" {
|
|
|
3702
3768
|
/** Create the global UI system object
|
|
3703
3769
|
* @param {Object} instance */
|
|
3704
3770
|
constructor(instance: any);
|
|
3771
|
+
/** @property {Object} - The Box2d instance */
|
|
3705
3772
|
instance: any;
|
|
3773
|
+
/** @property {Object} - The Box2d world */
|
|
3706
3774
|
world: any;
|
|
3775
|
+
/** @property {Array<Box2dObject>} - List of all Box2d objects */
|
|
3707
3776
|
objects: any[];
|
|
3708
3777
|
/** @property {number} - Velocity iterations per update*/
|
|
3709
3778
|
velocityIterations: number;
|
|
@@ -3753,13 +3822,14 @@ declare module "littlejsengine" {
|
|
|
3753
3822
|
* @param {Color} [color]
|
|
3754
3823
|
* @param {Color} [lineColor]
|
|
3755
3824
|
* @param {number} [lineWidth]
|
|
3825
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
3756
3826
|
* @param {CanvasRenderingContext2D} [context] */
|
|
3757
|
-
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
3827
|
+
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, lineColor?: Color, lineWidth?: number, useWebgl: any, context?: CanvasRenderingContext2D): void;
|
|
3758
3828
|
/** converts a box2d vec2 to a Vector2
|
|
3759
3829
|
* @param {Object} v */
|
|
3760
3830
|
vec2From(v: any): Vector2;
|
|
3761
3831
|
/** converts a box2d vec2 pointer to a Vector2
|
|
3762
|
-
* @param {Object}
|
|
3832
|
+
* @param {Object} vp */
|
|
3763
3833
|
vec2FromPointer(vp: any): Vector2;
|
|
3764
3834
|
/** converts a Vector2 to a box2 vec2
|
|
3765
3835
|
* @param {Vector2} v */
|
|
@@ -3789,16 +3859,23 @@ declare module "littlejsengine" {
|
|
|
3789
3859
|
* @param {number} [bodyType]
|
|
3790
3860
|
* @param {number} [renderOrder] */
|
|
3791
3861
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, bodyType?: number, renderOrder?: number);
|
|
3862
|
+
/** @property {Object} - The Box2d body */
|
|
3792
3863
|
body: any;
|
|
3864
|
+
/** @property {Color} - Line color used for default box2d drawing */
|
|
3793
3865
|
lineColor: Color;
|
|
3866
|
+
/** @property {Array<Object>} - List of all edges for default box2d drawing */
|
|
3794
3867
|
edgeLists: any[];
|
|
3868
|
+
/** @property {Array<Object>} - List of all edge loops for default box2d drawing */
|
|
3795
3869
|
edgeLoops: any[];
|
|
3870
|
+
/** Destroy this object and its physics body */
|
|
3871
|
+
destroy(): void;
|
|
3796
3872
|
/** Draws all this object's fixtures
|
|
3797
|
-
* @param {Color}
|
|
3798
|
-
* @param {Color}
|
|
3799
|
-
* @param {number}
|
|
3873
|
+
* @param {Color} [color]
|
|
3874
|
+
* @param {Color} [lineColor]
|
|
3875
|
+
* @param {number} [lineWidth]
|
|
3876
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
3800
3877
|
* @param {CanvasRenderingContext2D} [context] */
|
|
3801
|
-
drawFixtures(color?: Color, lineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
3878
|
+
drawFixtures(color?: Color, lineColor?: Color, lineWidth?: number, useWebGL?: boolean, context?: CanvasRenderingContext2D): void;
|
|
3802
3879
|
/** Called when a contact begins
|
|
3803
3880
|
* @param {Box2dObject} otherObject */
|
|
3804
3881
|
beginContact(otherObject: Box2dObject): void;
|
|
@@ -3873,6 +3950,11 @@ declare module "littlejsengine" {
|
|
|
3873
3950
|
* @param {number} [restitution]
|
|
3874
3951
|
* @param {boolean} [isSensor] */
|
|
3875
3952
|
addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
|
|
3953
|
+
/** Destroy a fixture from the body
|
|
3954
|
+
* @param {Object} [fixture] */
|
|
3955
|
+
destroyFixture(fixture?: any): void;
|
|
3956
|
+
/** Destroy all fixture from the body */
|
|
3957
|
+
destroyAllFixtures(): void;
|
|
3876
3958
|
/** Gets the center of mass
|
|
3877
3959
|
* @return {Vector2} */
|
|
3878
3960
|
getCenterOfMass(): Vector2;
|
|
@@ -3998,11 +4080,11 @@ declare module "littlejsengine" {
|
|
|
3998
4080
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
3999
4081
|
}
|
|
4000
4082
|
/**
|
|
4001
|
-
* Box2D
|
|
4083
|
+
* Box2D Kinematic Object - Box2d with a kinematic physics body
|
|
4002
4084
|
* @extends Box2dObject
|
|
4003
4085
|
* @memberof Box2D
|
|
4004
4086
|
*/
|
|
4005
|
-
export class
|
|
4087
|
+
export class Box2dKinematicObject extends Box2dObject {
|
|
4006
4088
|
/** Create a LittleJS object with Box2d physics
|
|
4007
4089
|
* @param {Vector2} [pos]
|
|
4008
4090
|
* @param {Vector2} [size]
|
|
@@ -4045,6 +4127,7 @@ declare module "littlejsengine" {
|
|
|
4045
4127
|
/** Create a box2d joint, the base class is not intended to be used directly
|
|
4046
4128
|
* @param {Object} jointDef */
|
|
4047
4129
|
constructor(jointDef: any);
|
|
4130
|
+
/** @property {Object} - The Box2d joint */
|
|
4048
4131
|
box2dJoint: any;
|
|
4049
4132
|
/** Destroy this joint */
|
|
4050
4133
|
destroy(): void;
|
|
@@ -4275,8 +4358,8 @@ declare module "littlejsengine" {
|
|
|
4275
4358
|
* @param {Box2dObject} objectB
|
|
4276
4359
|
* @param {Box2dJoint} joint1
|
|
4277
4360
|
* @param {Box2dJoint} joint2
|
|
4278
|
-
* @param {
|
|
4279
|
-
constructor(objectA: Box2dObject, objectB: Box2dObject, joint1: Box2dJoint, joint2: Box2dJoint, ratio?:
|
|
4361
|
+
* @param {number} [ratio] */
|
|
4362
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, joint1: Box2dJoint, joint2: Box2dJoint, ratio?: number);
|
|
4280
4363
|
joint1: Box2dJoint;
|
|
4281
4364
|
joint2: Box2dJoint;
|
|
4282
4365
|
/** Get the first joint
|