littlejsengine 1.9.0 → 1.9.1

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.
@@ -619,11 +619,11 @@ declare module "littlejs.esm" {
619
619
  * @memberof Utilities */
620
620
  export function nearestPowerOfTwo(value: number): number;
621
621
  /** Returns true if two axis aligned bounding boxes are overlapping
622
- * @param {Vector2} pointA - Center of box A
623
- * @param {Vector2} sizeA - Size of box A
624
- * @param {Vector2} pointB - Center of box B
625
- * @param {Vector2} sizeB - Size of box B
626
- * @return {Boolean} - True if overlapping
622
+ * @param {Vector2} pointA - Center of box A
623
+ * @param {Vector2} sizeA - Size of box A
624
+ * @param {Vector2} pointB - Center of box B
625
+ * @param {Vector2} sizeB - Size of box B
626
+ * @return {Boolean} - True if overlapping
627
627
  * @memberof Utilities */
628
628
  export function isOverlapping(pointA: Vector2, sizeA: Vector2, pointB: Vector2, sizeB: Vector2): boolean;
629
629
  /** Returns an oscillating wave between 0 and amplitude with frequency of 1 Hz by default
@@ -979,7 +979,7 @@ declare module "littlejs.esm" {
979
979
  * Create a tile info object
980
980
  * - This can take vecs or floats for easier use and conversion
981
981
  * - If an index is passed in, the tile size and index will determine the position
982
- * @param {(Number|Vector2)} [pos=Vector2()] - Top left corner of tile in pixels or index
982
+ * @param {(Number|Vector2)} [pos=(0,0)] - Top left corner of tile in pixels or index
983
983
  * @param {(Number|Vector2)} [size=tileSizeDefault] - Size of tile in pixels
984
984
  * @param {Number} [textureIndex] - Texture index to use
985
985
  * @return {TileInfo}
@@ -996,7 +996,7 @@ declare module "littlejs.esm" {
996
996
  */
997
997
  export class TileInfo {
998
998
  /** Create a tile info object
999
- * @param {Vector2} [pos=Vector2()] - Top left corner of tile in pixels
999
+ * @param {Vector2} [pos=(0,0)] - Top left corner of tile in pixels
1000
1000
  * @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
1001
1001
  * @param {Number} [textureIndex] - Texture index to use
1002
1002
  */
@@ -1085,25 +1085,25 @@ declare module "littlejs.esm" {
1085
1085
  * @memberof Draw */
1086
1086
  export function worldToScreen(worldPos: Vector2): Vector2;
1087
1087
  /** Draw textured tile centered in world space, with color applied if using WebGL
1088
- * @param {Vector2} pos - Center of the tile in world space
1089
- * @param {Vector2} [size=Vector2(1,1)] - Size of the tile in world space
1090
- * @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
1091
- * @param {Color} [color=Color()] - Color to modulate with
1092
- * @param {Number} [angle] - Angle to rotate by
1093
- * @param {Boolean} [mirror] - If true image is flipped along the Y axis
1094
- * @param {Color} [additiveColor=Color(0,0,0,0)] - Additive color to be applied
1095
- * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
1096
- * @param {Boolean} [screenSpace] - If true the pos and size are in screen space
1097
- * @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
1088
+ * @param {Vector2} pos - Center of the tile in world space
1089
+ * @param {Vector2} [size=(1,1)] - Size of the tile in world space
1090
+ * @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
1091
+ * @param {Color} [color=(1,1,1,1)] - Color to modulate with
1092
+ * @param {Number} [angle] - Angle to rotate by
1093
+ * @param {Boolean} [mirror] - If true image is flipped along the Y axis
1094
+ * @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
1095
+ * @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
1096
+ * @param {Boolean} [screenSpace=false] - If true the pos and size are in screen space
1097
+ * @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
1098
1098
  * @memberof Draw */
1099
1099
  export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
1100
1100
  /** Draw colored rect centered on pos
1101
1101
  * @param {Vector2} pos
1102
- * @param {Vector2} [size=Vector2(1,1)]
1103
- * @param {Color} [color=Color()]
1102
+ * @param {Vector2} [size=(1,1)]
1103
+ * @param {Color} [color=(1,1,1,1)]
1104
1104
  * @param {Number} [angle]
1105
1105
  * @param {Boolean} [useWebGL=glEnable]
1106
- * @param {Boolean} [screenSpace]
1106
+ * @param {Boolean} [screenSpace=false]
1107
1107
  * @param {CanvasRenderingContext2D} [context]
1108
1108
  * @memberof Draw */
1109
1109
  export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
@@ -1111,9 +1111,9 @@ declare module "littlejs.esm" {
1111
1111
  * @param {Vector2} posA
1112
1112
  * @param {Vector2} posB
1113
1113
  * @param {Number} [thickness]
1114
- * @param {Color} [color=Color()]
1114
+ * @param {Color} [color=(1,1,1,1)]
1115
1115
  * @param {Boolean} [useWebGL=glEnable]
1116
- * @param {Boolean} [screenSpace]
1116
+ * @param {Boolean} [screenSpace=false]
1117
1117
  * @param {CanvasRenderingContext2D} [context]
1118
1118
  * @memberof Draw */
1119
1119
  export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
@@ -1123,7 +1123,7 @@ declare module "littlejs.esm" {
1123
1123
  * @param {Number} angle
1124
1124
  * @param {Boolean} mirror
1125
1125
  * @param {Function} drawFunction
1126
- * @param {Boolean} [screenSpace]
1126
+ * @param {Boolean} [screenSpace=false]
1127
1127
  * @param {CanvasRenderingContext2D} [context=mainContext]
1128
1128
  * @memberof Draw */
1129
1129
  export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
@@ -1138,9 +1138,9 @@ declare module "littlejs.esm" {
1138
1138
  * @param {String} text
1139
1139
  * @param {Vector2} pos
1140
1140
  * @param {Number} [size]
1141
- * @param {Color} [color=Color()]
1141
+ * @param {Color} [color=(1,1,1,1)]
1142
1142
  * @param {Number} [lineWidth]
1143
- * @param {Color} [lineColor=Color(0,0,0)]
1143
+ * @param {Color} [lineColor=(0,0,0,1)]
1144
1144
  * @param {CanvasTextAlign} [textAlign]
1145
1145
  * @param {String} [font=fontDefault]
1146
1146
  * @param {CanvasRenderingContext2D} [context=overlayContext]
@@ -1151,9 +1151,9 @@ declare module "littlejs.esm" {
1151
1151
  * @param {String} text
1152
1152
  * @param {Vector2} pos
1153
1153
  * @param {Number} [size]
1154
- * @param {Color} [color=Color()]
1154
+ * @param {Color} [color=(1,1,1,1)]
1155
1155
  * @param {Number} [lineWidth]
1156
- * @param {Color} [lineColor=Color(0,0,0)]
1156
+ * @param {Color} [lineColor=(0,0,0,1)]
1157
1157
  * @param {CanvasTextAlign} [textAlign='center']
1158
1158
  * @param {String} [font=fontDefault]
1159
1159
  * @param {CanvasRenderingContext2D} [context=overlayContext]
@@ -1174,9 +1174,9 @@ declare module "littlejs.esm" {
1174
1174
  */
1175
1175
  export class FontImage {
1176
1176
  /** Create an image font
1177
- * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
1178
- * @param {Vector2} [tileSize=Vector2(8)] - Size of the font source tiles
1179
- * @param {Vector2} [paddingSize=Vector2(0,1)] - How much extra space to add between characters
1177
+ * @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
1178
+ * @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
1179
+ * @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
1180
1180
  * @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
1181
1181
  */
1182
1182
  constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D);
@@ -1251,7 +1251,7 @@ declare module "littlejs.esm" {
1251
1251
  * @param {String} shaderCode
1252
1252
  * @param {Boolean} includeOverlay
1253
1253
  * @memberof WebGL */
1254
- export function glInitPostProcess(shaderCode: string, includeOverlay: boolean): void;
1254
+ export function glInitPostProcess(shaderCode: string, includeOverlay?: boolean): void;
1255
1255
  /**
1256
1256
  * LittleJS Input System
1257
1257
  * - Tracks keyboard down, pressed, and released
@@ -1354,9 +1354,9 @@ declare module "littlejs.esm" {
1354
1354
  export function mouseToScreen(mousePos: any): Vector2;
1355
1355
  export function gamepadsUpdate(): void;
1356
1356
  /** Pulse the vibration hardware if it exists
1357
- * @param {Number} [pattern] - a single value in miliseconds or vibration interval array
1357
+ * @param {Number|Array} [pattern] - single value in ms or vibration interval array
1358
1358
  * @memberof Input */
1359
- export function vibrate(pattern?: number): void;
1359
+ export function vibrate(pattern?: number | any[]): void;
1360
1360
  /** Cancel any ongoing vibration
1361
1361
  * @memberof Input */
1362
1362
  export function vibrateStop(): void;
@@ -1569,12 +1569,12 @@ declare module "littlejs.esm" {
1569
1569
  */
1570
1570
  export class EngineObject {
1571
1571
  /** Create an engine object and adds it to the list of objects
1572
- * @param {Vector2} [pos=Vector2()] - World space position of the object
1573
- * @param {Vector2} [size=Vector2(1,1)] - World space size of the object
1574
- * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
1575
- * @param {Number} [angle] - Angle the object is rotated by
1576
- * @param {Color} [color=Color()] - Color to apply to tile when rendered
1577
- * @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
1572
+ * @param {Vector2} [pos=(0,0)] - World space position of the object
1573
+ * @param {Vector2} [size=(1,1)] - World space size of the object
1574
+ * @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
1575
+ * @param {Number} [angle] - Angle the object is rotated by
1576
+ * @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
1577
+ * @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
1578
1578
  */
1579
1579
  constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
1580
1580
  /** @property {Vector2} - World space position of the object */
@@ -1664,7 +1664,7 @@ declare module "littlejs.esm" {
1664
1664
  getMirrorSign(): number;
1665
1665
  /** Attaches a child to this with a given local transform
1666
1666
  * @param {EngineObject} child
1667
- * @param {Vector2} [localPos=Vector2()]
1667
+ * @param {Vector2} [localPos=(0,0)]
1668
1668
  * @param {Number} [localAngle] */
1669
1669
  addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
1670
1670
  /** Removes a child from this one
@@ -1714,7 +1714,7 @@ declare module "littlejs.esm" {
1714
1714
  export function getTileCollisionData(pos: Vector2): number;
1715
1715
  /** Check if collision with another object should occur
1716
1716
  * @param {Vector2} pos
1717
- * @param {Vector2} [size=Vector2(1,1)]
1717
+ * @param {Vector2} [size=(1,1)]
1718
1718
  * @param {EngineObject} [object]
1719
1719
  * @return {Boolean}
1720
1720
  * @memberof TileCollision */
@@ -1768,11 +1768,11 @@ declare module "littlejs.esm" {
1768
1768
  */
1769
1769
  export class TileLayer extends EngineObject {
1770
1770
  /** Create a tile layer object
1771
- * @param {Vector2} [position=Vector2()] - World space position
1771
+ * @param {Vector2} [position=(0,0)] - World space position
1772
1772
  * @param {Vector2} [size=tileCollisionSize] - World space size
1773
- * @param {TileInfo} [tileInfo] - Tile info for layer
1774
- * @param {Vector2} [scale=Vector2(1,1)] - How much to scale this layer when rendered
1775
- * @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
1773
+ * @param {TileInfo} [tileInfo] - Tile info for layer
1774
+ * @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
1775
+ * @param {Number} [renderOrder] - Objects are sorted by renderOrder
1776
1776
  */
1777
1777
  constructor(position?: Vector2, size?: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number);
1778
1778
  /** @property {HTMLCanvasElement} - The canvas used by this tile layer */
@@ -1794,21 +1794,23 @@ declare module "littlejs.esm" {
1794
1794
  * @return {TileLayerData} */
1795
1795
  getData(layerPos: Vector2): TileLayerData;
1796
1796
  /** Draw all the tile data to an offscreen canvas
1797
- * - This may be slow in some browsers
1798
- */
1797
+ * - This may be slow in some browsers but only needs to be done once */
1799
1798
  redraw(): void;
1800
1799
  /** Call to start the redraw process
1800
+ * - This can be used to manually update small parts of the level
1801
1801
  * @param {Boolean} [clear] - Should it clear the canvas before drawing */
1802
1802
  redrawStart(clear?: boolean): void;
1803
1803
  /** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
1804
1804
  savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
1805
1805
  /** Call to end the redraw process */
1806
1806
  redrawEnd(): void;
1807
- /** Draw the tile at a given position
1808
- * @param {Vector2} layerPos */
1809
- drawTileData(layerPos: Vector2): void;
1810
- /** Draw all the tiles in this layer */
1811
- drawAllTileData(): void;
1807
+ /** Draw the tile at a given position in the tile grid
1808
+ * This can be used to clear out tiles when they are destroyed
1809
+ * Tiles can also be redrawn if isinde a redrawStart/End block
1810
+ * @param {Vector2} layerPos
1811
+ * @param {Boolean} [clear] - should the old tile be cleared out
1812
+ */
1813
+ drawTileData(layerPos: Vector2, clear?: boolean): void;
1812
1814
  /** Draw directly to the 2D canvas in world space (bipass webgl)
1813
1815
  * @param {Vector2} pos
1814
1816
  * @param {Vector2} size
@@ -1816,18 +1818,18 @@ declare module "littlejs.esm" {
1816
1818
  * @param {Boolean} mirror
1817
1819
  * @param {Function} drawFunction */
1818
1820
  drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
1819
- /** Draw a tile directly onto the layer canvas
1821
+ /** Draw a tile directly onto the layer canvas in world space
1820
1822
  * @param {Vector2} pos
1821
- * @param {Vector2} [size=Vector2(1,1)]
1823
+ * @param {Vector2} [size=(1,1)]
1822
1824
  * @param {TileInfo} [tileInfo]
1823
- * @param {Color} [color=Color()]
1825
+ * @param {Color} [color=(1,1,1,1)]
1824
1826
  * @param {Number} [angle=0]
1825
1827
  * @param {Boolean} [mirror=0] */
1826
1828
  drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
1827
- /** Draw a rectangle directly onto the layer canvas
1829
+ /** Draw a rectangle directly onto the layer canvas in world space
1828
1830
  * @param {Vector2} pos
1829
- * @param {Vector2} [size=Vector2(1,1)]
1830
- * @param {Color} [color=Color()]
1831
+ * @param {Vector2} [size=(1,1)]
1832
+ * @param {Color} [color=(1,1,1,1)]
1831
1833
  * @param {Number} [angle=0] */
1832
1834
  drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
1833
1835
  }
@@ -1860,10 +1862,10 @@ declare module "littlejs.esm" {
1860
1862
  * @param {Number} [emitRate] - How many particles per second to spawn, does not emit if 0
1861
1863
  * @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
1862
1864
  * @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
1863
- * @param {Color} [colorStartA=Color()] - Color at start of life 1, randomized between start colors
1864
- * @param {Color} [colorStartB=Color()] - Color at start of life 2, randomized between start colors
1865
- * @param {Color} [colorEndA=Color(1,1,1,0)] - Color at end of life 1, randomized between end colors
1866
- * @param {Color} [colorEndB=Color(1,1,1,0)] - Color at end of life 2, randomized between end colors
1865
+ * @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
1866
+ * @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
1867
+ * @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
1868
+ * @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
1867
1869
  * @param {Number} [particleTime] - How long particles live
1868
1870
  * @param {Number} [sizeStart] - How big are particles at start
1869
1871
  * @param {Number} [sizeEnd] - How big are particles at end