littlejsengine 1.14.19 → 1.14.28

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.
Files changed (70) hide show
  1. package/dist/littlejs.d.ts +217 -38
  2. package/dist/littlejs.esm.js +879 -324
  3. package/dist/littlejs.esm.min.js +1 -1
  4. package/dist/littlejs.js +861 -324
  5. package/dist/littlejs.min.js +1 -1
  6. package/dist/littlejs.release.js +799 -325
  7. package/examples/box2d/gameObjects.js +6 -10
  8. package/examples/box2d/scenes.js +2 -2
  9. package/examples/breakout/gameObjects.js +1 -1
  10. package/examples/electron/game.js +1 -41
  11. package/examples/electron/index.html +2 -2
  12. package/examples/htmlMenu/game.js +1 -1
  13. package/examples/index.html +19 -10
  14. package/examples/module/game.js +5 -7
  15. package/examples/particles/index.html +6 -9
  16. package/examples/platformer/gameCharacter.js +4 -3
  17. package/examples/platformer/gameEffects.js +7 -2
  18. package/examples/platformer/gameObjects.js +6 -11
  19. package/examples/shorts/animation.js +2 -2
  20. package/examples/shorts/base.html +4 -1
  21. package/examples/shorts/box2d.js +2 -2
  22. package/examples/shorts/box2dCar.js +18 -7
  23. package/examples/shorts/box2dPool.js +108 -0
  24. package/examples/shorts/cameraDrag.js +22 -0
  25. package/examples/shorts/debugDraw.js +37 -0
  26. package/examples/shorts/flappyGame.js +1 -0
  27. package/examples/shorts/fps.js +90 -0
  28. package/examples/shorts/helloWorld.js +1 -1
  29. package/examples/shorts/hillGlideGame.js +1 -3
  30. package/examples/shorts/input.js +59 -0
  31. package/examples/shorts/landerGame.js +1 -3
  32. package/examples/shorts/medals.js +15 -9
  33. package/examples/shorts/music.js +15 -17
  34. package/examples/shorts/musicPlayer.js +24 -24
  35. package/examples/shorts/platformer.js +0 -2
  36. package/examples/shorts/postProcess.js +1 -1
  37. package/examples/shorts/sequencer.js +3 -3
  38. package/examples/shorts/slidingPuzzle.js +1 -1
  39. package/examples/shorts/spaceGame.js +1 -3
  40. package/examples/shorts/spriteAtlas.js +6 -8
  41. package/examples/shorts/starfield.js +1 -1
  42. package/examples/shorts/tileRaycast.js +39 -0
  43. package/examples/shorts/tiles.png +0 -0
  44. package/examples/shorts/tiltedView.js +1 -4
  45. package/examples/shorts/timers.js +1 -2
  46. package/examples/shorts/topDown.js +0 -2
  47. package/examples/starter/game.js +5 -7
  48. package/examples/starter/index.html +2 -2
  49. package/examples/typescript/game.js +3 -2
  50. package/examples/typescript/game.ts +5 -7
  51. package/examples/uiSystem/game.js +2 -2
  52. package/package.json +1 -1
  53. package/plugins/box2d.js +170 -50
  54. package/plugins/pluginExport.js +2 -0
  55. package/plugins/uiSystem.js +55 -27
  56. package/src/engine.js +19 -16
  57. package/src/engineAudio.js +27 -15
  58. package/src/engineDebug.js +64 -0
  59. package/src/engineDraw.js +88 -32
  60. package/src/engineExport.js +16 -0
  61. package/src/engineInput.js +35 -25
  62. package/src/engineMedals.js +2 -2
  63. package/src/engineObject.js +55 -10
  64. package/src/engineParticles.js +36 -20
  65. package/src/engineRelease.js +2 -1
  66. package/src/engineSettings.js +20 -1
  67. package/src/engineTileLayer.js +64 -59
  68. package/src/engineUtilities.js +213 -59
  69. package/src/engineWebGL.js +13 -8
  70. package/examples/shorts/raycasting.js +0 -79
@@ -14,7 +14,11 @@ declare module "littlejsengine" {
14
14
  /**
15
15
  * - Function that processes an object
16
16
  */
17
- export type ObjectCallbackFunction = (uiObjects: EngineObject) => any;
17
+ export type ObjectCallbackFunction = (object: EngineObject) => any;
18
+ /**
19
+ * - Checks if a position is colliding
20
+ */
21
+ export type LineTestFunction = (pos: Vector2) => any;
18
22
  /**
19
23
  * - A function that draws to a 2D canvas context
20
24
  */
@@ -143,7 +147,7 @@ declare module "littlejsengine" {
143
147
  export function engineObjectsCollect(pos?: Vector2, size?: Vector2 | number, objects?: Array<EngineObject>): Array<EngineObject>;
144
148
  /**
145
149
  * @callback ObjectCallbackFunction - Function that processes an object
146
- * @param {EngineObject} uiObjects
150
+ * @param {EngineObject} object
147
151
  * @memberof Engine
148
152
  */
149
153
  /** Triggers a callback for each object within a given area
@@ -456,6 +460,13 @@ declare module "littlejsengine" {
456
460
  * @default
457
461
  * @memberof Settings */
458
462
  export let touchGamepadEnable: boolean;
463
+ /** True if touch gamepad should have start button in the center
464
+ * - When the game is paused, any touch will press the button
465
+ * - This can function as a way to pause/unpause the game
466
+ * @type {boolean}
467
+ * @default
468
+ * @memberof Settings */
469
+ export let touchGamepadCenterButton: boolean;
459
470
  /** True if touch gamepad should be analog stick or false to use if 8 way dpad
460
471
  * @type {boolean}
461
472
  * @default
@@ -637,6 +648,11 @@ declare module "littlejsengine" {
637
648
  * @param {boolean} enable
638
649
  * @memberof Settings */
639
650
  export function setTouchGamepadEnable(enable: boolean): void;
651
+ /** True if touch gamepad should have start button in the center
652
+ * - This can function as a way to pause/unpause the game
653
+ * @param {boolean} enable
654
+ * @memberof Settings */
655
+ export function setTouchGamepadCenterButton(enable: boolean): void;
640
656
  /** Set if touch gamepad should be analog stick or 8 way dpad
641
657
  * @param {boolean} analog
642
658
  * @memberof Settings */
@@ -702,7 +718,7 @@ declare module "littlejsengine" {
702
718
  * - RandomGenerator - seeded random number generator
703
719
  * @namespace Utilities
704
720
  */
705
- /** A shortcut to get Math.PI
721
+ /** The value of PI
706
722
  * @type {number}
707
723
  * @default Math.PI
708
724
  * @memberof Utilities */
@@ -711,22 +727,68 @@ declare module "littlejsengine" {
711
727
  * @param {number} value
712
728
  * @return {number}
713
729
  * @memberof Utilities */
714
- export function abs(value: number): number;
730
+ export const abs: (x: number) => number;
731
+ /** Returns floored value of value passed in
732
+ * @param {number} value
733
+ * @return {number}
734
+ * @memberof Utilities */
735
+ export const floor: (x: number) => number;
736
+ /** Returns ceiled value of value passed in
737
+ * @param {number} value
738
+ * @return {number}
739
+ * @memberof Utilities */
740
+ export const ceil: (x: number) => number;
741
+ /** Returns rounded value passed in
742
+ * @param {number} value
743
+ * @return {number}
744
+ * @memberof Utilities */
745
+ export const round: (x: number) => number;
715
746
  /** Returns lowest value passed in
716
747
  * @param {...number} values
717
748
  * @return {number}
718
749
  * @memberof Utilities */
719
- export function min(...values: number[]): number;
750
+ export const min: (...values: number[]) => number;
720
751
  /** Returns highest value passed in
721
752
  * @param {...number} values
722
753
  * @return {number}
723
754
  * @memberof Utilities */
724
- export function max(...values: number[]): number;
755
+ export const max: (...values: number[]) => number;
725
756
  /** Returns the sign of value passed in
726
757
  * @param {number} value
727
758
  * @return {number}
728
759
  * @memberof Utilities */
729
- export function sign(value: number): number;
760
+ export const sign: (x: number) => number;
761
+ /** Returns hypotenuse of values passed in
762
+ * @param {...number} values
763
+ * @return {number}
764
+ * @memberof Utilities */
765
+ export const hypot: (...values: number[]) => number;
766
+ /** Returns log2 of value passed in
767
+ * @param {number} value
768
+ * @return {number}
769
+ * @memberof Utilities */
770
+ export const log2: (x: number) => number;
771
+ /** Returns sin of value passed in
772
+ * @param {number} value
773
+ * @return {number}
774
+ * @memberof Utilities */
775
+ export const sin: (x: number) => number;
776
+ /** Returns cos of value passed in
777
+ * @param {number} value
778
+ * @return {number}
779
+ * @memberof Utilities */
780
+ export const cos: (x: number) => number;
781
+ /** Returns tan of value passed in
782
+ * @param {number} value
783
+ * @return {number}
784
+ * @memberof Utilities */
785
+ export const tan: (x: number) => number;
786
+ /** Returns atan2 of values passed in
787
+ * @param {number} y
788
+ * @param {number} x
789
+ * @return {number}
790
+ * @memberof Utilities */
791
+ export const atan2: (y: number, x: number) => number;
730
792
  /** Returns first parm modulo the second param, but adjusted so negative numbers work as expected
731
793
  * @param {number} dividend
732
794
  * @param {number} [divisor]
@@ -842,6 +904,11 @@ declare module "littlejsengine" {
842
904
  * @return {number}
843
905
  * @memberof Random */
844
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;
845
912
  /** Randomly returns either -1 or 1
846
913
  * @return {number}
847
914
  * @memberof Random */
@@ -911,6 +978,18 @@ declare module "littlejsengine" {
911
978
  * @param {number} [valueB]
912
979
  * @return {Vector2} */
913
980
  vec2(valueA?: number, valueB?: number): Vector2;
981
+ /** Returns a random color between the two passed in colors, combine components if linear
982
+ * @param {Color} [colorA=(1,1,1,1)]
983
+ * @param {Color} [colorB=(0,0,0,1)]
984
+ * @param {boolean} [linear]
985
+ * @return {Color} */
986
+ randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
987
+ /** Returns a new color that has each component randomly adjusted
988
+ * @param {Color} color
989
+ * @param {number} [amount]
990
+ * @param {number} [alphaAmount]
991
+ * @return {Color} */
992
+ mutateColor(color: Color, amount?: number, alphaAmount?: number): Color;
914
993
  }
915
994
  /**
916
995
  * 2D Vector object with vector math library
@@ -1238,6 +1317,12 @@ declare module "littlejsengine" {
1238
1317
  * @return {boolean}
1239
1318
  * @memberof Utilities */
1240
1319
  export function isString(s: any): boolean;
1320
+ /**
1321
+ * Check if object is an array
1322
+ * @param {any} a
1323
+ * @return {boolean}
1324
+ * @memberof Utilities */
1325
+ export function isArray(a: any): boolean;
1241
1326
  /** Color - White #ffffff
1242
1327
  * @type {Color}
1243
1328
  * @memberof Utilities */
@@ -1442,6 +1527,16 @@ declare module "littlejsengine" {
1442
1527
  * @return {Vector2}
1443
1528
  * @memberof Draw */
1444
1529
  export function worldToScreen(worldPos: Vector2): Vector2;
1530
+ /** Convert from screen to world space coordinates for a directional vector (no translation)
1531
+ * @param {Vector2} screenDelta
1532
+ * @return {Vector2}
1533
+ * @memberof Draw */
1534
+ export function screenToWorldDelta(screenDelta: Vector2): Vector2;
1535
+ /** Convert from screen to world space coordinates for a directional vector (no translation)
1536
+ * @param {Vector2} worldDelta
1537
+ * @return {Vector2}
1538
+ * @memberof Draw */
1539
+ export function worldToScreenDelta(worldDelta: Vector2): Vector2;
1445
1540
  /** Draw textured tile centered in world space, with color applied if using WebGL
1446
1541
  * @param {Vector2} pos - Center of the tile in world space
1447
1542
  * @param {Vector2} [size=(1,1)] - Size of the tile in world space
@@ -1562,9 +1657,10 @@ declare module "littlejsengine" {
1562
1657
  * @param {string} [font=fontDefault]
1563
1658
  * @param {string} [fontStyle]
1564
1659
  * @param {number} [maxWidth]
1660
+ * @param {number} [angle]
1565
1661
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
1566
1662
  * @memberof Draw */
1567
- 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;
1663
+ 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;
1568
1664
  /** Draw text on overlay canvas in world space
1569
1665
  * Automatically splits new lines into rows
1570
1666
  * @param {string} text
@@ -1577,8 +1673,9 @@ declare module "littlejsengine" {
1577
1673
  * @param {string} [font=fontDefault]
1578
1674
  * @param {string} [fontStyle]
1579
1675
  * @param {number} [maxWidth]
1676
+ * @param {number} [angle]
1580
1677
  * @memberof Draw */
1581
- export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number): void;
1678
+ 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;
1582
1679
  /** Draw text on overlay canvas in screen space
1583
1680
  * Automatically splits new lines into rows
1584
1681
  * @param {string} text
@@ -1591,9 +1688,10 @@ declare module "littlejsengine" {
1591
1688
  * @param {string} [font=fontDefault]
1592
1689
  * @param {string} [fontStyle]
1593
1690
  * @param {number} [maxWidth]
1691
+ * @param {number} [angle]
1594
1692
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
1595
1693
  * @memberof Draw */
1596
- 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;
1694
+ 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;
1597
1695
  /** Enable normal or additive blend mode
1598
1696
  * @param {boolean} [additive]
1599
1697
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
@@ -1876,6 +1974,10 @@ declare module "littlejsengine" {
1876
1974
  * @type {number}
1877
1975
  * @memberof Input */
1878
1976
  export let mouseWheel: number;
1977
+ /** True if mouse was inside the document window, set to false when mouse leaves
1978
+ * @type {boolean}
1979
+ * @memberof Input */
1980
+ export let mouseInWindow: boolean;
1879
1981
  /** Returns true if user is using gamepad (has more recently pressed a gamepad button)
1880
1982
  * @type {boolean}
1881
1983
  * @memberof Input */
@@ -2297,6 +2399,8 @@ declare module "littlejsengine" {
2297
2399
  /** Update the object transform, called automatically by engine even when paused */
2298
2400
  updateTransforms(): void;
2299
2401
  /** Update the object physics, called automatically by engine once each frame */
2402
+ updatePhysics(): void;
2403
+ /** Update the object, called automatically by engine once each frame. Does nothing by default. */
2300
2404
  update(): void;
2301
2405
  /** Render the object, draws a tile by default, automatically called each frame, sorted by renderOrder */
2302
2406
  render(): void;
@@ -2325,9 +2429,20 @@ declare module "littlejsengine" {
2325
2429
  * @return {boolean} - true if the collision should be resolved
2326
2430
  */
2327
2431
  collideWithObject(object: EngineObject): boolean;
2432
+ /** Get this object's up vector
2433
+ * @param {number} [scale] - length of the vector
2434
+ * @return {Vector2} */
2435
+ getUp(scale?: number): Vector2;
2436
+ /** Get this object's right vector
2437
+ * @param {number} [scale] - length of the vector
2438
+ * @return {Vector2} */
2439
+ getRight(scale?: number): Vector2;
2328
2440
  /** How long since the object was created
2329
2441
  * @return {number} */
2330
2442
  getAliveTime(): number;
2443
+ /** Get the speed of this object
2444
+ * @return {number} */
2445
+ getSpeed(): number;
2331
2446
  /** Apply acceleration to this object (adjust velocity, not affected by mass)
2332
2447
  * @param {Vector2} acceleration */
2333
2448
  applyAcceleration(acceleration: Vector2): void;
@@ -2348,6 +2463,16 @@ declare module "littlejsengine" {
2348
2463
  /** Removes a child from this one
2349
2464
  * @param {EngineObject} child */
2350
2465
  removeChild(child: EngineObject): void;
2466
+ /** Check if overlapping another engine object
2467
+ * Collisions are resoloved to prevent overlaps
2468
+ * @param {EngineObject} object
2469
+ * @return {boolean} */
2470
+ isOverlappingObject(object: EngineObject): boolean;
2471
+ /** Check if overlapping a point or aligned bounding box
2472
+ * @param {Vector2} pos - Center of box
2473
+ * @param {Vector2} [size=(0,0)] - Size of box, uses a point if undefined
2474
+ * @return {boolean} */
2475
+ isOverlapping(pos: Vector2, size?: Vector2): boolean;
2351
2476
  /** Set how this object collides
2352
2477
  * @param {boolean} [collideSolidObjects] - Does it collide with solid objects?
2353
2478
  * @param {boolean} [isSolid] - Does it collide with and block other objects? (expensive in large numbers)
@@ -2385,15 +2510,16 @@ declare module "littlejsengine" {
2385
2510
  * @return {TileCollisionLayer}
2386
2511
  * @memberof TileLayers */
2387
2512
  export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
2388
- /** Return the center of first tile hit, undefined if nothing was hit.
2389
- * This does not return the exact intersection, but the center of the tile hit.
2513
+ /** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
2514
+ * The point will be inside the colliding tile if it hits (may have a tiny shift)
2390
2515
  * @param {Vector2} posStart
2391
2516
  * @param {Vector2} posEnd
2392
2517
  * @param {EngineObject} [object] - An object or undefined for generic test
2518
+ * @param {Vector2} [normal] - Optional normal of the surface hit
2393
2519
  * @param {boolean} [solidOnly=true] - Only check solid layers if true
2394
- * @return {Vector2}
2520
+ * @return {Vector2|undefined} - position of the center of the tile hit or undefined if no hit
2395
2521
  * @memberof TileLayers */
2396
- export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, solidOnly?: boolean): Vector2;
2522
+ export function tileCollisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, normal?: Vector2, solidOnly?: boolean): Vector2 | undefined;
2397
2523
  /**
2398
2524
  * Load tile layers from exported data
2399
2525
  * @param {Object} tileMapData - Level data from exported data
@@ -2456,6 +2582,8 @@ declare module "littlejsengine" {
2456
2582
  /** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
2457
2583
  context: OffscreenCanvasRenderingContext2D;
2458
2584
  textureInfo: TextureInfo;
2585
+ /** @property {boolean} - True if WebGL texture needs to be refreshed */
2586
+ refreshWebGL: boolean;
2459
2587
  /** Draw this canvas layer centered in world space, with color applied if using WebGL
2460
2588
  * @param {Vector2} pos - Center in world space
2461
2589
  * @param {Vector2} [size] - Size in world space
@@ -2494,8 +2622,10 @@ declare module "littlejsengine" {
2494
2622
  * @param {number} [angle=0] */
2495
2623
  drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
2496
2624
  /** Create or update the WebGL texture for this layer
2497
- * @param {boolean} [enable] - enable WebGL rendering and update the texture */
2498
- useWebGL(enable?: boolean): void;
2625
+ * @param {boolean} [enable] - enable WebGL rendering and update the texture
2626
+ * @param {boolean} [immediate] - shoulkd the texture be updated immediately
2627
+ */
2628
+ useWebGL(enable?: boolean, immediate?: boolean): void;
2499
2629
  }
2500
2630
  /**
2501
2631
  * Tile Layer - cached rendering system for tile layers
@@ -2574,13 +2704,14 @@ declare module "littlejsengine" {
2574
2704
  * @param {EngineObject} [object]
2575
2705
  * @return {boolean} */
2576
2706
  collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
2577
- /** Return the center of first tile hit, undefined if nothing was hit.
2578
- * This does not return the exact intersection, but the center of the tile hit.
2707
+ /** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
2708
+ * The point will be inside the colliding tile if it hits (may have a tiny shift)
2579
2709
  * @param {Vector2} posStart
2580
2710
  * @param {Vector2} posEnd
2581
- * @param {EngineObject} [object]
2582
- * @return {Vector2} */
2583
- collisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject): Vector2;
2711
+ * @param {EngineObject} [object] - An object or undefined for generic test
2712
+ * @param {Vector2} [normal] - Optional normal of the surface hit
2713
+ * @return {Vector2|undefined} */
2714
+ collisionRaycast(posStart: Vector2, posEnd: Vector2, object?: EngineObject, normal?: Vector2): Vector2 | undefined;
2584
2715
  }
2585
2716
  /**
2586
2717
  * LittleJS Particle System
@@ -2685,6 +2816,10 @@ declare module "littlejsengine" {
2685
2816
  particleCreateCallback: any;
2686
2817
  /** @property {number} - Track particle emit time */
2687
2818
  emitTimeBuffer: number;
2819
+ /** @property {number} - Percentage of velocity to pass to particles (0-1) */
2820
+ velocityInheritance: number;
2821
+ previousAngle: number;
2822
+ previousPos: Vector2;
2688
2823
  /** Spawn one particle
2689
2824
  * @return {Particle} */
2690
2825
  emitParticle(): Particle;
@@ -3018,11 +3153,11 @@ declare module "littlejsengine" {
3018
3153
  /** Draw a rectangle to the UI context
3019
3154
  * @param {Vector2} pos
3020
3155
  * @param {Vector2} size
3021
- * @param {Color} [color=uiSystem.defaultColor]
3022
- * @param {number} [lineWidth=uiSystem.defaultLineWidth]
3023
- * @param {Color} [lineColor=uiSystem.defaultLineColor]
3024
- * @param {number} [cornerRadius=uiSystem.defaultCornerRadius]
3025
- * @param {Color} [gradientColor=uiSystem.defaultGradientColor] */
3156
+ * @param {Color} [color]
3157
+ * @param {number} [lineWidth]
3158
+ * @param {Color} [lineColor]
3159
+ * @param {number} [cornerRadius]
3160
+ * @param {Color} [gradientColor] */
3026
3161
  drawRect(pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, cornerRadius?: number, gradientColor?: Color): void;
3027
3162
  /** Draw a line to the UI context
3028
3163
  * @param {Vector2} posA
@@ -3048,8 +3183,10 @@ declare module "littlejsengine" {
3048
3183
  * @param {string} [align]
3049
3184
  * @param {string} [font=uiSystem.defaultFont]
3050
3185
  * @param {string} [fontStyle]
3051
- * @param {boolean} [applyMaxWidth=true] */
3052
- drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean): void;
3186
+ * @param {boolean} [applyMaxWidth=true]
3187
+ * @param {Vector2} [textShadow]
3188
+ */
3189
+ drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean, textShadow?: Vector2): void;
3053
3190
  /**
3054
3191
  * @callback DragAndDropCallback - Callback for drag and drop events
3055
3192
  * @param {DragEvent} event - The drag event
@@ -3062,6 +3199,11 @@ declare module "littlejsengine" {
3062
3199
  * @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
3063
3200
  * @param {DragAndDropCallback} [onDragOver] - continously when dragging over */
3064
3201
  setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
3202
+ /** Convert a screen space position to native UI position
3203
+ * @param {Vector2} pos
3204
+ * @return {Vector2}
3205
+ */
3206
+ screenToNative(pos: Vector2): Vector2;
3065
3207
  }
3066
3208
  /**
3067
3209
  * UI Object - Base level object for all UI elements
@@ -3130,6 +3272,8 @@ declare module "littlejsengine" {
3130
3272
  dragActivate: boolean;
3131
3273
  /** @property {boolean} - True if this can be a hover object */
3132
3274
  canBeHover: boolean;
3275
+ /** @property {Vector2} - How much to offset the text shadow or undefined */
3276
+ textShadow: any;
3133
3277
  /** Add a child UIObject to this object
3134
3278
  * @param {UIObject} child
3135
3279
  */
@@ -3156,6 +3300,8 @@ declare module "littlejsengine" {
3156
3300
  isHoverObject(): boolean;
3157
3301
  /** @return {boolean} - Is the mouse held onto this element */
3158
3302
  isActiveObject(): boolean;
3303
+ /** Called each frame when object updates */
3304
+ onUpdate(): void;
3159
3305
  /** Called when the mouse enters the object */
3160
3306
  onEnter(): void;
3161
3307
  /** Called when the mouse leaves the object */
@@ -3265,9 +3411,9 @@ declare module "littlejsengine" {
3265
3411
  /**
3266
3412
  * LittleJS Box2D Physics Plugin
3267
3413
  * - Box2dObject extends EngineObject with Box2D physics
3268
- * - Call box2dInit() before engineInit() to enable
3414
+ * - Call box2dInit() to enable
3269
3415
  * - You will also need to include box2d.wasm.js
3270
- * - Uses a super fast web assembly port of Box2D
3416
+ * - Uses a super fast web assembly port of Box2D v2.3.1
3271
3417
  * - More info: https://github.com/kripken/box2d.js
3272
3418
  * - Functions to create polygon, circle, and edge shapes
3273
3419
  * - Contact begin and end callbacks
@@ -3307,6 +3453,7 @@ declare module "littlejsengine" {
3307
3453
  constructor(instance: any);
3308
3454
  instance: any;
3309
3455
  world: any;
3456
+ objects: any[];
3310
3457
  /** @property {number} - Velocity iterations per update*/
3311
3458
  velocityIterations: number;
3312
3459
  /** @property {number} - Position iterations per update*/
@@ -3362,7 +3509,7 @@ declare module "littlejsengine" {
3362
3509
  vec2From(v: any): Vector2;
3363
3510
  /** converts a box2d vec2 pointer to a Vector2
3364
3511
  * @param {Object} v */
3365
- vec2FromPointer(v: any): Vector2;
3512
+ vec2FromPointer(vp: any): Vector2;
3366
3513
  /** converts a Vector2 to a box2 vec2
3367
3514
  * @param {Vector2} v */
3368
3515
  vec2dTo(v: Vector2): any;
@@ -3375,9 +3522,9 @@ declare module "littlejsengine" {
3375
3522
  }
3376
3523
  /**
3377
3524
  * Box2D Object - extend with your own custom physics objects
3378
- * - A LittleJS object with Box2D physics
3379
- * - Each object has a Box2D body which can have multiple fixtures and joints
3525
+ * - A LittleJS object with Box2D physics, dynamic by default
3380
3526
  * - Provides interface for Box2D body and fixture functions
3527
+ * - Each object can have multiple fixtures and joints
3381
3528
  * @extends EngineObject
3382
3529
  * @memberof Box2D
3383
3530
  */
@@ -3393,6 +3540,8 @@ declare module "littlejsengine" {
3393
3540
  constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, bodyType?: number, renderOrder?: number);
3394
3541
  body: any;
3395
3542
  lineColor: Color;
3543
+ edgeLists: any[];
3544
+ edgeLoops: any[];
3396
3545
  /** Draws all this object's fixtures
3397
3546
  * @param {Color} [color]
3398
3547
  * @param {Color} [lineColor]
@@ -3459,20 +3608,20 @@ declare module "littlejsengine" {
3459
3608
  * @param {number} [restitution]
3460
3609
  * @param {boolean} [isSensor] */
3461
3610
  addEdge(point1: Vector2, point2: Vector2, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any;
3462
- /** Add an edge loop to the body, an edge loop connects the end points
3611
+ /** Add an edge list to the body
3463
3612
  * @param {Array<Vector2>} points
3464
3613
  * @param {number} [density]
3465
3614
  * @param {number} [friction]
3466
3615
  * @param {number} [restitution]
3467
3616
  * @param {boolean} [isSensor] */
3468
- addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
3469
- /** Add an edge list to the body
3617
+ addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
3618
+ /** Add an edge loop to the body, an edge loop connects the end points
3470
3619
  * @param {Array<Vector2>} points
3471
3620
  * @param {number} [density]
3472
3621
  * @param {number} [friction]
3473
3622
  * @param {number} [restitution]
3474
3623
  * @param {boolean} [isSensor] */
3475
- addEdgeList(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
3624
+ addEdgeLoop(points: Array<Vector2>, density?: number, friction?: number, restitution?: number, isSensor?: boolean): any[];
3476
3625
  /** Gets the center of mass
3477
3626
  * @return {Vector2} */
3478
3627
  getCenterOfMass(): Vector2;
@@ -3519,7 +3668,7 @@ declare module "littlejsengine" {
3519
3668
  /** Sets the gravity scale
3520
3669
  * @param {number} [scale] */
3521
3670
  setGravityScale(scale?: number): void;
3522
- /** Should this body be treated like a bullet for continuous collision detection?
3671
+ /** Should be like a bullet for continuous collision detection?
3523
3672
  * @param {boolean} [isBullet] */
3524
3673
  setBullet(isBullet?: boolean): void;
3525
3674
  /** Set the sleep state of the body
@@ -3582,6 +3731,36 @@ declare module "littlejsengine" {
3582
3731
  * @return {Array<Object>} */
3583
3732
  getJointList(): Array<any>;
3584
3733
  }
3734
+ /**
3735
+ * Box2D Static Object - Box2d with a static physics body
3736
+ * @extends Box2dObject
3737
+ * @memberof Box2D
3738
+ */
3739
+ export class Box2dStaticObject extends Box2dObject {
3740
+ /** Create a LittleJS object with Box2d physics
3741
+ * @param {Vector2} [pos]
3742
+ * @param {Vector2} [size]
3743
+ * @param {TileInfo} [tileInfo]
3744
+ * @param {number} [angle]
3745
+ * @param {Color} [color]
3746
+ * @param {number} [renderOrder] */
3747
+ constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
3748
+ }
3749
+ /**
3750
+ * Box2D Kiematic Object - Box2d with a kinematic physics body
3751
+ * @extends Box2dObject
3752
+ * @memberof Box2D
3753
+ */
3754
+ export class Box2dKiematicObject extends Box2dObject {
3755
+ /** Create a LittleJS object with Box2d physics
3756
+ * @param {Vector2} [pos]
3757
+ * @param {Vector2} [size]
3758
+ * @param {TileInfo} [tileInfo]
3759
+ * @param {number} [angle]
3760
+ * @param {Color} [color]
3761
+ * @param {number} [renderOrder] */
3762
+ constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
3763
+ }
3585
3764
  /**
3586
3765
  * Box2D Raycast Result
3587
3766
  * - Holds results from a box2d raycast queries