littlejsengine 1.14.23 → 1.15.2
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 +184 -30
- package/dist/littlejs.esm.js +589 -147
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +583 -147
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +546 -147
- package/examples/box2d/gameObjects.js +6 -10
- package/examples/box2d/scenes.js +2 -2
- package/examples/breakout/gameObjects.js +1 -1
- package/examples/electron/index.html +2 -2
- package/examples/index.html +11 -7
- package/examples/platformer/gameCharacter.js +3 -2
- package/examples/platformer/gameObjects.js +3 -8
- package/examples/shorts/base.html +2 -2
- package/examples/shorts/box2d.js +2 -2
- package/examples/shorts/box2dCar.js +18 -7
- package/examples/shorts/box2dPool.js +108 -0
- package/examples/shorts/debugDraw.js +2 -3
- package/examples/shorts/flappyGame.js +1 -0
- package/examples/shorts/fps.js +1 -1
- package/examples/shorts/hillGlideGame.js +0 -2
- package/examples/shorts/input.js +59 -0
- package/examples/shorts/landerGame.js +1 -3
- package/examples/shorts/medals.js +15 -9
- package/examples/shorts/music.js +15 -17
- package/examples/shorts/musicPlayer.js +24 -24
- package/examples/shorts/platformer.js +0 -2
- package/examples/shorts/slidingPuzzle.js +1 -1
- package/examples/shorts/song.mp3 +0 -0
- package/examples/shorts/spaceGame.js +0 -2
- package/examples/shorts/spriteAtlas.js +0 -2
- package/examples/shorts/tiltedView.js +0 -3
- package/examples/shorts/timers.js +1 -2
- package/examples/shorts/topDown.js +0 -2
- package/examples/shorts/video.webm +0 -0
- package/examples/shorts/videoPlayer.js +33 -0
- package/examples/starter/index.html +3 -3
- package/package.json +1 -1
- package/plugins/box2d.js +170 -50
- package/plugins/pluginExport.js +3 -0
- package/plugins/uiSystem.js +229 -27
- package/src/engine.js +21 -18
- package/src/engineAudio.js +14 -2
- package/src/engineDebug.js +37 -0
- package/src/engineDraw.js +21 -13
- package/src/engineExport.js +3 -0
- package/src/engineInput.js +24 -12
- package/src/engineMedals.js +2 -2
- package/src/engineObject.js +24 -4
- package/src/engineParticles.js +4 -6
- package/src/engineTileLayer.js +2 -0
- package/src/engineUtilities.js +35 -13
package/dist/littlejs.d.ts
CHANGED
|
@@ -105,7 +105,7 @@ declare module "littlejsengine" {
|
|
|
105
105
|
export function setPaused(isPaused?: boolean): void;
|
|
106
106
|
/**
|
|
107
107
|
* @callback GameInitCallback - Called after the engine starts, can be async
|
|
108
|
-
* @
|
|
108
|
+
* @return {void|Promise<void>}
|
|
109
109
|
* @memberof Engine
|
|
110
110
|
*/
|
|
111
111
|
/**
|
|
@@ -139,10 +139,10 @@ declare module "littlejsengine" {
|
|
|
139
139
|
* @memberof Engine */
|
|
140
140
|
export function engineObjectsDestroy(): void;
|
|
141
141
|
/** Collects all object within a given area
|
|
142
|
-
* @param {Vector2} [pos]
|
|
143
|
-
* @param {Vector2|number} [size]
|
|
142
|
+
* @param {Vector2} [pos] - Center of test area, or undefined for all objects
|
|
143
|
+
* @param {Vector2|number} [size] - Radius of circle if float, rectangle size if Vector2
|
|
144
144
|
* @param {Array<EngineObject>} [objects=engineObjects] - List of objects to check
|
|
145
|
-
* @return {Array<EngineObject>}
|
|
145
|
+
* @return {Array<EngineObject>} - List of collected objects
|
|
146
146
|
* @memberof Engine */
|
|
147
147
|
export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>): Array<EngineObject>;
|
|
148
148
|
/**
|
|
@@ -813,7 +813,7 @@ declare module "littlejsengine" {
|
|
|
813
813
|
* @param {number} valueA
|
|
814
814
|
* @param {number} valueB
|
|
815
815
|
* @param {number} [wrapSize]
|
|
816
|
-
* @
|
|
816
|
+
* @return {number}
|
|
817
817
|
* @memberof Utilities */
|
|
818
818
|
export function distanceWrap(valueA: number, valueB: number, wrapSize?: number): number;
|
|
819
819
|
/** Linearly interpolates between values passed in with wrapping
|
|
@@ -821,20 +821,20 @@ declare module "littlejsengine" {
|
|
|
821
821
|
* @param {number} valueB
|
|
822
822
|
* @param {number} percent
|
|
823
823
|
* @param {number} [wrapSize]
|
|
824
|
-
* @
|
|
824
|
+
* @return {number}
|
|
825
825
|
* @memberof Utilities */
|
|
826
826
|
export function lerpWrap(valueA: number, valueB: number, percent: number, wrapSize?: number): number;
|
|
827
827
|
/** Returns signed wrapped distance between the two angles passed in
|
|
828
828
|
* @param {number} angleA
|
|
829
829
|
* @param {number} angleB
|
|
830
|
-
* @
|
|
830
|
+
* @return {number}
|
|
831
831
|
* @memberof Utilities */
|
|
832
832
|
export function distanceAngle(angleA: number, angleB: number): number;
|
|
833
833
|
/** Linearly interpolates between the angles passed in with wrapping
|
|
834
834
|
* @param {number} angleA
|
|
835
835
|
* @param {number} angleB
|
|
836
836
|
* @param {number} percent
|
|
837
|
-
* @
|
|
837
|
+
* @return {number}
|
|
838
838
|
* @memberof Utilities */
|
|
839
839
|
export function lerpAngle(angleA: number, angleB: number, percent: number): number;
|
|
840
840
|
/** Linearly interpolates between values passed in using percent
|
|
@@ -904,6 +904,11 @@ declare module "littlejsengine" {
|
|
|
904
904
|
* @return {number}
|
|
905
905
|
* @memberof Random */
|
|
906
906
|
export function randInt(valueA: number, valueB?: number): number;
|
|
907
|
+
/** Randomly returns true or false given the chance of true passed in
|
|
908
|
+
* @param {number} [chance]
|
|
909
|
+
* @return {boolean}
|
|
910
|
+
* @memberof Random */
|
|
911
|
+
export function randBool(chance?: number): boolean;
|
|
907
912
|
/** Randomly returns either -1 or 1
|
|
908
913
|
* @return {number}
|
|
909
914
|
* @memberof Random */
|
|
@@ -1224,13 +1229,18 @@ declare module "littlejsengine" {
|
|
|
1224
1229
|
*/
|
|
1225
1230
|
export class Timer {
|
|
1226
1231
|
/** Create a timer object set time passed in
|
|
1227
|
-
* @param {number} [timeLeft] - How much time left before the timer
|
|
1228
|
-
|
|
1232
|
+
* @param {number} [timeLeft] - How much time left before the timer
|
|
1233
|
+
* @param {boolean} [useRealTime] - Should the timer keep running even when the game is paused? (useful for UI) */
|
|
1234
|
+
constructor(timeLeft?: number, useRealTime?: boolean);
|
|
1235
|
+
useRealTime: boolean;
|
|
1229
1236
|
time: number;
|
|
1230
1237
|
setTime: number;
|
|
1231
1238
|
/** Set the timer with seconds passed in
|
|
1232
1239
|
* @param {number} [timeLeft] - How much time left before the timer is elapsed in seconds */
|
|
1233
1240
|
set(timeLeft?: number): void;
|
|
1241
|
+
/** Set if the timer should keep running even when the game is paused
|
|
1242
|
+
* @param {boolean} [useRealTime] */
|
|
1243
|
+
setUseRealTime(useRealTime?: boolean): void;
|
|
1234
1244
|
/** Unset the timer */
|
|
1235
1245
|
unset(): void;
|
|
1236
1246
|
/** Returns true if set
|
|
@@ -1251,6 +1261,9 @@ declare module "littlejsengine" {
|
|
|
1251
1261
|
/** Get the time this timer was set to, returns 0 if not set
|
|
1252
1262
|
* @return {number} */
|
|
1253
1263
|
getSetTime(): number;
|
|
1264
|
+
/** Get the current global time this timer is based on
|
|
1265
|
+
* @return {number} */
|
|
1266
|
+
getGlobalTime(): number;
|
|
1254
1267
|
/** Returns this timer expressed as a string
|
|
1255
1268
|
* @return {string} */
|
|
1256
1269
|
toString(): string;
|
|
@@ -1312,6 +1325,12 @@ declare module "littlejsengine" {
|
|
|
1312
1325
|
* @return {boolean}
|
|
1313
1326
|
* @memberof Utilities */
|
|
1314
1327
|
export function isString(s: any): boolean;
|
|
1328
|
+
/**
|
|
1329
|
+
* Check if object is an array
|
|
1330
|
+
* @param {any} a
|
|
1331
|
+
* @return {boolean}
|
|
1332
|
+
* @memberof Utilities */
|
|
1333
|
+
export function isArray(a: any): boolean;
|
|
1315
1334
|
/** Color - White #ffffff
|
|
1316
1335
|
* @type {Color}
|
|
1317
1336
|
* @memberof Utilities */
|
|
@@ -1646,9 +1665,10 @@ declare module "littlejsengine" {
|
|
|
1646
1665
|
* @param {string} [font=fontDefault]
|
|
1647
1666
|
* @param {string} [fontStyle]
|
|
1648
1667
|
* @param {number} [maxWidth]
|
|
1668
|
+
* @param {number} [angle]
|
|
1649
1669
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1650
1670
|
* @memberof Draw */
|
|
1651
|
-
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1671
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1652
1672
|
/** Draw text on overlay canvas in world space
|
|
1653
1673
|
* Automatically splits new lines into rows
|
|
1654
1674
|
* @param {string} text
|
|
@@ -1661,8 +1681,9 @@ declare module "littlejsengine" {
|
|
|
1661
1681
|
* @param {string} [font=fontDefault]
|
|
1662
1682
|
* @param {string} [fontStyle]
|
|
1663
1683
|
* @param {number} [maxWidth]
|
|
1684
|
+
* @param {number} [angle]
|
|
1664
1685
|
* @memberof Draw */
|
|
1665
|
-
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number): void;
|
|
1686
|
+
export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number): void;
|
|
1666
1687
|
/** Draw text on overlay canvas in screen space
|
|
1667
1688
|
* Automatically splits new lines into rows
|
|
1668
1689
|
* @param {string} text
|
|
@@ -1675,9 +1696,10 @@ declare module "littlejsengine" {
|
|
|
1675
1696
|
* @param {string} [font=fontDefault]
|
|
1676
1697
|
* @param {string} [fontStyle]
|
|
1677
1698
|
* @param {number} [maxWidth]
|
|
1699
|
+
* @param {number} [angle]
|
|
1678
1700
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
|
|
1679
1701
|
* @memberof Draw */
|
|
1680
|
-
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1702
|
+
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1681
1703
|
/** Enable normal or additive blend mode
|
|
1682
1704
|
* @param {boolean} [additive]
|
|
1683
1705
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1960,6 +1982,10 @@ declare module "littlejsengine" {
|
|
|
1960
1982
|
* @type {number}
|
|
1961
1983
|
* @memberof Input */
|
|
1962
1984
|
export let mouseWheel: number;
|
|
1985
|
+
/** True if mouse was inside the document window, set to false when mouse leaves
|
|
1986
|
+
* @type {boolean}
|
|
1987
|
+
* @memberof Input */
|
|
1988
|
+
export let mouseInWindow: boolean;
|
|
1963
1989
|
/** Returns true if user is using gamepad (has more recently pressed a gamepad button)
|
|
1964
1990
|
* @type {boolean}
|
|
1965
1991
|
* @memberof Input */
|
|
@@ -2381,6 +2407,8 @@ declare module "littlejsengine" {
|
|
|
2381
2407
|
/** Update the object transform, called automatically by engine even when paused */
|
|
2382
2408
|
updateTransforms(): void;
|
|
2383
2409
|
/** Update the object physics, called automatically by engine once each frame */
|
|
2410
|
+
updatePhysics(): void;
|
|
2411
|
+
/** Update the object, called automatically by engine once each frame. Does nothing by default. */
|
|
2384
2412
|
update(): void;
|
|
2385
2413
|
/** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
|
|
2386
2414
|
render(): void;
|
|
@@ -2420,6 +2448,9 @@ declare module "littlejsengine" {
|
|
|
2420
2448
|
/** How long since the object was created
|
|
2421
2449
|
* @return {number} */
|
|
2422
2450
|
getAliveTime(): number;
|
|
2451
|
+
/** Get the speed of this object
|
|
2452
|
+
* @return {number} */
|
|
2453
|
+
getSpeed(): number;
|
|
2423
2454
|
/** Apply acceleration to this object (adjust velocity, not affected by mass)
|
|
2424
2455
|
* @param {Vector2} acceleration */
|
|
2425
2456
|
applyAcceleration(acceleration: Vector2): void;
|
|
@@ -2440,6 +2471,16 @@ declare module "littlejsengine" {
|
|
|
2440
2471
|
/** Removes a child from this one
|
|
2441
2472
|
* @param {EngineObject} child */
|
|
2442
2473
|
removeChild(child: EngineObject): void;
|
|
2474
|
+
/** Check if overlapping another engine object
|
|
2475
|
+
* Collisions are resoloved to prevent overlaps
|
|
2476
|
+
* @param {EngineObject} object
|
|
2477
|
+
* @return {boolean} */
|
|
2478
|
+
isOverlappingObject(object: EngineObject): boolean;
|
|
2479
|
+
/** Check if overlapping a point or aligned bounding box
|
|
2480
|
+
* @param {Vector2} pos - Center of box
|
|
2481
|
+
* @param {Vector2} [size=(0,0)] - Size of box, uses a point if undefined
|
|
2482
|
+
* @return {boolean} */
|
|
2483
|
+
isOverlapping(pos: Vector2, size?: Vector2): boolean;
|
|
2443
2484
|
/** Set how this object collides
|
|
2444
2485
|
* @param {boolean} [collideSolidObjects] - Does it collide with solid objects?
|
|
2445
2486
|
* @param {boolean} [isSolid] - Does it collide with and block other objects? (expensive in large numbers)
|
|
@@ -2478,6 +2519,7 @@ declare module "littlejsengine" {
|
|
|
2478
2519
|
* @memberof TileLayers */
|
|
2479
2520
|
export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
|
|
2480
2521
|
/** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
|
|
2522
|
+
* The point will be inside the colliding tile if it hits (may have a tiny shift)
|
|
2481
2523
|
* @param {Vector2} posStart
|
|
2482
2524
|
* @param {Vector2} posEnd
|
|
2483
2525
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
@@ -2671,6 +2713,7 @@ declare module "littlejsengine" {
|
|
|
2671
2713
|
* @return {boolean} */
|
|
2672
2714
|
collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
2673
2715
|
/** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
|
|
2716
|
+
* The point will be inside the colliding tile if it hits (may have a tiny shift)
|
|
2674
2717
|
* @param {Vector2} posStart
|
|
2675
2718
|
* @param {Vector2} posEnd
|
|
2676
2719
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
@@ -3118,11 +3161,11 @@ declare module "littlejsengine" {
|
|
|
3118
3161
|
/** Draw a rectangle to the UI context
|
|
3119
3162
|
* @param {Vector2} pos
|
|
3120
3163
|
* @param {Vector2} size
|
|
3121
|
-
* @param {Color} [color
|
|
3122
|
-
* @param {number} [lineWidth
|
|
3123
|
-
* @param {Color} [lineColor
|
|
3124
|
-
* @param {number} [cornerRadius
|
|
3125
|
-
* @param {Color} [gradientColor
|
|
3164
|
+
* @param {Color} [color]
|
|
3165
|
+
* @param {number} [lineWidth]
|
|
3166
|
+
* @param {Color} [lineColor]
|
|
3167
|
+
* @param {number} [cornerRadius]
|
|
3168
|
+
* @param {Color} [gradientColor] */
|
|
3126
3169
|
drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, cornerRadius?: number, gradientColor?: Color): void;
|
|
3127
3170
|
/** Draw a line to the UI context
|
|
3128
3171
|
* @param {Vector2} posA
|
|
@@ -3148,8 +3191,10 @@ declare module "littlejsengine" {
|
|
|
3148
3191
|
* @param {string} [align]
|
|
3149
3192
|
* @param {string} [font=uiSystem.defaultFont]
|
|
3150
3193
|
* @param {string} [fontStyle]
|
|
3151
|
-
* @param {boolean} [applyMaxWidth=true]
|
|
3152
|
-
|
|
3194
|
+
* @param {boolean} [applyMaxWidth=true]
|
|
3195
|
+
* @param {Vector2} [textShadow]
|
|
3196
|
+
*/
|
|
3197
|
+
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean, textShadow?: Vector2): void;
|
|
3153
3198
|
/**
|
|
3154
3199
|
* @callback DragAndDropCallback - Callback for drag and drop events
|
|
3155
3200
|
* @param {DragEvent} event - The drag event
|
|
@@ -3162,6 +3207,14 @@ declare module "littlejsengine" {
|
|
|
3162
3207
|
* @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
|
|
3163
3208
|
* @param {DragAndDropCallback} [onDragOver] - continously when dragging over */
|
|
3164
3209
|
setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
|
|
3210
|
+
/** Convert a screen space position to native UI position
|
|
3211
|
+
* @param {Vector2} pos
|
|
3212
|
+
* @return {Vector2}
|
|
3213
|
+
*/
|
|
3214
|
+
screenToNative(pos: Vector2): Vector2;
|
|
3215
|
+
/** Destroy and remove all objects
|
|
3216
|
+
* @memberof Engine */
|
|
3217
|
+
destroyObjects(): void;
|
|
3165
3218
|
}
|
|
3166
3219
|
/**
|
|
3167
3220
|
* UI Object - Base level object for all UI elements
|
|
@@ -3230,6 +3283,8 @@ declare module "littlejsengine" {
|
|
|
3230
3283
|
dragActivate: boolean;
|
|
3231
3284
|
/** @property {boolean} - True if this can be a hover object */
|
|
3232
3285
|
canBeHover: boolean;
|
|
3286
|
+
/** @property {Vector2} - How much to offset the text shadow or undefined */
|
|
3287
|
+
textShadow: any;
|
|
3233
3288
|
/** Add a child UIObject to this object
|
|
3234
3289
|
* @param {UIObject} child
|
|
3235
3290
|
*/
|
|
@@ -3238,6 +3293,9 @@ declare module "littlejsengine" {
|
|
|
3238
3293
|
* @param {UIObject} child
|
|
3239
3294
|
*/
|
|
3240
3295
|
removeChild(child: UIObject): void;
|
|
3296
|
+
/** Destroy this object, destroy its children, detach its parent, and mark it for removal */
|
|
3297
|
+
destroy(): void;
|
|
3298
|
+
destroyed: number;
|
|
3241
3299
|
/** Check if the mouse is overlapping a box in screen space
|
|
3242
3300
|
* @return {boolean} - True if overlapping
|
|
3243
3301
|
*/
|
|
@@ -3256,6 +3314,8 @@ declare module "littlejsengine" {
|
|
|
3256
3314
|
isHoverObject(): boolean;
|
|
3257
3315
|
/** @return {boolean} - Is the mouse held onto this element */
|
|
3258
3316
|
isActiveObject(): boolean;
|
|
3317
|
+
/** Called each frame when object updates */
|
|
3318
|
+
onUpdate(): void;
|
|
3259
3319
|
/** Called when the mouse enters the object */
|
|
3260
3320
|
onEnter(): void;
|
|
3261
3321
|
/** Called when the mouse leaves the object */
|
|
@@ -3362,12 +3422,73 @@ declare module "littlejsengine" {
|
|
|
3362
3422
|
handleColor: Color;
|
|
3363
3423
|
text: string;
|
|
3364
3424
|
}
|
|
3425
|
+
/**
|
|
3426
|
+
* VideoPlayerUIObject - A UI object that plays video
|
|
3427
|
+
* @extends UIObject
|
|
3428
|
+
* @example
|
|
3429
|
+
* // Create a video player UI object
|
|
3430
|
+
* const video = new VideoPlayerUIObject(vec2(400, 300), vec2(320, 240), 'cutscene.mp4', true);
|
|
3431
|
+
* video.play();
|
|
3432
|
+
* @memberof UISystem
|
|
3433
|
+
*/
|
|
3434
|
+
export class UIVideo extends UIObject {
|
|
3435
|
+
/** Create a video player UI object
|
|
3436
|
+
* @param {Vector2} [pos]
|
|
3437
|
+
* @param {Vector2} [size]
|
|
3438
|
+
* @param {string} src - Video file path or URL
|
|
3439
|
+
* @param {boolean} [autoplay=false] - Start playing immediately?
|
|
3440
|
+
* @param {boolean} [loop=false] - Loop the video?
|
|
3441
|
+
* @param {number} [volume=1] - Volume percent scaled by global volume (0-1)
|
|
3442
|
+
*/
|
|
3443
|
+
constructor(pos?: Vector2, size?: Vector2, src: string, autoplay?: boolean, loop?: boolean, volume?: number);
|
|
3444
|
+
/** @property {float} - The video volume */
|
|
3445
|
+
volume: number;
|
|
3446
|
+
/** @property {HTMLVideoElement} - The video player */
|
|
3447
|
+
video: HTMLVideoElement;
|
|
3448
|
+
/** Play or resume the video
|
|
3449
|
+
* @return {Promise} Promise that resolves when playback starts */
|
|
3450
|
+
play(): Promise<any>;
|
|
3451
|
+
/** Pause the video */
|
|
3452
|
+
pause(): void;
|
|
3453
|
+
/** Stop and reset the video */
|
|
3454
|
+
stop(): void;
|
|
3455
|
+
/** Check if video is currently loading
|
|
3456
|
+
* @return {boolean} */
|
|
3457
|
+
isLoadng(): boolean;
|
|
3458
|
+
/** Check if video is currently paused
|
|
3459
|
+
* @return {boolean} */
|
|
3460
|
+
isPaused(): boolean;
|
|
3461
|
+
/** Check if video is currently playing
|
|
3462
|
+
* @return {boolean} */
|
|
3463
|
+
isPlaying(): boolean;
|
|
3464
|
+
/** Check if video has ended playing
|
|
3465
|
+
* @return {boolean} */
|
|
3466
|
+
hasEnded(): boolean;
|
|
3467
|
+
/** Set volume (0-1)
|
|
3468
|
+
* @param {number} volume - Volume level (0-1) */
|
|
3469
|
+
setVolume(volume: number): void;
|
|
3470
|
+
/** Set playback speed
|
|
3471
|
+
* @param {number} rate - Playback rate multiplier */
|
|
3472
|
+
setPlaybackRate(rate: number): void;
|
|
3473
|
+
/** Get current time in seconds
|
|
3474
|
+
* @return {number} Current playback time */
|
|
3475
|
+
getCurrentTime(): number;
|
|
3476
|
+
/** Get duration in seconds
|
|
3477
|
+
* @return {number} Total video duration */
|
|
3478
|
+
getDuration(): number;
|
|
3479
|
+
/** Get the native video dimensions
|
|
3480
|
+
* @return {Vector2} Video dimensions (may be 0,0 if metadata not loaded) */
|
|
3481
|
+
getVideoSize(): Vector2;
|
|
3482
|
+
/** Seek to time in seconds
|
|
3483
|
+
* @param {number} time - Time in seconds to seek to */
|
|
3484
|
+
setTime(time: number): void;
|
|
3485
|
+
}
|
|
3365
3486
|
/**
|
|
3366
3487
|
* LittleJS Box2D Physics Plugin
|
|
3367
3488
|
* - Box2dObject extends EngineObject with Box2D physics
|
|
3368
|
-
* - Call box2dInit()
|
|
3489
|
+
* - Call box2dInit() to enable
|
|
3369
3490
|
* - You will also need to include box2d.wasm.js
|
|
3370
|
-
* - Uses a super fast web assembly port of Box2D
|
|
3491
|
+
* - Uses a super fast web assembly port of Box2D v2.3.1
|
|
3371
3492
|
* - More info: https://github.com/kripken/box2d.js
|
|
3372
3493
|
* - Functions to create polygon, circle, and edge shapes
|
|
3373
3494
|
* - Contact begin and end callbacks
|
|
@@ -3407,6 +3528,7 @@ declare module "littlejsengine" {
|
|
|
3407
3528
|
constructor(instance: any);
|
|
3408
3529
|
instance: any;
|
|
3409
3530
|
world: any;
|
|
3531
|
+
objects: any[];
|
|
3410
3532
|
/** @property {number} - Velocity iterations per update*/
|
|
3411
3533
|
velocityIterations: number;
|
|
3412
3534
|
/** @property {number} - Position iterations per update*/
|
|
@@ -3462,7 +3584,7 @@ declare module "littlejsengine" {
|
|
|
3462
3584
|
vec2From(v: any): Vector2;
|
|
3463
3585
|
/** converts a box2d vec2 pointer to a Vector2
|
|
3464
3586
|
* @param {Object} v */
|
|
3465
|
-
vec2FromPointer(
|
|
3587
|
+
vec2FromPointer(vp: any): Vector2;
|
|
3466
3588
|
/** converts a Vector2 to a box2 vec2
|
|
3467
3589
|
* @param {Vector2} v */
|
|
3468
3590
|
vec2dTo(v: Vector2): any;
|
|
@@ -3475,9 +3597,9 @@ declare module "littlejsengine" {
|
|
|
3475
3597
|
}
|
|
3476
3598
|
/**
|
|
3477
3599
|
* Box2D Object - extend with your own custom physics objects
|
|
3478
|
-
* - A LittleJS object with Box2D physics
|
|
3479
|
-
* - Each object has a Box2D body which can have multiple fixtures and joints
|
|
3600
|
+
* - A LittleJS object with Box2D physics, dynamic by default
|
|
3480
3601
|
* - Provides interface for Box2D body and fixture functions
|
|
3602
|
+
* - Each object can have multiple fixtures and joints
|
|
3481
3603
|
* @extends EngineObject
|
|
3482
3604
|
* @memberof Box2D
|
|
3483
3605
|
*/
|
|
@@ -3493,6 +3615,8 @@ declare module "littlejsengine" {
|
|
|
3493
3615
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, bodyType?: number, renderOrder?: number);
|
|
3494
3616
|
body: any;
|
|
3495
3617
|
lineColor: Color;
|
|
3618
|
+
edgeLists: any[];
|
|
3619
|
+
edgeLoops: any[];
|
|
3496
3620
|
/** Draws all this object's fixtures
|
|
3497
3621
|
* @param {Color} [color]
|
|
3498
3622
|
* @param {Color} [lineColor]
|
|
@@ -3559,20 +3683,20 @@ declare module "littlejsengine" {
|
|
|
3559
3683
|
* @param {number} [restitution]
|
|
3560
3684
|
* @param {boolean} [isSensor] */
|
|
3561
3685
|
addEdge(point1: Vector2, point2: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
|
|
3562
|
-
/** Add an edge
|
|
3686
|
+
/** Add an edge list to the body
|
|
3563
3687
|
* @param {Array<Vector2>} points
|
|
3564
3688
|
* @param {number} [density]
|
|
3565
3689
|
* @param {number} [friction]
|
|
3566
3690
|
* @param {number} [restitution]
|
|
3567
3691
|
* @param {boolean} [isSensor] */
|
|
3568
|
-
|
|
3569
|
-
/** Add an edge
|
|
3692
|
+
addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
|
|
3693
|
+
/** Add an edge loop to the body, an edge loop connects the end points
|
|
3570
3694
|
* @param {Array<Vector2>} points
|
|
3571
3695
|
* @param {number} [density]
|
|
3572
3696
|
* @param {number} [friction]
|
|
3573
3697
|
* @param {number} [restitution]
|
|
3574
3698
|
* @param {boolean} [isSensor] */
|
|
3575
|
-
|
|
3699
|
+
addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
|
|
3576
3700
|
/** Gets the center of mass
|
|
3577
3701
|
* @return {Vector2} */
|
|
3578
3702
|
getCenterOfMass(): Vector2;
|
|
@@ -3619,7 +3743,7 @@ declare module "littlejsengine" {
|
|
|
3619
3743
|
/** Sets the gravity scale
|
|
3620
3744
|
* @param {number} [scale] */
|
|
3621
3745
|
setGravityScale(scale?: number): void;
|
|
3622
|
-
/** Should
|
|
3746
|
+
/** Should be like a bullet for continuous collision detection?
|
|
3623
3747
|
* @param {boolean} [isBullet] */
|
|
3624
3748
|
setBullet(isBullet?: boolean): void;
|
|
3625
3749
|
/** Set the sleep state of the body
|
|
@@ -3682,6 +3806,36 @@ declare module "littlejsengine" {
|
|
|
3682
3806
|
* @return {Array<Object>} */
|
|
3683
3807
|
getJointList(): Array<any>;
|
|
3684
3808
|
}
|
|
3809
|
+
/**
|
|
3810
|
+
* Box2D Static Object - Box2d with a static physics body
|
|
3811
|
+
* @extends Box2dObject
|
|
3812
|
+
* @memberof Box2D
|
|
3813
|
+
*/
|
|
3814
|
+
export class Box2dStaticObject extends Box2dObject {
|
|
3815
|
+
/** Create a LittleJS object with Box2d physics
|
|
3816
|
+
* @param {Vector2} [pos]
|
|
3817
|
+
* @param {Vector2} [size]
|
|
3818
|
+
* @param {TileInfo} [tileInfo]
|
|
3819
|
+
* @param {number} [angle]
|
|
3820
|
+
* @param {Color} [color]
|
|
3821
|
+
* @param {number} [renderOrder] */
|
|
3822
|
+
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
3823
|
+
}
|
|
3824
|
+
/**
|
|
3825
|
+
* Box2D Kiematic Object - Box2d with a kinematic physics body
|
|
3826
|
+
* @extends Box2dObject
|
|
3827
|
+
* @memberof Box2D
|
|
3828
|
+
*/
|
|
3829
|
+
export class Box2dKiematicObject extends Box2dObject {
|
|
3830
|
+
/** Create a LittleJS object with Box2d physics
|
|
3831
|
+
* @param {Vector2} [pos]
|
|
3832
|
+
* @param {Vector2} [size]
|
|
3833
|
+
* @param {TileInfo} [tileInfo]
|
|
3834
|
+
* @param {number} [angle]
|
|
3835
|
+
* @param {Color} [color]
|
|
3836
|
+
* @param {number} [renderOrder] */
|
|
3837
|
+
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
3838
|
+
}
|
|
3685
3839
|
/**
|
|
3686
3840
|
* Box2D Raycast Result
|
|
3687
3841
|
* - Holds results from a box2d raycast queries
|