littlejsengine 1.11.10 → 1.11.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/littlejs.d.ts +1311 -81
- package/dist/littlejs.esm.js +3135 -299
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +291 -293
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +193 -288
- package/examples/box2d/game.js +7 -10
- package/examples/box2d/gameObjects.js +33 -33
- package/examples/box2d/index.html +6 -6
- package/examples/box2d/scenes.js +28 -28
- package/examples/breakout/game.js +1 -4
- package/examples/breakout/index.html +4 -4
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/htmlMenu/game.js +14 -7
- package/examples/htmlMenu/index.html +3 -12
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/game.js +0 -3
- package/examples/platformer/index.html +8 -8
- package/examples/puzzle/game.js +0 -3
- package/examples/puzzle/index.html +2 -2
- package/examples/shorts/base.html +1 -1
- package/examples/starter/build.js +15 -5
- package/examples/starter/index.html +13 -13
- package/examples/stress/index.html +3 -2
- package/examples/uiSystem/game.js +1 -7
- package/examples/uiSystem/index.html +3 -3
- package/package.json +3 -3
- package/plugins/box2d.js +1552 -640
- package/plugins/{Box2D_v2.3.1_min.wasm.js → box2d.wasm.js} +1 -1
- package/plugins/newgrounds.js +13 -9
- package/plugins/pluginExport.js +51 -0
- package/plugins/postProcess.js +94 -93
- package/plugins/uiSystem.js +145 -161
- package/plugins/zzfxm.js +163 -0
- package/src/engine.js +15 -20
- package/src/engineAudio.js +74 -204
- package/src/engineBuild.js +21 -3
- package/src/engineDebug.js +104 -6
- package/src/engineDraw.js +27 -14
- package/src/engineExport.js +12 -6
- package/src/engineInput.js +10 -5
- package/src/engineMedals.js +20 -10
- package/src/engineObject.js +3 -1
- package/src/engineParticles.js +6 -1
- package/src/engineRelease.js +6 -1
- package/src/engineSettings.js +7 -14
- package/src/engineUtilities.js +5 -11
- package/src/engineWebGL.js +19 -7
- /package/plugins/{Box2D_v2.3.1_min.wasm.wasm → box2d.wasm.wasm} +0 -0
package/dist/littlejs.d.ts
CHANGED
|
@@ -216,6 +216,18 @@ declare module "littlejsengine" {
|
|
|
216
216
|
* @param {string} filename
|
|
217
217
|
* @memberof Debug */
|
|
218
218
|
export function debugSaveDataURL(dataURL: string, filename: string): void;
|
|
219
|
+
/** Show error as full page of red text
|
|
220
|
+
* @memberof Debug */
|
|
221
|
+
export function debugShowErrors(): void;
|
|
222
|
+
/** Check if video capture is active
|
|
223
|
+
* @memberof Debug */
|
|
224
|
+
export function debugVideoCaptureIsActive(): boolean;
|
|
225
|
+
/** Start capturing video
|
|
226
|
+
* @memberof Debug */
|
|
227
|
+
export function debugVideoCaptureStart(): void;
|
|
228
|
+
/** Stop capturing video and save to disk
|
|
229
|
+
* @memberof Debug */
|
|
230
|
+
export function debugVideoCaptureStop(): void;
|
|
219
231
|
/**
|
|
220
232
|
* LittleJS Engine Settings
|
|
221
233
|
* - All settings for the engine are here
|
|
@@ -265,6 +277,7 @@ declare module "littlejsengine" {
|
|
|
265
277
|
* @memberof Settings */
|
|
266
278
|
export let showSplashScreen: boolean;
|
|
267
279
|
/** Disables all rendering, audio, and input for servers
|
|
280
|
+
* - Must be set before startup to take effect
|
|
268
281
|
* @type {boolean}
|
|
269
282
|
* @default
|
|
270
283
|
* @memberof Settings */
|
|
@@ -325,11 +338,13 @@ declare module "littlejsengine" {
|
|
|
325
338
|
* @memberof Settings */
|
|
326
339
|
export let particleEmitRateScale: number;
|
|
327
340
|
/** Enable webgl rendering, webgl can be disabled and removed from build (with some features disabled)
|
|
341
|
+
* - Must be set before startup to take effect
|
|
328
342
|
* @type {boolean}
|
|
329
343
|
* @default
|
|
330
344
|
* @memberof Settings */
|
|
331
345
|
export let glEnable: boolean;
|
|
332
346
|
/** Fixes slow rendering in some browsers by not compositing the WebGL canvas
|
|
347
|
+
* - Must be set before startup to take effect
|
|
333
348
|
* @type {boolean}
|
|
334
349
|
* @default
|
|
335
350
|
* @memberof Settings */
|
|
@@ -351,7 +366,7 @@ declare module "littlejsengine" {
|
|
|
351
366
|
export let inputWASDEmulateDirection: boolean;
|
|
352
367
|
/** True if touch gamepad should appear on mobile devices
|
|
353
368
|
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
354
|
-
* - Must be set
|
|
369
|
+
* - Must be set before startup to take effect
|
|
355
370
|
* @type {boolean}
|
|
356
371
|
* @default
|
|
357
372
|
* @memberof Settings */
|
|
@@ -411,11 +426,6 @@ declare module "littlejsengine" {
|
|
|
411
426
|
* @default Vector2(640,80)
|
|
412
427
|
* @memberof Settings */
|
|
413
428
|
export let medalDisplaySize: Vector2;
|
|
414
|
-
/** Size of icon in medal display
|
|
415
|
-
* @type {number}
|
|
416
|
-
* @default
|
|
417
|
-
* @memberof Settings */
|
|
418
|
-
export let medalDisplayIconSize: number;
|
|
419
429
|
/** Set position of camera in world space
|
|
420
430
|
* @param {Vector2} pos
|
|
421
431
|
* @memberof Settings */
|
|
@@ -568,10 +578,6 @@ declare module "littlejsengine" {
|
|
|
568
578
|
* @param {Vector2} size
|
|
569
579
|
* @memberof Settings */
|
|
570
580
|
export function setMedalDisplaySize(size: Vector2): void;
|
|
571
|
-
/** Set size of icon in medal display
|
|
572
|
-
* @param {number} size
|
|
573
|
-
* @memberof Settings */
|
|
574
|
-
export function setMedalDisplayIconSize(size: number): void;
|
|
575
581
|
/** Set to stop medals from being unlockable
|
|
576
582
|
* @param {boolean} preventUnlock
|
|
577
583
|
* @memberof Settings */
|
|
@@ -1037,18 +1043,17 @@ declare module "littlejsengine" {
|
|
|
1037
1043
|
valueOf(): number;
|
|
1038
1044
|
}
|
|
1039
1045
|
/**
|
|
1040
|
-
* Create a 2d vector, can take
|
|
1041
|
-
* @param {
|
|
1042
|
-
* @param {number} [y]
|
|
1046
|
+
* Create a 2d vector, can take 1 or 2 scalar values
|
|
1047
|
+
* @param {number} [x]
|
|
1048
|
+
* @param {number} [y] - if y is undefined, x is used for both
|
|
1043
1049
|
* @return {Vector2}
|
|
1044
1050
|
* @example
|
|
1045
1051
|
* let a = vec2(0, 1); // vector with coordinates (0, 1)
|
|
1046
|
-
* let b = vec2(a); // copy a into b
|
|
1047
1052
|
* a = vec2(5); // set a to (5, 5)
|
|
1048
1053
|
* b = vec2(); // set b to (0, 0)
|
|
1049
1054
|
* @memberof Utilities
|
|
1050
1055
|
*/
|
|
1051
|
-
export function vec2(x?:
|
|
1056
|
+
export function vec2(x?: number, y?: number): Vector2;
|
|
1052
1057
|
/**
|
|
1053
1058
|
* Create a color object with RGBA values, white by default
|
|
1054
1059
|
* @param {number} [r=1] - red
|
|
@@ -1186,6 +1191,8 @@ declare module "littlejsengine" {
|
|
|
1186
1191
|
image: HTMLImageElement;
|
|
1187
1192
|
/** @property {Vector2} - size of the image */
|
|
1188
1193
|
size: Vector2;
|
|
1194
|
+
/** @property {Vector2} - inverse of the size, cached for rendering */
|
|
1195
|
+
sizeInverse: Vector2;
|
|
1189
1196
|
/** @property {WebGLTexture} - webgl texture */
|
|
1190
1197
|
glTexture: WebGLTexture;
|
|
1191
1198
|
}
|
|
@@ -1247,7 +1254,7 @@ declare module "littlejsengine" {
|
|
|
1247
1254
|
* @param {Color} [color=(1,1,1,1)] - Color to modulate with
|
|
1248
1255
|
* @param {number} [angle] - Angle to rotate by
|
|
1249
1256
|
* @param {boolean} [mirror] - If true image is flipped along the Y axis
|
|
1250
|
-
* @param {Color} [additiveColor
|
|
1257
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any
|
|
1251
1258
|
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1252
1259
|
* @param {boolean} [screenSpace=false] - If true the pos and size are in screen space
|
|
1253
1260
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
@@ -1461,6 +1468,11 @@ declare module "littlejsengine" {
|
|
|
1461
1468
|
* @return {WebGLTexture}
|
|
1462
1469
|
* @memberof WebGL */
|
|
1463
1470
|
export function glCreateTexture(image: HTMLImageElement): WebGLTexture;
|
|
1471
|
+
/** Set WebGL texture data from an image
|
|
1472
|
+
* @param {WebGLTexture} texture
|
|
1473
|
+
* @param {HTMLImageElement} image
|
|
1474
|
+
* @memberof WebGL */
|
|
1475
|
+
export function glSetTextureData(texture: WebGLTexture, image: HTMLImageElement): void;
|
|
1464
1476
|
/** Add a sprite to the gl draw list, used by all gl draw functions
|
|
1465
1477
|
* @param {Number} x
|
|
1466
1478
|
* @param {Number} y
|
|
@@ -1471,10 +1483,10 @@ declare module "littlejsengine" {
|
|
|
1471
1483
|
* @param {Number} uv0Y
|
|
1472
1484
|
* @param {Number} uv1X
|
|
1473
1485
|
* @param {Number} uv1Y
|
|
1474
|
-
* @param {Number} rgba
|
|
1475
|
-
* @param {Number} [rgbaAdditive=0]
|
|
1486
|
+
* @param {Number} [rgba=-1] - white is -1
|
|
1487
|
+
* @param {Number} [rgbaAdditive=0] - black is 0
|
|
1476
1488
|
* @memberof WebGL */
|
|
1477
|
-
export function glDraw(x: number, y: number, sizeX: number, sizeY: number, angle: number, uv0X: number, uv0Y: number, uv1X: number, uv1Y: number, rgba
|
|
1489
|
+
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;
|
|
1478
1490
|
/** Draw all sprites and clear out the buffer, called automatically by the system whenever necessary
|
|
1479
1491
|
* @memberof WebGL */
|
|
1480
1492
|
export function glFlush(): void;
|
|
@@ -1580,10 +1592,15 @@ declare module "littlejsengine" {
|
|
|
1580
1592
|
* @type {boolean}
|
|
1581
1593
|
* @memberof Input */
|
|
1582
1594
|
export let isUsingGamepad: boolean;
|
|
1583
|
-
/** Prevents input continuing to the default browser handling (
|
|
1595
|
+
/** Prevents input continuing to the default browser handling (true by default)
|
|
1584
1596
|
* @type {boolean}
|
|
1585
1597
|
* @memberof Input */
|
|
1586
|
-
export let
|
|
1598
|
+
export let inputPreventDefault: boolean;
|
|
1599
|
+
/** Prevents input continuing to the default browser handling
|
|
1600
|
+
* This is useful to disable for html menus so the browser can handle input normally
|
|
1601
|
+
* @param {boolean} preventDefault
|
|
1602
|
+
* @memberof Input */
|
|
1603
|
+
export function setInputPreventDefault(preventDefault: boolean): void;
|
|
1587
1604
|
/** Returns true if gamepad button is down
|
|
1588
1605
|
* @param {number} button
|
|
1589
1606
|
* @param {number} [gamepad]
|
|
@@ -1702,49 +1719,6 @@ declare module "littlejsengine" {
|
|
|
1702
1719
|
*/
|
|
1703
1720
|
constructor(filename: string, randomness?: number, range?: number, taper?: number, onloadCallback?: Function);
|
|
1704
1721
|
}
|
|
1705
|
-
/**
|
|
1706
|
-
* Music Object - Stores a zzfx music track for later use
|
|
1707
|
-
*
|
|
1708
|
-
* <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
|
|
1709
|
-
* @example
|
|
1710
|
-
* // create some music
|
|
1711
|
-
* const music_example = new Music(
|
|
1712
|
-
* [
|
|
1713
|
-
* [ // instruments
|
|
1714
|
-
* [,0,400] // simple note
|
|
1715
|
-
* ],
|
|
1716
|
-
* [ // patterns
|
|
1717
|
-
* [ // pattern 1
|
|
1718
|
-
* [ // channel 0
|
|
1719
|
-
* 0, -1, // instrument 0, left speaker
|
|
1720
|
-
* 1, 0, 9, 1 // channel notes
|
|
1721
|
-
* ],
|
|
1722
|
-
* [ // channel 1
|
|
1723
|
-
* 0, 1, // instrument 0, right speaker
|
|
1724
|
-
* 0, 12, 17, -1 // channel notes
|
|
1725
|
-
* ]
|
|
1726
|
-
* ],
|
|
1727
|
-
* ],
|
|
1728
|
-
* [0, 0, 0, 0], // sequence, play pattern 0 four times
|
|
1729
|
-
* 90 // BPM
|
|
1730
|
-
* ]);
|
|
1731
|
-
*
|
|
1732
|
-
* // play the music
|
|
1733
|
-
* music_example.play();
|
|
1734
|
-
*/
|
|
1735
|
-
export class Music extends Sound {
|
|
1736
|
-
/** Create a music object and cache the zzfx music samples for later use
|
|
1737
|
-
* @param {[Array, Array, Array, number]} zzfxMusic - Array of zzfx music parameters
|
|
1738
|
-
*/
|
|
1739
|
-
constructor(zzfxMusic: [any[], any[], any[], number]);
|
|
1740
|
-
sampleChannels: any[];
|
|
1741
|
-
/** Play the music
|
|
1742
|
-
* @param {number} [volume=1] - How much to scale volume by
|
|
1743
|
-
* @param {boolean} [loop] - True if the music should loop
|
|
1744
|
-
* @return {AudioBufferSourceNode} - The audio source node
|
|
1745
|
-
*/
|
|
1746
|
-
playMusic(volume?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1747
|
-
}
|
|
1748
1722
|
/** Play an mp3, ogg, or wav audio from a local file or url
|
|
1749
1723
|
* @param {string} filename - Location of sound file to play
|
|
1750
1724
|
* @param {number} [volume] - How much to scale volume by
|
|
@@ -1770,20 +1744,6 @@ declare module "littlejsengine" {
|
|
|
1770
1744
|
* @return {number} - The frequency of the note
|
|
1771
1745
|
* @memberof Audio */
|
|
1772
1746
|
export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
|
|
1773
|
-
/**
|
|
1774
|
-
* LittleJS Audio System
|
|
1775
|
-
* - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a> - ZzFX Sound Effect Generator
|
|
1776
|
-
* - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a> - ZzFXM Music System
|
|
1777
|
-
* - Caches sounds and music for fast playback
|
|
1778
|
-
* - Can attenuate and apply stereo panning to sounds
|
|
1779
|
-
* - Ability to play mp3, ogg, and wave files
|
|
1780
|
-
* - Speech synthesis functions
|
|
1781
|
-
* @namespace Audio
|
|
1782
|
-
*/
|
|
1783
|
-
/** Audio context used by the engine
|
|
1784
|
-
* @type {AudioContext}
|
|
1785
|
-
* @memberof Audio */
|
|
1786
|
-
export let audioContext: AudioContext;
|
|
1787
1747
|
/** Play cached audio samples with given settings
|
|
1788
1748
|
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
|
|
1789
1749
|
* @param {number} [volume] - How much to scale volume by
|
|
@@ -1802,6 +1762,50 @@ declare module "littlejsengine" {
|
|
|
1802
1762
|
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1803
1763
|
* @memberof Audio */
|
|
1804
1764
|
export function zzfx(...zzfxSound: any[]): AudioBufferSourceNode;
|
|
1765
|
+
/** Generate samples for a ZzFX sound
|
|
1766
|
+
* @param {number} [volume] - Volume scale (percent)
|
|
1767
|
+
* @param {number} [randomness] - How much to randomize frequency (percent Hz)
|
|
1768
|
+
* @param {number} [frequency] - Frequency of sound (Hz)
|
|
1769
|
+
* @param {number} [attack] - Attack time, how fast sound starts (seconds)
|
|
1770
|
+
* @param {number} [sustain] - Sustain time, how long sound holds (seconds)
|
|
1771
|
+
* @param {number} [release] - Release time, how fast sound fades out (seconds)
|
|
1772
|
+
* @param {number} [shape] - Shape of the sound wave
|
|
1773
|
+
* @param {number} [shapeCurve] - Squareness of wave (0=square, 1=normal, 2=pointy)
|
|
1774
|
+
* @param {number} [slide] - How much to slide frequency (kHz/s)
|
|
1775
|
+
* @param {number} [deltaSlide] - How much to change slide (kHz/s/s)
|
|
1776
|
+
* @param {number} [pitchJump] - Frequency of pitch jump (Hz)
|
|
1777
|
+
* @param {number} [pitchJumpTime] - Time of pitch jump (seconds)
|
|
1778
|
+
* @param {number} [repeatTime] - Resets some parameters periodically (seconds)
|
|
1779
|
+
* @param {number} [noise] - How much random noise to add (percent)
|
|
1780
|
+
* @param {number} [modulation] - Frequency of modulation wave, negative flips phase (Hz)
|
|
1781
|
+
* @param {number} [bitCrush] - Resamples at a lower frequency in (samples*100)
|
|
1782
|
+
* @param {number} [delay] - Overlap sound with itself for reverb and flanger effects (seconds)
|
|
1783
|
+
* @param {number} [sustainVolume] - Volume level for sustain (percent)
|
|
1784
|
+
* @param {number} [decay] - Decay time, how long to reach sustain after attack (seconds)
|
|
1785
|
+
* @param {number} [tremolo] - Trembling effect, rate controlled by repeat time (percent)
|
|
1786
|
+
* @param {number} [filter] - Filter cutoff frequency, positive for HPF, negative for LPF (Hz)
|
|
1787
|
+
* @return {Array} - Array of audio samples
|
|
1788
|
+
* @memberof Audio
|
|
1789
|
+
*/
|
|
1790
|
+
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[];
|
|
1791
|
+
/** Sample rate used for all ZzFX sounds
|
|
1792
|
+
* @default 44100
|
|
1793
|
+
* @memberof Audio */
|
|
1794
|
+
export const zzfxR: 44100;
|
|
1795
|
+
/**
|
|
1796
|
+
* LittleJS Audio System
|
|
1797
|
+
* - <a href=https://killedbyapixel.github.io/ZzFX/>ZzFX Sound Effects</a> - ZzFX Sound Effect Generator
|
|
1798
|
+
* - <a href=https://keithclark.github.io/ZzFXM/>ZzFXM Music</a> - ZzFXM Music System
|
|
1799
|
+
* - Caches sounds and music for fast playback
|
|
1800
|
+
* - Can attenuate and apply stereo panning to sounds
|
|
1801
|
+
* - Ability to play mp3, ogg, and wave files
|
|
1802
|
+
* - Speech synthesis functions
|
|
1803
|
+
* @namespace Audio
|
|
1804
|
+
*/
|
|
1805
|
+
/** Audio context used by the engine
|
|
1806
|
+
* @type {AudioContext}
|
|
1807
|
+
* @memberof Audio */
|
|
1808
|
+
export let audioContext: AudioContext;
|
|
1805
1809
|
/**
|
|
1806
1810
|
* LittleJS Object System
|
|
1807
1811
|
*/
|
|
@@ -1881,7 +1885,7 @@ declare module "littlejsengine" {
|
|
|
1881
1885
|
/** @property {boolean} - Limit object speed using linear or circular math */
|
|
1882
1886
|
clampSpeedLinear: boolean;
|
|
1883
1887
|
/** @property {EngineObject} - Object we are standing on, if any */
|
|
1884
|
-
groundObject:
|
|
1888
|
+
groundObject: any;
|
|
1885
1889
|
/** @property {EngineObject} - Parent of object if in local space */
|
|
1886
1890
|
parent: any;
|
|
1887
1891
|
/** @property {Vector2} - Local position if child */
|
|
@@ -2321,9 +2325,1235 @@ declare module "littlejsengine" {
|
|
|
2321
2325
|
render(hidePercent?: number): void;
|
|
2322
2326
|
/** Render the icon for a medal
|
|
2323
2327
|
* @param {Vector2} pos - Screen space position
|
|
2324
|
-
* @param {Number}
|
|
2328
|
+
* @param {Number} size - Screen space size
|
|
2325
2329
|
*/
|
|
2326
|
-
renderIcon(pos: Vector2, size
|
|
2330
|
+
renderIcon(pos: Vector2, size: number): void;
|
|
2327
2331
|
storageKey(): string;
|
|
2328
2332
|
}
|
|
2333
|
+
/** Global Newgrounds object
|
|
2334
|
+
* @type {NewgroundsPlugin}
|
|
2335
|
+
* @memberof Medal */
|
|
2336
|
+
export let newgrounds: NewgroundsPlugin;
|
|
2337
|
+
/**
|
|
2338
|
+
* Newgrounds API object
|
|
2339
|
+
*/
|
|
2340
|
+
export class NewgroundsPlugin {
|
|
2341
|
+
/** Create the global newgrounds object
|
|
2342
|
+
* @param {string} app_id - The newgrounds App ID
|
|
2343
|
+
* @param {string} [cipher] - The encryption Key (AES-128/Base64)
|
|
2344
|
+
* @param {Object} [cryptoJS] - An instance of CryptoJS, if there is a cipher
|
|
2345
|
+
* @example
|
|
2346
|
+
* // create the newgrounds object, replace the app id with your own
|
|
2347
|
+
* const app_id = 'your_app_id_here';
|
|
2348
|
+
* new NewgroundsPlugin(app_id);
|
|
2349
|
+
*/
|
|
2350
|
+
constructor(app_id: string, cipher?: string, cryptoJS?: any);
|
|
2351
|
+
app_id: string;
|
|
2352
|
+
cipher: string;
|
|
2353
|
+
cryptoJS: any;
|
|
2354
|
+
host: string;
|
|
2355
|
+
session_id: string;
|
|
2356
|
+
medals: any;
|
|
2357
|
+
scoreboards: any;
|
|
2358
|
+
/** Send message to unlock a medal by id
|
|
2359
|
+
* @param {number} id - The medal id */
|
|
2360
|
+
unlockMedal(id: number): any;
|
|
2361
|
+
/** Send message to post score
|
|
2362
|
+
* @param {number} id - The scoreboard id
|
|
2363
|
+
* @param {number} value - The score value */
|
|
2364
|
+
postScore(id: number, value: number): any;
|
|
2365
|
+
/** Get scores from a scoreboard
|
|
2366
|
+
* @param {number} id - The scoreboard id
|
|
2367
|
+
* @param {string} [user] - A user's id or name
|
|
2368
|
+
* @param {number} [social] - If true, only social scores will be loaded
|
|
2369
|
+
* @param {number} [skip] - Number of scores to skip before start
|
|
2370
|
+
* @param {number} [limit] - Number of scores to include in the list
|
|
2371
|
+
* @return {Object} - The response JSON object
|
|
2372
|
+
*/
|
|
2373
|
+
getScores(id: number, user?: string, social?: number, skip?: number, limit?: number): any;
|
|
2374
|
+
/** Send message to log a view */
|
|
2375
|
+
logView(): any;
|
|
2376
|
+
/** Send a message to call a component of the Newgrounds API
|
|
2377
|
+
* @param {string} component - Name of the component
|
|
2378
|
+
* @param {Object} [parameters] - Parameters to use for call
|
|
2379
|
+
* @param {boolean} [async] - If true, don't wait for response before continuing
|
|
2380
|
+
* @return {Object} - The response JSON object
|
|
2381
|
+
*/
|
|
2382
|
+
call(component: string, parameters?: any, async?: boolean): any;
|
|
2383
|
+
}
|
|
2384
|
+
/**
|
|
2385
|
+
* Newgrounds medal auto unlocks in newgrounds API
|
|
2386
|
+
* @extends Medal
|
|
2387
|
+
*/
|
|
2388
|
+
export class NewgroundsMedal extends Medal {
|
|
2389
|
+
}
|
|
2390
|
+
/** Global Post Process plugin object
|
|
2391
|
+
* @type {PostProcessPlugin} */
|
|
2392
|
+
export let postProcess: PostProcessPlugin;
|
|
2393
|
+
/**
|
|
2394
|
+
* UI System Global Object
|
|
2395
|
+
*/
|
|
2396
|
+
export class PostProcessPlugin {
|
|
2397
|
+
/** Create global post processing shader
|
|
2398
|
+
* @param {string} shaderCode
|
|
2399
|
+
* @param {boolean} [includeOverlay]
|
|
2400
|
+
* @example
|
|
2401
|
+
* // create the post process plugin object
|
|
2402
|
+
* new PostProcessPlugin(shaderCode);
|
|
2403
|
+
*/
|
|
2404
|
+
constructor(shaderCode: string, includeOverlay?: boolean);
|
|
2405
|
+
/** @property {WebGLProgram} - Shader for post processing */
|
|
2406
|
+
shader: WebGLProgram;
|
|
2407
|
+
/** @property {WebGLTexture} - Texture for post processing */
|
|
2408
|
+
texture: WebGLTexture;
|
|
2409
|
+
/** @property {boolean} - Should overlay canvas be included in post processing */
|
|
2410
|
+
includeOverlay: boolean;
|
|
2411
|
+
}
|
|
2412
|
+
/**
|
|
2413
|
+
* Music Object - Stores a zzfx music track for later use
|
|
2414
|
+
*
|
|
2415
|
+
* <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
|
|
2416
|
+
* @example
|
|
2417
|
+
* // create some music
|
|
2418
|
+
* const music_example = new Music(
|
|
2419
|
+
* [
|
|
2420
|
+
* [ // instruments
|
|
2421
|
+
* [,0,400] // simple note
|
|
2422
|
+
* ],
|
|
2423
|
+
* [ // patterns
|
|
2424
|
+
* [ // pattern 1
|
|
2425
|
+
* [ // channel 0
|
|
2426
|
+
* 0, -1, // instrument 0, left speaker
|
|
2427
|
+
* 1, 0, 9, 1 // channel notes
|
|
2428
|
+
* ],
|
|
2429
|
+
* [ // channel 1
|
|
2430
|
+
* 0, 1, // instrument 0, right speaker
|
|
2431
|
+
* 0, 12, 17, -1 // channel notes
|
|
2432
|
+
* ]
|
|
2433
|
+
* ],
|
|
2434
|
+
* ],
|
|
2435
|
+
* [0, 0, 0, 0], // sequence, play pattern 0 four times
|
|
2436
|
+
* 90 // BPM
|
|
2437
|
+
* ]);
|
|
2438
|
+
*
|
|
2439
|
+
* // play the music
|
|
2440
|
+
* music_example.play();
|
|
2441
|
+
*/
|
|
2442
|
+
export class ZzFXMusic extends Sound {
|
|
2443
|
+
/** Create a music object and cache the zzfx music samples for later use
|
|
2444
|
+
* @param {[Array, Array, Array, number]} zzfxMusic - Array of zzfx music parameters
|
|
2445
|
+
*/
|
|
2446
|
+
constructor(zzfxMusic: [any[], any[], any[], number]);
|
|
2447
|
+
sampleChannels: any[];
|
|
2448
|
+
/** Play the music
|
|
2449
|
+
* @param {number} [volume=1] - How much to scale volume by
|
|
2450
|
+
* @param {boolean} [loop] - True if the music should loop
|
|
2451
|
+
* @return {AudioBufferSourceNode} - The audio source node
|
|
2452
|
+
*/
|
|
2453
|
+
playMusic(volume?: number, loop?: boolean): AudioBufferSourceNode;
|
|
2454
|
+
}
|
|
2455
|
+
/** Global UI system plugin object
|
|
2456
|
+
* @type {UISystemPlugin} */
|
|
2457
|
+
export let uiSystem: UISystemPlugin;
|
|
2458
|
+
/**
|
|
2459
|
+
* UI System Global Object
|
|
2460
|
+
*/
|
|
2461
|
+
export class UISystemPlugin {
|
|
2462
|
+
/** Create the global UI system object
|
|
2463
|
+
* @param {CanvasRenderingContext2D} [context]
|
|
2464
|
+
* @example
|
|
2465
|
+
* // create the ui plugin object
|
|
2466
|
+
* new UISystemPlugin;
|
|
2467
|
+
*/
|
|
2468
|
+
constructor(context?: CanvasRenderingContext2D);
|
|
2469
|
+
/** @property {Color} - Default fill color for UI elements */
|
|
2470
|
+
defaultColor: Color;
|
|
2471
|
+
/** @property {Color} - Default outline color for UI elements */
|
|
2472
|
+
defaultLineColor: Color;
|
|
2473
|
+
/** @property {Color} - Default text color for UI elements */
|
|
2474
|
+
defaultTextColor: Color;
|
|
2475
|
+
/** @property {Color} - Default button color for UI elements */
|
|
2476
|
+
defaultButtonColor: Color;
|
|
2477
|
+
/** @property {Color} - Default hover color for UI elements */
|
|
2478
|
+
defaultHoverColor: Color;
|
|
2479
|
+
/** @property {number} - Default line width for UI elements */
|
|
2480
|
+
defaultLineWidth: number;
|
|
2481
|
+
/** @property {string} - Default font for UI elements */
|
|
2482
|
+
defaultFont: string;
|
|
2483
|
+
/** @property {Array<UIObject>} - List of all UI elements */
|
|
2484
|
+
uiObjects: any[];
|
|
2485
|
+
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
|
|
2486
|
+
uiContext: CanvasRenderingContext2D;
|
|
2487
|
+
/** Draw a rectangle to the UI context
|
|
2488
|
+
* @param {Vector2} pos
|
|
2489
|
+
* @param {Vector2} size
|
|
2490
|
+
* @param {Color} [color=uiSystem.defaultColor]
|
|
2491
|
+
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2492
|
+
* @param {Color} [lineColor=uiSystem.defaultLineColor] */
|
|
2493
|
+
drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color): void;
|
|
2494
|
+
/** Draw a line to the UI context
|
|
2495
|
+
* @param {Vector2} posA
|
|
2496
|
+
* @param {Vector2} posB
|
|
2497
|
+
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2498
|
+
* @param {Color} [lineColor=uiSystem.defaultLineColor] */
|
|
2499
|
+
drawLine(posA: Vector2, posB: Vector2, lineWidth?: number, lineColor?: Color): void;
|
|
2500
|
+
/** Draw a tile to the UI context
|
|
2501
|
+
* @param {Vector2} pos
|
|
2502
|
+
* @param {Vector2} size
|
|
2503
|
+
* @param {TileInfo} tileInfo
|
|
2504
|
+
* @param {Color} [color=uiSystem.defaultColor]
|
|
2505
|
+
* @param {number} [angle]
|
|
2506
|
+
* @param {boolean} [mirror] */
|
|
2507
|
+
drawTile(pos: Vector2, size: Vector2, tileInfo: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2508
|
+
/** Draw text to the UI context
|
|
2509
|
+
* @param {string} text
|
|
2510
|
+
* @param {Vector2} pos
|
|
2511
|
+
* @param {Vector2} size
|
|
2512
|
+
* @param {Color} [color=uiSystem.defaultColor]
|
|
2513
|
+
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2514
|
+
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2515
|
+
* @param {string} [align]
|
|
2516
|
+
* @param {string} [font=uiSystem.defaultFont] */
|
|
2517
|
+
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string): void;
|
|
2518
|
+
}
|
|
2519
|
+
/**
|
|
2520
|
+
* UI Object - Base level object for all UI elements
|
|
2521
|
+
*/
|
|
2522
|
+
export class UIObject {
|
|
2523
|
+
/** Create a UIObject
|
|
2524
|
+
* @param {Vector2} [pos=(0,0)]
|
|
2525
|
+
* @param {Vector2} [size=(1,1)]
|
|
2526
|
+
*/
|
|
2527
|
+
constructor(pos?: Vector2, size?: Vector2);
|
|
2528
|
+
/** @property {Vector2} - Local position of the object */
|
|
2529
|
+
localPos: Vector2;
|
|
2530
|
+
/** @property {Vector2} - Screen space position of the object */
|
|
2531
|
+
pos: Vector2;
|
|
2532
|
+
/** @property {Vector2} - Screen space size of the object */
|
|
2533
|
+
size: Vector2;
|
|
2534
|
+
/** @property {Color} */
|
|
2535
|
+
color: Color;
|
|
2536
|
+
/** @property {Color} */
|
|
2537
|
+
lineColor: Color;
|
|
2538
|
+
/** @property {Color} */
|
|
2539
|
+
textColor: Color;
|
|
2540
|
+
/** @property {Color} */
|
|
2541
|
+
hoverColor: Color;
|
|
2542
|
+
/** @property {number} */
|
|
2543
|
+
lineWidth: number;
|
|
2544
|
+
/** @property {string} */
|
|
2545
|
+
font: string;
|
|
2546
|
+
/** @property {boolean} */
|
|
2547
|
+
visible: boolean;
|
|
2548
|
+
/** @property {Array<UIObject>} */
|
|
2549
|
+
children: any[];
|
|
2550
|
+
/** @property {UIObject} */
|
|
2551
|
+
parent: any;
|
|
2552
|
+
/** Add a child UIObject to this object
|
|
2553
|
+
* @param {UIObject} child
|
|
2554
|
+
*/
|
|
2555
|
+
addChild(child: UIObject): void;
|
|
2556
|
+
/** Remove a child UIObject from this object
|
|
2557
|
+
* @param {UIObject} child
|
|
2558
|
+
*/
|
|
2559
|
+
removeChild(child: UIObject): void;
|
|
2560
|
+
/** Update the object, called automatically by plugin once each frame */
|
|
2561
|
+
update(): void;
|
|
2562
|
+
mouseIsOver: boolean;
|
|
2563
|
+
mouseIsHeld: boolean;
|
|
2564
|
+
/** Render the object, called automatically by plugin once each frame */
|
|
2565
|
+
render(): void;
|
|
2566
|
+
/** Called when the mouse enters the object */
|
|
2567
|
+
onEnter(): void;
|
|
2568
|
+
/** Called when the mouse leaves the object */
|
|
2569
|
+
onLeave(): void;
|
|
2570
|
+
/** Called when the mouse is pressed while over the object */
|
|
2571
|
+
onPress(): void;
|
|
2572
|
+
/** Called when the mouse is released while over the object */
|
|
2573
|
+
onRelease(): void;
|
|
2574
|
+
/** Called when the state of this object changes */
|
|
2575
|
+
onChange(): void;
|
|
2576
|
+
}
|
|
2577
|
+
/**
|
|
2578
|
+
* UIText - A UI object that displays text
|
|
2579
|
+
* @extends UIObject
|
|
2580
|
+
*/
|
|
2581
|
+
export class UIText extends UIObject {
|
|
2582
|
+
/** Create a UIText object
|
|
2583
|
+
* @param {Vector2} [pos]
|
|
2584
|
+
* @param {Vector2} [size]
|
|
2585
|
+
* @param {string} [text]
|
|
2586
|
+
* @param {string} [align]
|
|
2587
|
+
* @param {string} [font=uiSystem.defaultFont]
|
|
2588
|
+
*/
|
|
2589
|
+
constructor(pos?: Vector2, size?: Vector2, text?: string, align?: string, font?: string);
|
|
2590
|
+
/** @property {string} */
|
|
2591
|
+
text: string;
|
|
2592
|
+
/** @property {string} */
|
|
2593
|
+
align: string;
|
|
2594
|
+
}
|
|
2595
|
+
/**
|
|
2596
|
+
* UITile - A UI object that displays a tile image
|
|
2597
|
+
* @extends UIObject
|
|
2598
|
+
*/
|
|
2599
|
+
export class UITile extends UIObject {
|
|
2600
|
+
/** Create a UITile object
|
|
2601
|
+
* @param {Vector2} [pos]
|
|
2602
|
+
* @param {Vector2} [size]
|
|
2603
|
+
* @param {TileInfo} [tileInfo]
|
|
2604
|
+
* @param {Color} [color=WHITE]
|
|
2605
|
+
* @param {number} [angle]
|
|
2606
|
+
* @param {boolean} [mirror]
|
|
2607
|
+
*/
|
|
2608
|
+
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean);
|
|
2609
|
+
/** @property {TileInfo} - Tile image to use */
|
|
2610
|
+
tileInfo: TileInfo;
|
|
2611
|
+
/** @property {number} - Angle to rotate in radians */
|
|
2612
|
+
angle: number;
|
|
2613
|
+
/** @property {boolean} - Should it be mirrored? */
|
|
2614
|
+
mirror: boolean;
|
|
2615
|
+
}
|
|
2616
|
+
/**
|
|
2617
|
+
* UIButton - A UI object that acts as a button
|
|
2618
|
+
* @extends UIObject
|
|
2619
|
+
*/
|
|
2620
|
+
export class UIButton extends UIObject {
|
|
2621
|
+
/** Create a UIButton object
|
|
2622
|
+
* @param {Vector2} [pos]
|
|
2623
|
+
* @param {Vector2} [size]
|
|
2624
|
+
* @param {string} [text]
|
|
2625
|
+
* @param {Color} [color=uiSystem.defaultButtonColor]
|
|
2626
|
+
*/
|
|
2627
|
+
constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
|
|
2628
|
+
/** @property {string} */
|
|
2629
|
+
text: string;
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
* UICheckbox - A UI object that acts as a checkbox
|
|
2633
|
+
* @extends UIObject
|
|
2634
|
+
*/
|
|
2635
|
+
export class UICheckbox extends UIObject {
|
|
2636
|
+
/** Create a UICheckbox object
|
|
2637
|
+
* @param {Vector2} [pos]
|
|
2638
|
+
* @param {Vector2} [size]
|
|
2639
|
+
* @param {boolean} [checked]
|
|
2640
|
+
*/
|
|
2641
|
+
constructor(pos?: Vector2, size?: Vector2, checked?: boolean);
|
|
2642
|
+
/** @property {boolean} */
|
|
2643
|
+
checked: boolean;
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* UIScrollbar - A UI object that acts as a scrollbar
|
|
2647
|
+
* @extends UIObject
|
|
2648
|
+
*/
|
|
2649
|
+
export class UIScrollbar extends UIObject {
|
|
2650
|
+
/** Create a UIScrollbar object
|
|
2651
|
+
* @param {Vector2} [pos]
|
|
2652
|
+
* @param {Vector2} [size]
|
|
2653
|
+
* @param {number} [value]
|
|
2654
|
+
* @param {string} [text]
|
|
2655
|
+
* @param {Color} [color=uiSystem.defaultButtonColor]
|
|
2656
|
+
* @param {Color} [handleColor=WHITE]
|
|
2657
|
+
*/
|
|
2658
|
+
constructor(pos?: Vector2, size?: Vector2, value?: number, text?: string, color?: Color, handleColor?: Color);
|
|
2659
|
+
/** @property {number} */
|
|
2660
|
+
value: number;
|
|
2661
|
+
/** @property {string} */
|
|
2662
|
+
text: string;
|
|
2663
|
+
handleColor: Color;
|
|
2664
|
+
}
|
|
2665
|
+
/** Global Box2d Plugin object
|
|
2666
|
+
* @type {Box2dPlugin} */
|
|
2667
|
+
export let box2d: Box2dPlugin;
|
|
2668
|
+
/** Enable Box2D debug drawing
|
|
2669
|
+
* @type {boolean}
|
|
2670
|
+
* @default */
|
|
2671
|
+
export let box2dDebug: boolean;
|
|
2672
|
+
/** Box2d Init - Startup LittleJS engine with your callback functions
|
|
2673
|
+
* @param {Function|function():Promise} gameInit - Called once after the engine starts up
|
|
2674
|
+
* @param {Function} gameUpdate - Called every frame before objects are updated
|
|
2675
|
+
* @param {Function} gameUpdatePost - Called after physics and objects are updated, even when paused
|
|
2676
|
+
* @param {Function} gameRender - Called before objects are rendered, for drawing the background
|
|
2677
|
+
* @param {Function} gameRenderPost - Called after objects are rendered, useful for drawing UI
|
|
2678
|
+
* @param {Array<string>} [imageSources=[]] - List of images to load
|
|
2679
|
+
* @param {HTMLElement} [rootElement] - Root element to attach to, the document body by default */
|
|
2680
|
+
export function box2dEngineInit(gameInit: Function | (() => Promise<any>), gameUpdate: Function, gameUpdatePost: Function, gameRender: Function, gameRenderPost: Function, imageSources?: Array<string>, rootElement?: HTMLElement): void;
|
|
2681
|
+
/**
|
|
2682
|
+
* Box2D Global Object
|
|
2683
|
+
* - Wraps Box2d world and provides global functions
|
|
2684
|
+
*/
|
|
2685
|
+
export class Box2dPlugin {
|
|
2686
|
+
/** Create the global UI system object
|
|
2687
|
+
* @param {Object} instance */
|
|
2688
|
+
constructor(instance: any);
|
|
2689
|
+
instance: any;
|
|
2690
|
+
world: any;
|
|
2691
|
+
/** @property {number} - Velocity iterations per update*/
|
|
2692
|
+
velocityIterations: number;
|
|
2693
|
+
/** @property {number} - Position iterations per update*/
|
|
2694
|
+
positionIterations: number;
|
|
2695
|
+
/** @property {number} - Static, zero mass, zero velocity, may be manually moved */
|
|
2696
|
+
bodyTypeStatic: any;
|
|
2697
|
+
/** @property {number} - Kinematic, zero mass, non-zero velocity set by user, moved by solver */
|
|
2698
|
+
bodyTypeKinematic: any;
|
|
2699
|
+
/** @property {number} - Dynamic, positive mass, non-zero velocity determined by forces, moved by solver */
|
|
2700
|
+
bodyTypeDynamic: any;
|
|
2701
|
+
/** Step the physics world simulation
|
|
2702
|
+
* @param {number} [frames] */
|
|
2703
|
+
step(frames?: number): void;
|
|
2704
|
+
/** raycast and return a list of all the results
|
|
2705
|
+
* @param {Vector2} start
|
|
2706
|
+
* @param {Vector2} end */
|
|
2707
|
+
raycastAll(start: Vector2, end: Vector2): any[];
|
|
2708
|
+
/** raycast and return the first result
|
|
2709
|
+
* @param {Vector2} start
|
|
2710
|
+
* @param {Vector2} end */
|
|
2711
|
+
raycast(start: Vector2, end: Vector2): any;
|
|
2712
|
+
/** box aabb cast and return all the objects
|
|
2713
|
+
* @param {Vector2} pos
|
|
2714
|
+
* @param {Vector2} size */
|
|
2715
|
+
boxCastAll(pos: Vector2, size: Vector2): any[];
|
|
2716
|
+
/** box aabb cast and return the first object
|
|
2717
|
+
* @param {Vector2} pos
|
|
2718
|
+
* @param {Vector2} size */
|
|
2719
|
+
boxCast(pos: Vector2, size: Vector2): undefined;
|
|
2720
|
+
/** circle cast and return all the objects
|
|
2721
|
+
* @param {Vector2} pos
|
|
2722
|
+
* @param {number} diameter */
|
|
2723
|
+
circleCastAll(pos: Vector2, diameter: number): any[];
|
|
2724
|
+
/** circle cast and return the first object
|
|
2725
|
+
* @param {Vector2} pos
|
|
2726
|
+
* @param {number} diameter */
|
|
2727
|
+
circleCast(pos: Vector2, diameter: number): any;
|
|
2728
|
+
/** point cast and return the first object
|
|
2729
|
+
* @param {Vector2} pos
|
|
2730
|
+
* @param {boolean} dynamicOnly */
|
|
2731
|
+
pointCast(pos: Vector2, dynamicOnly?: boolean): undefined;
|
|
2732
|
+
/** draws a fixture
|
|
2733
|
+
* @param {Object} fixture
|
|
2734
|
+
* @param {Vector2} pos
|
|
2735
|
+
* @param {number} angle
|
|
2736
|
+
* @param {Color} [color]
|
|
2737
|
+
* @param {Color} [outlineColor]
|
|
2738
|
+
* @param {number} [lineWidth]
|
|
2739
|
+
* @param {CanvasRenderingContext2D} [context] */
|
|
2740
|
+
drawFixture(fixture: any, pos: Vector2, angle: number, color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2741
|
+
/** draws a circle
|
|
2742
|
+
* @param {Vector2} pos
|
|
2743
|
+
* @param {number} radius
|
|
2744
|
+
* @param {Color} [color]
|
|
2745
|
+
* @param {Color} [outlineColor]
|
|
2746
|
+
* @param {number} [lineWidth]
|
|
2747
|
+
* @param {CanvasRenderingContext2D} [context] */
|
|
2748
|
+
drawCircle(pos: Vector2, radius: number, color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2749
|
+
/** draws a polygon
|
|
2750
|
+
* @param {Vector2} pos
|
|
2751
|
+
* @param {number} angle
|
|
2752
|
+
* @param {Array<Vector2>} points
|
|
2753
|
+
* @param {Color} [color]
|
|
2754
|
+
* @param {Color} [outlineColor]
|
|
2755
|
+
* @param {number} [lineWidth]
|
|
2756
|
+
* @param {CanvasRenderingContext2D} [context] */
|
|
2757
|
+
drawPoly(pos: Vector2, angle: number, points: Array<Vector2>, color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2758
|
+
/** draws a line
|
|
2759
|
+
* @param {Vector2} pos
|
|
2760
|
+
* @param {number} angle
|
|
2761
|
+
* @param {Vector2} posA
|
|
2762
|
+
* @param {Vector2} posB
|
|
2763
|
+
* @param {Color} [color]
|
|
2764
|
+
* @param {number} [lineWidth]
|
|
2765
|
+
* @param {CanvasRenderingContext2D} [context] */
|
|
2766
|
+
drawLine(pos: Vector2, angle: number, posA: Vector2, posB: Vector2, color?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2767
|
+
/** performs a fill or stroke as a helper to the other draw functions
|
|
2768
|
+
* @param {Color} [color]
|
|
2769
|
+
* @param {Color} [outlineColor]
|
|
2770
|
+
* @param {number} [lineWidth]
|
|
2771
|
+
* @param {CanvasRenderingContext2D} [context] */
|
|
2772
|
+
drawFillStroke(color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2773
|
+
/** converts a box2d vec2 to a Vector2
|
|
2774
|
+
* @param {Object} v */
|
|
2775
|
+
vec2From(v: any): Vector2;
|
|
2776
|
+
/** converts a box2d vec2 pointer to a Vector2
|
|
2777
|
+
* @param {Object} v */
|
|
2778
|
+
vec2FromPointer(v: any): Vector2;
|
|
2779
|
+
/** converts a Vector2 to a box2 vec2
|
|
2780
|
+
* @param {Vector2} v */
|
|
2781
|
+
vec2dTo(v: Vector2): any;
|
|
2782
|
+
/** checks if a box2d object is null
|
|
2783
|
+
* @param {Object} o */
|
|
2784
|
+
isNull(o: any): boolean;
|
|
2785
|
+
/** casts a box2d object to its correct type
|
|
2786
|
+
* @param {Object} o */
|
|
2787
|
+
castObjectType(o: any): any;
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Box2D Object - extend with your own custom physics objects
|
|
2791
|
+
* - A LittleJS object with Box2D physics
|
|
2792
|
+
* - Each object has a Box2D body which can have multiple fixtures and joints
|
|
2793
|
+
* - Provides interface for Box2D body and fixture functions
|
|
2794
|
+
* @extends EngineObject
|
|
2795
|
+
*/
|
|
2796
|
+
export class Box2dObject extends EngineObject {
|
|
2797
|
+
/** Create a LittleJS object with Box2d physics
|
|
2798
|
+
* @param {Vector2} [pos]
|
|
2799
|
+
* @param {Vector2} [size]
|
|
2800
|
+
* @param {TileInfo} [tileInfo]
|
|
2801
|
+
* @param {number} [angle]
|
|
2802
|
+
* @param {Color} [color]
|
|
2803
|
+
* @param {number} [bodyType]
|
|
2804
|
+
* @param {number} [renderOrder] */
|
|
2805
|
+
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, bodyType?: number, renderOrder?: number);
|
|
2806
|
+
body: any;
|
|
2807
|
+
outlineColor: Color;
|
|
2808
|
+
/** Draws all this object's fixtures
|
|
2809
|
+
* @param {Color} [color]
|
|
2810
|
+
* @param {Color} [outlineColor]
|
|
2811
|
+
* @param {number} [lineWidth]
|
|
2812
|
+
* @param {CanvasRenderingContext2D} [context] */
|
|
2813
|
+
drawFixtures(color?: Color, outlineColor?: Color, lineWidth?: number, context?: CanvasRenderingContext2D): void;
|
|
2814
|
+
/** Called when a contact begins
|
|
2815
|
+
* @param {Box2dObject} otherObject */
|
|
2816
|
+
beginContact(otherObject: Box2dObject): void;
|
|
2817
|
+
/** Called when a contact ends
|
|
2818
|
+
* @param {Box2dObject} otherObject */
|
|
2819
|
+
endContact(otherObject: Box2dObject): void;
|
|
2820
|
+
/** Add a shape fixture to the body
|
|
2821
|
+
* @param {Object} shape
|
|
2822
|
+
* @param {number} [density]
|
|
2823
|
+
* @param {number} [friction]
|
|
2824
|
+
* @param {number} [restitution]
|
|
2825
|
+
* @param {boolean} [isSensor] */
|
|
2826
|
+
addShape(shape: any, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2827
|
+
/** Add a box shape to the body
|
|
2828
|
+
* @param {Vector2} [size]
|
|
2829
|
+
* @param {Vector2} [offset]
|
|
2830
|
+
* @param {number} [angle]
|
|
2831
|
+
* @param {number} [density]
|
|
2832
|
+
* @param {number} [friction]
|
|
2833
|
+
* @param {number} [restitution]
|
|
2834
|
+
* @param {boolean} [isSensor] */
|
|
2835
|
+
addBox(size?: Vector2, offset?: Vector2, angle?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2836
|
+
/** Add a polygon shape to the body
|
|
2837
|
+
* @param {Array<Vector2>} points
|
|
2838
|
+
* @param {number} [density]
|
|
2839
|
+
* @param {number} [friction]
|
|
2840
|
+
* @param {number} [restitution]
|
|
2841
|
+
* @param {boolean} [isSensor] */
|
|
2842
|
+
addPoly(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2843
|
+
/** Add a regular polygon shape to the body
|
|
2844
|
+
* @param {number} [diameter]
|
|
2845
|
+
* @param {number} [sides]
|
|
2846
|
+
* @param {number} [density]
|
|
2847
|
+
* @param {number} [friction]
|
|
2848
|
+
* @param {number} [restitution]
|
|
2849
|
+
* @param {boolean} [isSensor] */
|
|
2850
|
+
addRegularPoly(diameter?: number, sides?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2851
|
+
/** Add a random polygon shape to the body
|
|
2852
|
+
* @param {number} [diameter]
|
|
2853
|
+
* @param {number} [density]
|
|
2854
|
+
* @param {number} [friction]
|
|
2855
|
+
* @param {number} [restitution]
|
|
2856
|
+
* @param {boolean} [isSensor] */
|
|
2857
|
+
addRandomPoly(diameter?: number, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2858
|
+
/** Add a circle shape to the body
|
|
2859
|
+
* @param {number} [diameter]
|
|
2860
|
+
* @param {Vector2} [offset]
|
|
2861
|
+
* @param {number} [density]
|
|
2862
|
+
* @param {number} [friction]
|
|
2863
|
+
* @param {number} [restitution]
|
|
2864
|
+
* @param {boolean} [isSensor] */
|
|
2865
|
+
addCircle(diameter?: number, offset?: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2866
|
+
/** Add an edge shape to the body
|
|
2867
|
+
* @param {Vector2} point1
|
|
2868
|
+
* @param {Vector2} point2
|
|
2869
|
+
* @param {number} [density]
|
|
2870
|
+
* @param {number} [friction]
|
|
2871
|
+
* @param {number} [restitution]
|
|
2872
|
+
* @param {boolean} [isSensor] */
|
|
2873
|
+
addEdge(point1: Vector2, point2: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
2874
|
+
/** Add an edge loop to the body, an edge loop connects the end points
|
|
2875
|
+
* @param {Array<Vector2>} points
|
|
2876
|
+
* @param {number} [density]
|
|
2877
|
+
* @param {number} [friction]
|
|
2878
|
+
* @param {number} [restitution]
|
|
2879
|
+
* @param {boolean} [isSensor] */
|
|
2880
|
+
addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
|
|
2881
|
+
/** Add an edge list to the body
|
|
2882
|
+
* @param {Array<Vector2>} points
|
|
2883
|
+
* @param {number} [density]
|
|
2884
|
+
* @param {number} [friction]
|
|
2885
|
+
* @param {number} [restitution]
|
|
2886
|
+
* @param {boolean} [isSensor] */
|
|
2887
|
+
addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
|
|
2888
|
+
/** Gets the center of mass
|
|
2889
|
+
* @return {Vector2} */
|
|
2890
|
+
getCenterOfMass(): Vector2;
|
|
2891
|
+
/** Gets the linear velocity
|
|
2892
|
+
* @return {Vector2} */
|
|
2893
|
+
getLinearVelocity(): Vector2;
|
|
2894
|
+
/** Gets the angular velocity
|
|
2895
|
+
* @return {Vector2} */
|
|
2896
|
+
getAngularVelocity(): Vector2;
|
|
2897
|
+
/** Gets the mass
|
|
2898
|
+
* @return {number} */
|
|
2899
|
+
getMass(): number;
|
|
2900
|
+
/** Gets the rotational inertia
|
|
2901
|
+
* @return {number} */
|
|
2902
|
+
getInertia(): number;
|
|
2903
|
+
/** Check if this object is awake
|
|
2904
|
+
* @return {boolean} */
|
|
2905
|
+
getIsAwake(): boolean;
|
|
2906
|
+
/** Gets the physics body type
|
|
2907
|
+
* @return {number} */
|
|
2908
|
+
getBodyType(): number;
|
|
2909
|
+
/** Sets the position and angle
|
|
2910
|
+
* @param {Vector2} pos
|
|
2911
|
+
* @param {number} angle */
|
|
2912
|
+
setTransform(pos: Vector2, angle: number): void;
|
|
2913
|
+
/** Sets the position
|
|
2914
|
+
* @param {Vector2} pos */
|
|
2915
|
+
setPosition(pos: Vector2): void;
|
|
2916
|
+
/** Sets the angle
|
|
2917
|
+
* @param {number} angle */
|
|
2918
|
+
setAngle(angle: number): void;
|
|
2919
|
+
/** Sets the linear velocity
|
|
2920
|
+
* @param {Vector2} velocity */
|
|
2921
|
+
setLinearVelocity(velocity: Vector2): void;
|
|
2922
|
+
/** Sets the angular velocity
|
|
2923
|
+
* @param {number} angularVelocity */
|
|
2924
|
+
setAngularVelocity(angularVelocity: number): void;
|
|
2925
|
+
/** Sets the linear damping
|
|
2926
|
+
* @param {number} damping */
|
|
2927
|
+
setLinearDamping(damping: number): void;
|
|
2928
|
+
/** Sets the angular damping
|
|
2929
|
+
* @param {number} damping */
|
|
2930
|
+
setAngularDamping(damping: number): void;
|
|
2931
|
+
/** Sets the gravity scale
|
|
2932
|
+
* @param {number} [scale] */
|
|
2933
|
+
setGravityScale(scale?: number): void;
|
|
2934
|
+
/** Should this body be treated like a bullet for continuous collision detection?
|
|
2935
|
+
* @param {boolean} [isBullet] */
|
|
2936
|
+
setBullet(isBullet?: boolean): void;
|
|
2937
|
+
/** Set the sleep state of the body
|
|
2938
|
+
* @param {boolean} [isAwake] */
|
|
2939
|
+
setAwake(isAwake?: boolean): void;
|
|
2940
|
+
/** Set the physics body type
|
|
2941
|
+
* @param {number} type */
|
|
2942
|
+
setBodyType(type: number): void;
|
|
2943
|
+
/** Set whether the body is allowed to sleep
|
|
2944
|
+
* @param {boolean} [isAllowed] */
|
|
2945
|
+
setSleepingAllowed(isAllowed?: boolean): void;
|
|
2946
|
+
/** Set whether the body can rotate
|
|
2947
|
+
* @param {boolean} [isFixed] */
|
|
2948
|
+
setFixedRotation(isFixed?: boolean): void;
|
|
2949
|
+
/** Set the center of mass of the body
|
|
2950
|
+
* @param {Vector2} center */
|
|
2951
|
+
setCenterOfMass(center: Vector2): void;
|
|
2952
|
+
/** Set the mass of the body
|
|
2953
|
+
* @param {number} mass */
|
|
2954
|
+
setMass(mass: number): void;
|
|
2955
|
+
/** Set the moment of inertia of the body
|
|
2956
|
+
* @param {number} momentOfInertia */
|
|
2957
|
+
setMomentOfInertia(momentOfInertia: number): void;
|
|
2958
|
+
/** Reset the mass, center of mass, and moment */
|
|
2959
|
+
resetMassData(): void;
|
|
2960
|
+
/** Set the mass data of the body
|
|
2961
|
+
* @param {Vector2} [localCenter]
|
|
2962
|
+
* @param {number} [mass]
|
|
2963
|
+
* @param {number} [momentOfInertia] */
|
|
2964
|
+
setMassData(localCenter?: Vector2, mass?: number, momentOfInertia?: number): void;
|
|
2965
|
+
/** Set the collision filter data for this body
|
|
2966
|
+
* @param {number} [categoryBits]
|
|
2967
|
+
* @param {number} [ignoreCategoryBits]
|
|
2968
|
+
* @param {number} [groupIndex] */
|
|
2969
|
+
setFilterData(categoryBits?: number, ignoreCategoryBits?: number, groupIndex?: number): void;
|
|
2970
|
+
/** Set if this body is a sensor
|
|
2971
|
+
* @param {boolean} [isSensor] */
|
|
2972
|
+
setSensor(isSensor?: boolean): void;
|
|
2973
|
+
/** Apply force to this object
|
|
2974
|
+
* @param {Vector2} force
|
|
2975
|
+
* @param {Vector2} [pos] */
|
|
2976
|
+
applyForce(force: Vector2, pos?: Vector2): void;
|
|
2977
|
+
/** Apply acceleration to this object
|
|
2978
|
+
* @param {Vector2} acceleration
|
|
2979
|
+
* @param {Vector2} [pos] */
|
|
2980
|
+
applyAcceleration(acceleration: Vector2, pos?: Vector2): void;
|
|
2981
|
+
/** Apply torque to this object
|
|
2982
|
+
* @param {number} torque */
|
|
2983
|
+
applyTorque(torque: number): void;
|
|
2984
|
+
/** Apply angular acceleration to this object
|
|
2985
|
+
* @param {number} acceleration */
|
|
2986
|
+
applyAngularAcceleration(acceleration: number): void;
|
|
2987
|
+
/** Check if this object has any fixtures
|
|
2988
|
+
* @return {boolean} */
|
|
2989
|
+
hasFixtures(): boolean;
|
|
2990
|
+
/** Get list of fixtures for this object
|
|
2991
|
+
* @return {Array<Object>} */
|
|
2992
|
+
getFixtureList(): Array<any>;
|
|
2993
|
+
/** Check if this object has any joints
|
|
2994
|
+
* @return {boolean} */
|
|
2995
|
+
hasJoints(): boolean;
|
|
2996
|
+
/** Get list of joints for this object
|
|
2997
|
+
* @return {Array<Object>} */
|
|
2998
|
+
getJointList(): Array<any>;
|
|
2999
|
+
}
|
|
3000
|
+
/**
|
|
3001
|
+
* Box2D Raycast Result
|
|
3002
|
+
* - Holds results from a box2d raycast queries
|
|
3003
|
+
* - Automatically created by box2d raycast functions
|
|
3004
|
+
*/
|
|
3005
|
+
export class Box2dRaycastResult {
|
|
3006
|
+
/** Create a raycast result
|
|
3007
|
+
* @param {Object} fixture
|
|
3008
|
+
* @param {Vector2} point
|
|
3009
|
+
* @param {Vector2} normal
|
|
3010
|
+
* @param {number} fraction */
|
|
3011
|
+
constructor(fixture: any, point: Vector2, normal: Vector2, fraction: number);
|
|
3012
|
+
/** @property {Box2dObject} - The box2d object */
|
|
3013
|
+
object: any;
|
|
3014
|
+
/** @property {Object} - The fixture that was hit */
|
|
3015
|
+
fixture: any;
|
|
3016
|
+
/** @property {Vector2} - The hit point */
|
|
3017
|
+
point: Vector2;
|
|
3018
|
+
/** @property {Vector2} - The hit normal */
|
|
3019
|
+
normal: Vector2;
|
|
3020
|
+
/** @property {number} - Distance fraction at the point of intersection */
|
|
3021
|
+
fraction: number;
|
|
3022
|
+
}
|
|
3023
|
+
/**
|
|
3024
|
+
* Box2D Joint
|
|
3025
|
+
* - Base class for Box2D joints
|
|
3026
|
+
* - A joint is used to connect objects together
|
|
3027
|
+
*/
|
|
3028
|
+
export class Box2dJoint {
|
|
3029
|
+
/** Create a box2d joint, the base class is not intended to be used directly
|
|
3030
|
+
* @param {Object} jointDef */
|
|
3031
|
+
constructor(jointDef: any);
|
|
3032
|
+
box2dJoint: any;
|
|
3033
|
+
/** Destroy this joint */
|
|
3034
|
+
destroy(): void;
|
|
3035
|
+
/** Get the first object attached to this joint
|
|
3036
|
+
* @return {Box2dObject} */
|
|
3037
|
+
getObjectA(): Box2dObject;
|
|
3038
|
+
/** Get the second object attached to this joint
|
|
3039
|
+
* @return {Box2dObject} */
|
|
3040
|
+
getObjectB(): Box2dObject;
|
|
3041
|
+
/** Get the first anchor for this joint in world coordinates
|
|
3042
|
+
* @return {Vector2} */
|
|
3043
|
+
getAnchorA(): Vector2;
|
|
3044
|
+
/** Get the second anchor for this joint in world coordinates
|
|
3045
|
+
* @return {Vector2} */
|
|
3046
|
+
getAnchorB(): Vector2;
|
|
3047
|
+
/** Get the reaction force on bodyB at the joint anchor given a time step
|
|
3048
|
+
* @param {number} time
|
|
3049
|
+
* @return {Vector2} */
|
|
3050
|
+
getReactionForce(time: number): Vector2;
|
|
3051
|
+
/** Get the reaction torque on bodyB in N*m given a time step
|
|
3052
|
+
* @param {number} time
|
|
3053
|
+
* @return {number} */
|
|
3054
|
+
getReactionTorque(time: number): number;
|
|
3055
|
+
/** Check if the connected bodies should collide
|
|
3056
|
+
* @return {boolean} */
|
|
3057
|
+
getCollideConnected(): boolean;
|
|
3058
|
+
/** Check if either connected body is active
|
|
3059
|
+
* @return {boolean} */
|
|
3060
|
+
isActive(): boolean;
|
|
3061
|
+
}
|
|
3062
|
+
/**
|
|
3063
|
+
* Box2D Target Joint, also known as a mouse joint
|
|
3064
|
+
* - Used to make a point on a object track a specific world point target
|
|
3065
|
+
* - This a soft constraint with a max force
|
|
3066
|
+
* - This allows the constraint to stretch and without applying huge forces
|
|
3067
|
+
* @extends Box2dJoint
|
|
3068
|
+
*/
|
|
3069
|
+
export class Box2dTargetJoint extends Box2dJoint {
|
|
3070
|
+
/** Create a target joint
|
|
3071
|
+
* @param {Box2dObject} object
|
|
3072
|
+
* @param {Box2dObject} fixedObject
|
|
3073
|
+
* @param {Vector2} worldPos */
|
|
3074
|
+
constructor(object: Box2dObject, fixedObject: Box2dObject, worldPos: Vector2);
|
|
3075
|
+
/** Set the target point in world coordinates
|
|
3076
|
+
* @param {Vector2} pos */
|
|
3077
|
+
setTarget(pos: Vector2): void;
|
|
3078
|
+
/** Get the target point in world coordinates
|
|
3079
|
+
* @return {Vector2} */
|
|
3080
|
+
getTarget(): Vector2;
|
|
3081
|
+
/** Sets the maximum force in Newtons
|
|
3082
|
+
* @param {number} force */
|
|
3083
|
+
setMaxForce(force: number): void;
|
|
3084
|
+
/** Gets the maximum force in Newtons
|
|
3085
|
+
* @return {number} */
|
|
3086
|
+
getMaxForce(): number;
|
|
3087
|
+
/** Sets the joint frequency in Hertz
|
|
3088
|
+
* @param {number} hz */
|
|
3089
|
+
setFrequency(hz: number): void;
|
|
3090
|
+
/** Gets the joint frequency in Hertz
|
|
3091
|
+
* @return {number} */
|
|
3092
|
+
getFrequency(): number;
|
|
3093
|
+
}
|
|
3094
|
+
/**
|
|
3095
|
+
* Box2D Distance Joint
|
|
3096
|
+
* - Constrains two points on two objects to remain at a fixed distance
|
|
3097
|
+
* - You can view this as a massless, rigid rod
|
|
3098
|
+
* @extends Box2dJoint
|
|
3099
|
+
*/
|
|
3100
|
+
export class Box2dDistanceJoint extends Box2dJoint {
|
|
3101
|
+
/** Create a distance joint
|
|
3102
|
+
* @param {Box2dObject} objectA
|
|
3103
|
+
* @param {Box2dObject} objectB
|
|
3104
|
+
* @param {Vector2} anchorA
|
|
3105
|
+
* @param {Vector2} anchorB
|
|
3106
|
+
* @param {boolean} [collide] */
|
|
3107
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchorA: Vector2, anchorB: Vector2, collide?: boolean);
|
|
3108
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3109
|
+
* @return {Vector2} */
|
|
3110
|
+
getLocalAnchorA(): Vector2;
|
|
3111
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3112
|
+
* @return {Vector2} */
|
|
3113
|
+
getLocalAnchorB(): Vector2;
|
|
3114
|
+
/** Set the length of the joint
|
|
3115
|
+
* @param {number} length */
|
|
3116
|
+
setLength(length: number): void;
|
|
3117
|
+
/** Get the length of the joint
|
|
3118
|
+
* @return {number} */
|
|
3119
|
+
getLength(): number;
|
|
3120
|
+
/** Set the frequency in Hertz
|
|
3121
|
+
* @param {number} hz */
|
|
3122
|
+
setFrequency(hz: number): void;
|
|
3123
|
+
/** Get the frequency in Hertz
|
|
3124
|
+
* @return {number} */
|
|
3125
|
+
getFrequency(): number;
|
|
3126
|
+
/** Set the damping ratio
|
|
3127
|
+
* @param {number} ratio */
|
|
3128
|
+
setDampingRatio(ratio: number): void;
|
|
3129
|
+
/** Get the damping ratio
|
|
3130
|
+
* @return {number} */
|
|
3131
|
+
getDampingRatio(): number;
|
|
3132
|
+
}
|
|
3133
|
+
/**
|
|
3134
|
+
* Box2D Pin Joint
|
|
3135
|
+
* - Pins two objects together at a point
|
|
3136
|
+
* @extends Box2dDistanceJoint
|
|
3137
|
+
*/
|
|
3138
|
+
export class Box2dPinJoint extends Box2dDistanceJoint {
|
|
3139
|
+
/** Create a pin joint
|
|
3140
|
+
* @param {Box2dObject} objectA
|
|
3141
|
+
* @param {Box2dObject} objectB
|
|
3142
|
+
* @param {Vector2} [pos]
|
|
3143
|
+
* @param {boolean} [collide] */
|
|
3144
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, pos?: Vector2, collide?: boolean);
|
|
3145
|
+
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Box2D Rope Joint
|
|
3148
|
+
* - Enforces a maximum distance between two points on two objects
|
|
3149
|
+
* @extends Box2dJoint
|
|
3150
|
+
*/
|
|
3151
|
+
export class Box2dRopeJoint extends Box2dJoint {
|
|
3152
|
+
/** Create a rope joint
|
|
3153
|
+
* @param {Box2dObject} objectA
|
|
3154
|
+
* @param {Box2dObject} objectB
|
|
3155
|
+
* @param {Vector2} anchorA
|
|
3156
|
+
* @param {Vector2} anchorB
|
|
3157
|
+
* @param {number} extraLength
|
|
3158
|
+
* @param {boolean} [collide] */
|
|
3159
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchorA: Vector2, anchorB: Vector2, extraLength?: number, collide?: boolean);
|
|
3160
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3161
|
+
* @return {Vector2} */
|
|
3162
|
+
getLocalAnchorA(): Vector2;
|
|
3163
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3164
|
+
* @return {Vector2} */
|
|
3165
|
+
getLocalAnchorB(): Vector2;
|
|
3166
|
+
/** Set the max length of the joint
|
|
3167
|
+
* @param {number} length */
|
|
3168
|
+
setMaxLength(length: number): void;
|
|
3169
|
+
/** Get the max length of the joint
|
|
3170
|
+
* @return {number} */
|
|
3171
|
+
getMaxLength(): number;
|
|
3172
|
+
}
|
|
3173
|
+
/**
|
|
3174
|
+
* Box2D Revolute Joint
|
|
3175
|
+
* - Constrains two objects to share a point while they are free to rotate around the point
|
|
3176
|
+
* - The relative rotation about the shared point is the joint angle
|
|
3177
|
+
* - You can limit the relative rotation with a joint limit
|
|
3178
|
+
* - You can use a motor to drive the relative rotation about the shared point
|
|
3179
|
+
* - A maximum motor torque is provided so that infinite forces are not generated
|
|
3180
|
+
* @extends Box2dJoint
|
|
3181
|
+
*/
|
|
3182
|
+
export class Box2dRevoluteJoint extends Box2dJoint {
|
|
3183
|
+
/** Create a revolute joint
|
|
3184
|
+
* @param {Box2dObject} objectA
|
|
3185
|
+
* @param {Box2dObject} objectB
|
|
3186
|
+
* @param {Vector2} anchor
|
|
3187
|
+
* @param {boolean} [collide] */
|
|
3188
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchor: Vector2, collide?: boolean);
|
|
3189
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3190
|
+
* @return {Vector2} */
|
|
3191
|
+
getLocalAnchorA(): Vector2;
|
|
3192
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3193
|
+
* @return {Vector2} */
|
|
3194
|
+
getLocalAnchorB(): Vector2;
|
|
3195
|
+
/** Get the reference angle, objectB angle minus objectA angle in the reference state
|
|
3196
|
+
* @return {number} */
|
|
3197
|
+
getReferenceAngle(): number;
|
|
3198
|
+
/** Get the current joint angle
|
|
3199
|
+
* @return {number} */
|
|
3200
|
+
getJointAngle(): number;
|
|
3201
|
+
/** Get the current joint angle speed in radians per second
|
|
3202
|
+
* @return {number} */
|
|
3203
|
+
getJointSpeed(): number;
|
|
3204
|
+
/** Is the joint limit enabled?
|
|
3205
|
+
* @return {boolean} */
|
|
3206
|
+
isLimitEnabled(): boolean;
|
|
3207
|
+
/** Enable/disable the joint limit
|
|
3208
|
+
* @param {boolean} [enable] */
|
|
3209
|
+
enableLimit(enable?: boolean): any;
|
|
3210
|
+
/** Get the lower joint limit
|
|
3211
|
+
* @return {number} */
|
|
3212
|
+
getLowerLimit(): number;
|
|
3213
|
+
/** Get the upper joint limit
|
|
3214
|
+
* @return {number} */
|
|
3215
|
+
getUpperLimit(): number;
|
|
3216
|
+
/** Set the joint limits
|
|
3217
|
+
* @param {number} min
|
|
3218
|
+
* @param {number} max */
|
|
3219
|
+
setLimits(min: number, max: number): any;
|
|
3220
|
+
/** Is the joint motor enabled?
|
|
3221
|
+
* @return {boolean} */
|
|
3222
|
+
isMotorEnabled(): boolean;
|
|
3223
|
+
/** Enable/disable the joint motor
|
|
3224
|
+
* @param {boolean} [enable] */
|
|
3225
|
+
enableMotor(enable?: boolean): any;
|
|
3226
|
+
/** Set the motor speed
|
|
3227
|
+
* @param {number} speed */
|
|
3228
|
+
setMotorSpeed(speed: number): any;
|
|
3229
|
+
/** Get the motor speed
|
|
3230
|
+
* @return {number} */
|
|
3231
|
+
getMotorSpeed(): number;
|
|
3232
|
+
/** Set the motor torque
|
|
3233
|
+
* @param {number} torque */
|
|
3234
|
+
setMaxMotorTorque(torque: number): any;
|
|
3235
|
+
/** Get the max motor torque
|
|
3236
|
+
* @return {number} */
|
|
3237
|
+
getMaxMotorTorque(): number;
|
|
3238
|
+
/** Get the motor torque given a time step
|
|
3239
|
+
* @param {number} time
|
|
3240
|
+
* @return {number} */
|
|
3241
|
+
getMotorTorque(time: number): number;
|
|
3242
|
+
}
|
|
3243
|
+
/**
|
|
3244
|
+
* Box2D Gear Joint
|
|
3245
|
+
* - A gear joint is used to connect two joints together
|
|
3246
|
+
* - Either joint can be a revolute or prismatic joint
|
|
3247
|
+
* - You specify a gear ratio to bind the motions together
|
|
3248
|
+
* @extends Box2dJoint
|
|
3249
|
+
*/
|
|
3250
|
+
export class Box2dGearJoint extends Box2dJoint {
|
|
3251
|
+
/** Create a gear joint
|
|
3252
|
+
* @param {Box2dObject} objectA
|
|
3253
|
+
* @param {Box2dObject} objectB
|
|
3254
|
+
* @param {Box2dJoint} joint1
|
|
3255
|
+
* @param {Box2dJoint} joint2
|
|
3256
|
+
* @param {ratio} [ratio] */
|
|
3257
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, joint1: Box2dJoint, joint2: Box2dJoint, ratio?: ratio);
|
|
3258
|
+
joint1: Box2dJoint;
|
|
3259
|
+
joint2: Box2dJoint;
|
|
3260
|
+
/** Get the first joint
|
|
3261
|
+
* @return {Box2dJoint} */
|
|
3262
|
+
getJoint1(): Box2dJoint;
|
|
3263
|
+
/** Get the second joint
|
|
3264
|
+
* @return {Box2dJoint} */
|
|
3265
|
+
getJoint2(): Box2dJoint;
|
|
3266
|
+
/** Set the gear ratio
|
|
3267
|
+
* @param {number} ratio */
|
|
3268
|
+
setRatio(ratio: number): any;
|
|
3269
|
+
/** Get the gear ratio
|
|
3270
|
+
* @return {number} */
|
|
3271
|
+
getRatio(): number;
|
|
3272
|
+
}
|
|
3273
|
+
/**
|
|
3274
|
+
* Box2D Prismatic Joint
|
|
3275
|
+
* - Provides one degree of freedom: translation along an axis fixed in objectA
|
|
3276
|
+
* - Relative rotation is prevented
|
|
3277
|
+
* - You can use a joint limit to restrict the range of motion
|
|
3278
|
+
* - You can use a joint motor to drive the motion or to model joint friction
|
|
3279
|
+
* @extends Box2dJoint
|
|
3280
|
+
*/
|
|
3281
|
+
export class Box2dPrismaticJoint extends Box2dJoint {
|
|
3282
|
+
/** Create a prismatic joint
|
|
3283
|
+
* @param {Box2dObject} objectA
|
|
3284
|
+
* @param {Box2dObject} objectB
|
|
3285
|
+
* @param {Vector2} anchor
|
|
3286
|
+
* @param {Vector2} worldAxis
|
|
3287
|
+
* @param {boolean} [collide] */
|
|
3288
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchor: Vector2, worldAxis?: Vector2, collide?: boolean);
|
|
3289
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3290
|
+
* @return {Vector2} */
|
|
3291
|
+
getLocalAnchorA(): Vector2;
|
|
3292
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3293
|
+
* @return {Vector2} */
|
|
3294
|
+
getLocalAnchorB(): Vector2;
|
|
3295
|
+
/** Get the local joint axis relative to bodyA
|
|
3296
|
+
* @return {Vector2} */
|
|
3297
|
+
getLocalAxisA(): Vector2;
|
|
3298
|
+
/** Get the reference angle
|
|
3299
|
+
* @return {number} */
|
|
3300
|
+
getReferenceAngle(): number;
|
|
3301
|
+
/** Get the current joint translation
|
|
3302
|
+
* @return {number} */
|
|
3303
|
+
getJointTranslation(): number;
|
|
3304
|
+
/** Get the current joint translation speed
|
|
3305
|
+
* @return {number} */
|
|
3306
|
+
getJointSpeed(): number;
|
|
3307
|
+
/** Is the joint limit enabled?
|
|
3308
|
+
* @return {boolean} */
|
|
3309
|
+
isLimitEnabled(): boolean;
|
|
3310
|
+
/** Enable/disable the joint limit
|
|
3311
|
+
* @param {boolean} [enable] */
|
|
3312
|
+
enableLimit(enable?: boolean): any;
|
|
3313
|
+
/** Get the lower joint limit
|
|
3314
|
+
* @return {number} */
|
|
3315
|
+
getLowerLimit(): number;
|
|
3316
|
+
/** Get the upper joint limit
|
|
3317
|
+
* @return {number} */
|
|
3318
|
+
getUpperLimit(): number;
|
|
3319
|
+
/** Set the joint limits
|
|
3320
|
+
* @param {number} min
|
|
3321
|
+
* @param {number} max */
|
|
3322
|
+
setLimits(min: number, max: number): any;
|
|
3323
|
+
/** Is the motor enabled?
|
|
3324
|
+
* @return {boolean} */
|
|
3325
|
+
isMotorEnabled(): boolean;
|
|
3326
|
+
/** Enable/disable the joint motor
|
|
3327
|
+
* @param {boolean} [enable] */
|
|
3328
|
+
enableMotor(enable?: boolean): any;
|
|
3329
|
+
/** Set the motor speed
|
|
3330
|
+
* @param {number} speed */
|
|
3331
|
+
setMotorSpeed(speed: number): any;
|
|
3332
|
+
/** Get the motor speed
|
|
3333
|
+
* @return {number} */
|
|
3334
|
+
getMotorSpeed(): number;
|
|
3335
|
+
/** Set the maximum motor force
|
|
3336
|
+
* @param {number} force */
|
|
3337
|
+
setMaxMotorForce(force: number): any;
|
|
3338
|
+
/** Get the maximum motor force
|
|
3339
|
+
* @return {number} */
|
|
3340
|
+
getMaxMotorForce(): number;
|
|
3341
|
+
/** Get the motor force given a time step
|
|
3342
|
+
* @param {number} time
|
|
3343
|
+
* @return {number} */
|
|
3344
|
+
getMotorForce(time: number): number;
|
|
3345
|
+
}
|
|
3346
|
+
/**
|
|
3347
|
+
* Box2D Wheel Joint
|
|
3348
|
+
* - Provides two degrees of freedom: translation along an axis fixed in objectA and rotation
|
|
3349
|
+
* - You can use a joint limit to restrict the range of motion
|
|
3350
|
+
* - You can use a joint motor to drive the motion or to model joint friction
|
|
3351
|
+
* - This joint is designed for vehicle suspensions
|
|
3352
|
+
* @extends Box2dJoint
|
|
3353
|
+
*/
|
|
3354
|
+
export class Box2dWheelJoint extends Box2dJoint {
|
|
3355
|
+
/** Create a wheel joint
|
|
3356
|
+
* @param {Box2dObject} objectA
|
|
3357
|
+
* @param {Box2dObject} objectB
|
|
3358
|
+
* @param {Vector2} anchor
|
|
3359
|
+
* @param {Vector2} worldAxis
|
|
3360
|
+
* @param {boolean} [collide] */
|
|
3361
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchor: Vector2, worldAxis?: Vector2, collide?: boolean);
|
|
3362
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3363
|
+
* @return {Vector2} */
|
|
3364
|
+
getLocalAnchorA(): Vector2;
|
|
3365
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3366
|
+
* @return {Vector2} */
|
|
3367
|
+
getLocalAnchorB(): Vector2;
|
|
3368
|
+
/** Get the local joint axis relative to bodyA
|
|
3369
|
+
* @return {Vector2} */
|
|
3370
|
+
getLocalAxisA(): Vector2;
|
|
3371
|
+
/** Get the current joint translation
|
|
3372
|
+
* @return {number} */
|
|
3373
|
+
getJointTranslation(): number;
|
|
3374
|
+
/** Get the current joint translation speed
|
|
3375
|
+
* @return {number} */
|
|
3376
|
+
getJointSpeed(): number;
|
|
3377
|
+
/** Is the joint motor enabled?
|
|
3378
|
+
* @return {boolean} */
|
|
3379
|
+
isMotorEnabled(): boolean;
|
|
3380
|
+
/** Enable/disable the joint motor
|
|
3381
|
+
* @param {boolean} [enable] */
|
|
3382
|
+
enableMotor(enable?: boolean): any;
|
|
3383
|
+
/** Set the motor speed
|
|
3384
|
+
* @param {number} speed */
|
|
3385
|
+
setMotorSpeed(speed: number): any;
|
|
3386
|
+
/** Get the motor speed
|
|
3387
|
+
* @return {number} */
|
|
3388
|
+
getMotorSpeed(): number;
|
|
3389
|
+
/** Set the maximum motor torque
|
|
3390
|
+
* @param {number} torque */
|
|
3391
|
+
setMaxMotorTorque(torque: number): any;
|
|
3392
|
+
/** Get the max motor torque
|
|
3393
|
+
* @return {number} */
|
|
3394
|
+
getMaxMotorTorque(): number;
|
|
3395
|
+
/** Get the motor torque for a time step
|
|
3396
|
+
* @return {number} */
|
|
3397
|
+
getMotorTorque(time: any): number;
|
|
3398
|
+
/** Set the spring frequency in Hertz
|
|
3399
|
+
* @param {number} hz */
|
|
3400
|
+
setSpringFrequencyHz(hz: number): any;
|
|
3401
|
+
/** Get the spring frequency in Hertz
|
|
3402
|
+
* @return {number} */
|
|
3403
|
+
getSpringFrequencyHz(): number;
|
|
3404
|
+
/** Set the spring damping ratio
|
|
3405
|
+
* @param {number} ratio */
|
|
3406
|
+
setSpringDampingRatio(ratio: number): any;
|
|
3407
|
+
/** Get the spring damping ratio
|
|
3408
|
+
* @return {number} */
|
|
3409
|
+
getSpringDampingRatio(): number;
|
|
3410
|
+
}
|
|
3411
|
+
/**
|
|
3412
|
+
* Box2D Weld Joint
|
|
3413
|
+
* - Glues two objects together
|
|
3414
|
+
* @extends Box2dJoint
|
|
3415
|
+
*/
|
|
3416
|
+
export class Box2dWeldJoint extends Box2dJoint {
|
|
3417
|
+
/** Create a weld joint
|
|
3418
|
+
* @param {Box2dObject} objectA
|
|
3419
|
+
* @param {Box2dObject} objectB
|
|
3420
|
+
* @param {Vector2} anchor
|
|
3421
|
+
* @param {boolean} [collide] */
|
|
3422
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchor: Vector2, collide?: boolean);
|
|
3423
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3424
|
+
* @return {Vector2} */
|
|
3425
|
+
getLocalAnchorA(): Vector2;
|
|
3426
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3427
|
+
* @return {Vector2} */
|
|
3428
|
+
getLocalAnchorB(): Vector2;
|
|
3429
|
+
/** Get the reference angle
|
|
3430
|
+
* @return {number} */
|
|
3431
|
+
getReferenceAngle(): number;
|
|
3432
|
+
/** Set the frequency in Hertz
|
|
3433
|
+
* @param {number} hz */
|
|
3434
|
+
setFrequency(hz: number): any;
|
|
3435
|
+
/** Get the frequency in Hertz
|
|
3436
|
+
* @return {number} */
|
|
3437
|
+
getFrequency(): number;
|
|
3438
|
+
/** Set the damping ratio
|
|
3439
|
+
* @param {number} ratio */
|
|
3440
|
+
setSpringDampingRatio(ratio: number): any;
|
|
3441
|
+
/** Get the damping ratio
|
|
3442
|
+
* @return {number} */
|
|
3443
|
+
getSpringDampingRatio(): number;
|
|
3444
|
+
}
|
|
3445
|
+
/**
|
|
3446
|
+
* Box2D Friction Joint
|
|
3447
|
+
* - Used to apply top-down friction
|
|
3448
|
+
* - Provides 2D translational friction and angular friction
|
|
3449
|
+
* @extends Box2dJoint
|
|
3450
|
+
*/
|
|
3451
|
+
export class Box2dFrictionJoint extends Box2dJoint {
|
|
3452
|
+
/** Create a friction joint
|
|
3453
|
+
* @param {Box2dObject} objectA
|
|
3454
|
+
* @param {Box2dObject} objectB
|
|
3455
|
+
* @param {Vector2} anchor
|
|
3456
|
+
* @param {boolean} [collide] */
|
|
3457
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, anchor: Vector2, collide?: boolean);
|
|
3458
|
+
/** Get the local anchor point relative to objectA's origin
|
|
3459
|
+
* @return {Vector2} */
|
|
3460
|
+
getLocalAnchorA(): Vector2;
|
|
3461
|
+
/** Get the local anchor point relative to objectB's origin
|
|
3462
|
+
* @return {Vector2} */
|
|
3463
|
+
getLocalAnchorB(): Vector2;
|
|
3464
|
+
/** Set the maximum friction force
|
|
3465
|
+
* @param {number} force */
|
|
3466
|
+
setMaxForce(force: number): void;
|
|
3467
|
+
/** Get the maximum friction force
|
|
3468
|
+
* @return {number} */
|
|
3469
|
+
getMaxForce(): number;
|
|
3470
|
+
/** Set the maximum friction torque
|
|
3471
|
+
* @param {number} torque */
|
|
3472
|
+
setMaxTorque(torque: number): void;
|
|
3473
|
+
/** Get the maximum friction torque
|
|
3474
|
+
* @return {number} */
|
|
3475
|
+
getMaxTorque(): number;
|
|
3476
|
+
}
|
|
3477
|
+
/**
|
|
3478
|
+
* Box2D Pulley Joint
|
|
3479
|
+
* - Connects to two objects and two fixed ground points
|
|
3480
|
+
* - The pulley supports a ratio such that: length1 + ratio * length2 <= constant
|
|
3481
|
+
* - The force transmitted is scaled by the ratio
|
|
3482
|
+
* @extends Box2dJoint
|
|
3483
|
+
*/
|
|
3484
|
+
export class Box2dPulleyJoint extends Box2dJoint {
|
|
3485
|
+
/** Create a pulley joint
|
|
3486
|
+
* @param {Box2dObject} objectA
|
|
3487
|
+
* @param {Box2dObject} objectB
|
|
3488
|
+
* @param {Vector2} groundAnchorA
|
|
3489
|
+
* @param {Vector2} groundAnchorB
|
|
3490
|
+
* @param {Vector2} anchorA
|
|
3491
|
+
* @param {Vector2} anchorB
|
|
3492
|
+
* @param {number} [ratio]
|
|
3493
|
+
* @param {boolean} [collide] */
|
|
3494
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject, groundAnchorA: Vector2, groundAnchorB: Vector2, anchorA: Vector2, anchorB: Vector2, ratio?: number, collide?: boolean);
|
|
3495
|
+
/** Get the first ground anchor
|
|
3496
|
+
* @return {Vector2} */
|
|
3497
|
+
getGroundAnchorA(): Vector2;
|
|
3498
|
+
/** Get the second ground anchor
|
|
3499
|
+
* @return {Vector2} */
|
|
3500
|
+
getGroundAnchorB(): Vector2;
|
|
3501
|
+
/** Get the current length of the segment attached to objectA
|
|
3502
|
+
* @return {number} */
|
|
3503
|
+
getLengthA(): number;
|
|
3504
|
+
/** Get the current length of the segment attached to objectB
|
|
3505
|
+
* @return {number} */
|
|
3506
|
+
getLengthB(): number;
|
|
3507
|
+
/** Get the pulley ratio
|
|
3508
|
+
* @return {number} */
|
|
3509
|
+
getRatio(): number;
|
|
3510
|
+
/** Get the current length of the segment attached to objectA
|
|
3511
|
+
* @return {number} */
|
|
3512
|
+
getCurrentLengthA(): number;
|
|
3513
|
+
/** Get the current length of the segment attached to objectB
|
|
3514
|
+
* @return {number} */
|
|
3515
|
+
getCurrentLengthB(): number;
|
|
3516
|
+
}
|
|
3517
|
+
/**
|
|
3518
|
+
* Box2D Motor Joint
|
|
3519
|
+
* - Controls the relative motion between two objects
|
|
3520
|
+
* - Typical usage is to control the movement of a object with respect to the ground
|
|
3521
|
+
* @extends Box2dJoint
|
|
3522
|
+
*/
|
|
3523
|
+
export class Box2dMotorJoint extends Box2dJoint {
|
|
3524
|
+
/** Create a motor joint
|
|
3525
|
+
* @param {Box2dObject} objectA
|
|
3526
|
+
* @param {Box2dObject} objectB */
|
|
3527
|
+
constructor(objectA: Box2dObject, objectB: Box2dObject);
|
|
3528
|
+
/** Set the target linear offset, in frame A, in meters.
|
|
3529
|
+
* @param {Vector2} offset */
|
|
3530
|
+
setLinearOffset(offset: Vector2): void;
|
|
3531
|
+
/** Get the target linear offset, in frame A, in meters.
|
|
3532
|
+
* @return {Vector2} */
|
|
3533
|
+
getLinearOffset(): Vector2;
|
|
3534
|
+
/** Set the target angular offset
|
|
3535
|
+
* @param {number} offset */
|
|
3536
|
+
setAngularOffset(offset: number): void;
|
|
3537
|
+
/** Get the target angular offset
|
|
3538
|
+
* @return {number} */
|
|
3539
|
+
getAngularOffset(): number;
|
|
3540
|
+
/** Set the maximum friction force
|
|
3541
|
+
* @param {number} force */
|
|
3542
|
+
setMaxForce(force: number): void;
|
|
3543
|
+
/** Get the maximum friction force
|
|
3544
|
+
* @return {number} */
|
|
3545
|
+
getMaxForce(): number;
|
|
3546
|
+
/** Set the maximum torque
|
|
3547
|
+
* @param {number} torque */
|
|
3548
|
+
setMaxTorque(torque: number): void;
|
|
3549
|
+
/** Get the maximum torque
|
|
3550
|
+
* @return {number} */
|
|
3551
|
+
getMaxTorque(): number;
|
|
3552
|
+
/** Set the position correction factor in the range [0,1]
|
|
3553
|
+
* @param {number} factor */
|
|
3554
|
+
setCorrectionFactor(factor: number): void;
|
|
3555
|
+
/** Get the position correction factor in the range [0,1]
|
|
3556
|
+
* @return {number} */
|
|
3557
|
+
getCorrectionFactor(): number;
|
|
3558
|
+
}
|
|
2329
3559
|
}
|