littlejsengine 1.16.2 → 1.17.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.
- package/dist/littlejs.d.ts +200 -166
- package/dist/littlejs.esm.js +1231 -1086
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +888 -735
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +884 -731
- package/examples/box2d/gameObjects.js +1 -1
- package/examples/breakout/game.js +5 -6
- package/examples/electron/index.html +2 -2
- package/examples/electron/tiles.png +0 -0
- package/examples/htmlMenu/tiles.png +0 -0
- package/examples/index.html +1 -1
- package/examples/logo.png +0 -0
- package/examples/module/tiles.png +0 -0
- package/examples/platformer/gameEffects.js +23 -22
- package/examples/platformer/gameLevel.js +24 -25
- package/examples/shorts/base.html +1 -1
- package/examples/shorts/clock.js +3 -3
- package/examples/shorts/fontImage.js +4 -3
- package/examples/shorts/parallax.js +1 -1
- package/examples/shorts/sequencer.js +1 -1
- package/examples/shorts/shapes.js +1 -1
- package/examples/shorts/texture.js +10 -6
- package/examples/shorts/tiles.png +0 -0
- package/examples/shorts/tiltedView.js +2 -0
- package/examples/starter/index.html +2 -2
- package/examples/starter/tiles.png +0 -0
- package/examples/typescript/tiles.png +0 -0
- package/examples/uiSystem/game.js +1 -1
- package/examples/uiSystem/tiles.png +0 -0
- package/package.json +1 -1
- package/plugins/postProcess.js +47 -28
- package/plugins/uiSystem.js +15 -15
- package/reference.md +1 -1
- package/src/engine.js +174 -174
- package/src/engineAudio.js +4 -6
- package/src/engineDebug.js +4 -4
- package/src/engineDraw.js +179 -122
- package/src/engineExport.js +326 -334
- package/src/engineFont.png +0 -0
- package/src/engineInput.js +14 -20
- package/src/engineMath.js +15 -104
- package/src/engineObject.js +26 -25
- package/src/engineParticles.js +2 -2
- package/src/engineTileLayer.js +196 -170
- package/src/engineUtilities.js +100 -4
- package/src/engineWebGL.js +123 -72
package/dist/littlejs.d.ts
CHANGED
|
@@ -212,7 +212,7 @@ declare module "littlejsengine" {
|
|
|
212
212
|
export function LOG(...output?: any[]): void;
|
|
213
213
|
/** Draw a debug rectangle in world space
|
|
214
214
|
* @param {Vector2} pos
|
|
215
|
-
* @param {Vector2} [size=
|
|
215
|
+
* @param {Vector2} [size=vec2(0)]
|
|
216
216
|
* @param {Color|string} [color]
|
|
217
217
|
* @param {number} [time]
|
|
218
218
|
* @param {number} [angle]
|
|
@@ -721,12 +721,11 @@ declare module "littlejsengine" {
|
|
|
721
721
|
* @memberof Debug */
|
|
722
722
|
export function setDebugKey(key: string): void;
|
|
723
723
|
/**
|
|
724
|
-
* LittleJS
|
|
724
|
+
* LittleJS Math Classes and Functions
|
|
725
725
|
* - General purpose math library
|
|
726
|
-
* - Vector2 - fast, simple, easy 2D vector class
|
|
727
|
-
* - Color - holds a rgba color with some math functions
|
|
728
|
-
* - Timer - tracks time automatically
|
|
729
726
|
* - RandomGenerator - seeded random number generator
|
|
727
|
+
* - Vector2 - fast, simple, easy 2D vector class
|
|
728
|
+
* - Color - holds a rgba color with math functions
|
|
730
729
|
* @namespace Math
|
|
731
730
|
*/
|
|
732
731
|
/** The value of PI
|
|
@@ -867,11 +866,11 @@ declare module "littlejsengine" {
|
|
|
867
866
|
export function nearestPowerOfTwo(value: number): number;
|
|
868
867
|
/** Returns true if two axis aligned bounding boxes are overlapping
|
|
869
868
|
* this can be used for simple collision detection between objects
|
|
870
|
-
* @param {Vector2} posA
|
|
871
|
-
* @param {Vector2} sizeA
|
|
872
|
-
* @param {Vector2} posB
|
|
873
|
-
* @param {Vector2} [sizeB=(
|
|
874
|
-
* @return {boolean}
|
|
869
|
+
* @param {Vector2} posA - Center of box A
|
|
870
|
+
* @param {Vector2} sizeA - Size of box A
|
|
871
|
+
* @param {Vector2} posB - Center of box B
|
|
872
|
+
* @param {Vector2} [sizeB=vec2()] - Size of box B, uses a point if undefined
|
|
873
|
+
* @return {boolean} - True if overlapping
|
|
875
874
|
* @memberof Math */
|
|
876
875
|
export function isOverlapping(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB?: Vector2): boolean;
|
|
877
876
|
/** Returns true if a line segment is intersecting an axis aligned box
|
|
@@ -892,11 +891,8 @@ declare module "littlejsengine" {
|
|
|
892
891
|
export function wave(frequency?: number, amplitude?: number, t?: number, offset?: number): number;
|
|
893
892
|
/**
|
|
894
893
|
* LittleJS Utility Classes and Functions
|
|
895
|
-
* - General purpose
|
|
896
|
-
* - Vector2 - fast, simple, easy 2D vector class
|
|
897
|
-
* - Color - holds a rgba color with some math functions
|
|
894
|
+
* - General purpose utilities
|
|
898
895
|
* - Timer - tracks time automatically
|
|
899
|
-
* - RandomGenerator - seeded random number generator
|
|
900
896
|
* @namespace Utilities
|
|
901
897
|
*/
|
|
902
898
|
/** Formats seconds to mm:ss style for display purposes
|
|
@@ -927,6 +923,12 @@ declare module "littlejsengine" {
|
|
|
927
923
|
* @param {number} [revokeTime] - how long before revoking the url
|
|
928
924
|
* @memberof Utilities */
|
|
929
925
|
export function saveDataURL(url: string, filename?: string, revokeTime?: number): void;
|
|
926
|
+
/** Share content using the native share dialog if available
|
|
927
|
+
* @param {string} title - title of the share
|
|
928
|
+
* @param {string} url - url to share
|
|
929
|
+
* @param {Function} [callback] - Called when share is complete
|
|
930
|
+
* @memberof Utilities */
|
|
931
|
+
export function shareURL(title: string, url: string, callback?: Function): void;
|
|
930
932
|
/** Random global functions
|
|
931
933
|
* @namespace Random */
|
|
932
934
|
/** Returns a random value between the two values passed in
|
|
@@ -963,8 +965,8 @@ declare module "littlejsengine" {
|
|
|
963
965
|
* @memberof Random */
|
|
964
966
|
export function randVec2(length?: number): Vector2;
|
|
965
967
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
966
|
-
* @param {Color} [colorA=
|
|
967
|
-
* @param {Color} [colorB=
|
|
968
|
+
* @param {Color} [colorA=WHITE]
|
|
969
|
+
* @param {Color} [colorB=BLACK]
|
|
968
970
|
* @param {boolean} [linear]
|
|
969
971
|
* @return {Color}
|
|
970
972
|
* @memberof Random */
|
|
@@ -1017,8 +1019,8 @@ declare module "littlejsengine" {
|
|
|
1017
1019
|
* @return {Vector2} */
|
|
1018
1020
|
vec2(valueA?: number, valueB?: number): Vector2;
|
|
1019
1021
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
1020
|
-
* @param {Color} [colorA=
|
|
1021
|
-
* @param {Color} [colorB=
|
|
1022
|
+
* @param {Color} [colorA=WHITE]
|
|
1023
|
+
* @param {Color} [colorB=BLACK]
|
|
1022
1024
|
* @param {boolean} [linear]
|
|
1023
1025
|
* @return {Color} */
|
|
1024
1026
|
randColor(colorA?: Color, colorB?: Color, linear?: boolean): Color;
|
|
@@ -1148,9 +1150,6 @@ declare module "littlejsengine" {
|
|
|
1148
1150
|
/** Returns the area this vector covers as a rectangle
|
|
1149
1151
|
* @return {number} */
|
|
1150
1152
|
area(): number;
|
|
1151
|
-
/** Returns true if this vector is (0,0)
|
|
1152
|
-
* @return {boolean} */
|
|
1153
|
-
isZero(): boolean;
|
|
1154
1153
|
/** Returns a new vector that is p percent between this and the vector passed in
|
|
1155
1154
|
* @param {Vector2} v - other vector
|
|
1156
1155
|
* @param {number} percent
|
|
@@ -1436,10 +1435,11 @@ declare module "littlejsengine" {
|
|
|
1436
1435
|
* Create a tile info object using a grid based system
|
|
1437
1436
|
* - This can take vecs or floats for easier use and conversion
|
|
1438
1437
|
* - If an index is passed in, the tile size and index will determine the position
|
|
1439
|
-
* @param {Vector2|number} [
|
|
1438
|
+
* @param {Vector2|number} [index=0] - Index of the tile in 1d or 2d form
|
|
1440
1439
|
* @param {Vector2|number} [size] - Size of tile in pixels
|
|
1441
|
-
* @param {number} [
|
|
1440
|
+
* @param {TextureInfo|number} [texture] - Texture index or info to use
|
|
1442
1441
|
* @param {number} [padding] - How many pixels padding around tiles
|
|
1442
|
+
* @param {number} [bleed] - How many pixels smaller to draw tiles
|
|
1443
1443
|
* @return {TileInfo}
|
|
1444
1444
|
* @example
|
|
1445
1445
|
* tile(2) // a tile at index 2 using the default tile size of 16
|
|
@@ -1447,26 +1447,24 @@ declare module "littlejsengine" {
|
|
|
1447
1447
|
* tile(1, 16, 3) // a tile at index 1 of size 16 on texture 3
|
|
1448
1448
|
* tile(vec2(4,8), vec2(30,10)) // a tile at index (4,8) with a size of (30,10)
|
|
1449
1449
|
* @memberof Draw */
|
|
1450
|
-
export function tile(
|
|
1450
|
+
export function tile(index?: Vector2 | number, size?: Vector2 | number, texture?: TextureInfo | number, padding?: number, bleed?: number): TileInfo;
|
|
1451
1451
|
/**
|
|
1452
1452
|
* Tile Info - Stores info about how to draw a tile
|
|
1453
1453
|
* @memberof Draw
|
|
1454
1454
|
*/
|
|
1455
1455
|
export class TileInfo {
|
|
1456
1456
|
/** Create a tile info object
|
|
1457
|
-
* @param {Vector2} [pos=(
|
|
1457
|
+
* @param {Vector2} [pos=vec2()] - Top left corner of tile in pixels
|
|
1458
1458
|
* @param {Vector2} [size] - Size of tile in pixels
|
|
1459
|
-
* @param {
|
|
1460
|
-
* @param {number}
|
|
1461
|
-
* @param {number}
|
|
1459
|
+
* @param {TextureInfo} [textureInfo] - Texture info to use
|
|
1460
|
+
* @param {number} [padding] - How many pixels padding around tiles
|
|
1461
|
+
* @param {number} [bleed] - How many pixels smaller to draw tiles
|
|
1462
1462
|
*/
|
|
1463
|
-
constructor(pos?: Vector2, size?: Vector2,
|
|
1463
|
+
constructor(pos?: Vector2, size?: Vector2, textureInfo?: TextureInfo, padding?: number, bleed?: number);
|
|
1464
1464
|
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
1465
1465
|
pos: Vector2;
|
|
1466
1466
|
/** @property {Vector2} - Size of tile in pixels */
|
|
1467
1467
|
size: Vector2;
|
|
1468
|
-
/** @property {number} - Texture index to use */
|
|
1469
|
-
textureIndex: number;
|
|
1470
1468
|
/** @property {number} - How many pixels padding around tiles */
|
|
1471
1469
|
padding: number;
|
|
1472
1470
|
/** @property {TextureInfo} - The texture info for this tile */
|
|
@@ -1485,10 +1483,16 @@ declare module "littlejsengine" {
|
|
|
1485
1483
|
frame(frame: number): TileInfo;
|
|
1486
1484
|
/**
|
|
1487
1485
|
* Set this tile to use a full image in a texture info
|
|
1488
|
-
* @param {TextureInfo} textureInfo
|
|
1486
|
+
* @param {TextureInfo} [textureInfo]
|
|
1487
|
+
* @return {TileInfo}
|
|
1488
|
+
*/
|
|
1489
|
+
setFullImage(textureInfo?: TextureInfo): TileInfo;
|
|
1490
|
+
/**
|
|
1491
|
+
* Returns a tile info for an index using this tile as refrence
|
|
1492
|
+
* @param {Vector2|number} [index=0]
|
|
1489
1493
|
* @return {TileInfo}
|
|
1490
1494
|
*/
|
|
1491
|
-
|
|
1495
|
+
tile(index?: Vector2 | number): TileInfo;
|
|
1492
1496
|
}
|
|
1493
1497
|
/**
|
|
1494
1498
|
* Tile Info - Stores info about each texture
|
|
@@ -1604,14 +1608,14 @@ declare module "littlejsengine" {
|
|
|
1604
1608
|
* @return {[Vector2, Vector2, number]} - [pos, size, angle]
|
|
1605
1609
|
* @memberof Draw */
|
|
1606
1610
|
export function screenToWorldTransform(screenPos: Vector2, screenSize: Vector2, screenAngle?: number): [Vector2, Vector2, number];
|
|
1607
|
-
/** Draw textured tile centered in world space
|
|
1608
|
-
* @param {Vector2} pos
|
|
1609
|
-
* @param {Vector2} [size=(1
|
|
1610
|
-
* @param {TileInfo} [tileInfo]
|
|
1611
|
-
* @param {Color} [color=
|
|
1612
|
-
* @param {number} [angle]
|
|
1613
|
-
* @param {boolean} [mirror]
|
|
1614
|
-
* @param {Color} [additiveColor]
|
|
1611
|
+
/** Draw textured tile centered in world space
|
|
1612
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
1613
|
+
* @param {Vector2} [size=vec2(1)] - Size of the tile in world space
|
|
1614
|
+
* @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
|
|
1615
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
1616
|
+
* @param {number} [angle] - Angle to rotate by
|
|
1617
|
+
* @param {boolean} [mirror] - Is image flipped along the Y axis?
|
|
1618
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any
|
|
1615
1619
|
* @param {boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering?
|
|
1616
1620
|
* @param {boolean} [screenSpace=false] - Are the pos and size are in screen space?
|
|
1617
1621
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
@@ -1619,8 +1623,8 @@ declare module "littlejsengine" {
|
|
|
1619
1623
|
export function drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1620
1624
|
/** Draw colored rect centered on pos
|
|
1621
1625
|
* @param {Vector2} pos
|
|
1622
|
-
* @param {Vector2} [size=(1
|
|
1623
|
-
* @param {Color} [color=
|
|
1626
|
+
* @param {Vector2} [size=vec2(1)]
|
|
1627
|
+
* @param {Color} [color=WHITE]
|
|
1624
1628
|
* @param {number} [angle]
|
|
1625
1629
|
* @param {boolean} [useWebGL=glEnable]
|
|
1626
1630
|
* @param {boolean} [screenSpace]
|
|
@@ -1629,9 +1633,9 @@ declare module "littlejsengine" {
|
|
|
1629
1633
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1630
1634
|
/** Draw a rect centered on pos with a gradient from top to bottom
|
|
1631
1635
|
* @param {Vector2} pos
|
|
1632
|
-
* @param {Vector2} [size=(1
|
|
1633
|
-
* @param {Color} [colorTop=
|
|
1634
|
-
* @param {Color} [colorBottom=
|
|
1636
|
+
* @param {Vector2} [size=vec2(1)]
|
|
1637
|
+
* @param {Color} [colorTop=WHITE]
|
|
1638
|
+
* @param {Color} [colorBottom=BLACK]
|
|
1635
1639
|
* @param {number} [angle]
|
|
1636
1640
|
* @param {boolean} [useWebGL=glEnable]
|
|
1637
1641
|
* @param {boolean} [screenSpace]
|
|
@@ -1641,9 +1645,9 @@ declare module "littlejsengine" {
|
|
|
1641
1645
|
/** Draw connected lines between a series of points
|
|
1642
1646
|
* @param {Array<Vector2>} points
|
|
1643
1647
|
* @param {number} [width]
|
|
1644
|
-
* @param {Color} [color=
|
|
1648
|
+
* @param {Color} [color=WHITE]
|
|
1645
1649
|
* @param {boolean} [wrap] - Should the last point connect to the first?
|
|
1646
|
-
* @param {Vector2} [pos=(
|
|
1650
|
+
* @param {Vector2} [pos=vec2()] - Offset to apply
|
|
1647
1651
|
* @param {number} [angle] - Angle to rotate by
|
|
1648
1652
|
* @param {boolean} [useWebGL=glEnable]
|
|
1649
1653
|
* @param {boolean} [screenSpace]
|
|
@@ -1654,8 +1658,8 @@ declare module "littlejsengine" {
|
|
|
1654
1658
|
* @param {Vector2} posA
|
|
1655
1659
|
* @param {Vector2} posB
|
|
1656
1660
|
* @param {number} [width]
|
|
1657
|
-
* @param {Color} [color=
|
|
1658
|
-
* @param {Vector2} [pos=(
|
|
1661
|
+
* @param {Color} [color=WHITE]
|
|
1662
|
+
* @param {Vector2} [pos=vec2()] - Offset to apply
|
|
1659
1663
|
* @param {number} [angle] - Angle to rotate by
|
|
1660
1664
|
* @param {boolean} [useWebGL=glEnable]
|
|
1661
1665
|
* @param {boolean} [screenSpace]
|
|
@@ -1664,10 +1668,10 @@ declare module "littlejsengine" {
|
|
|
1664
1668
|
export function drawLine(posA: Vector2, posB: Vector2, width?: number, color?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1665
1669
|
/** Draw colored polygon using passed in points
|
|
1666
1670
|
* @param {Array<Vector2>} points - Array of Vector2 points
|
|
1667
|
-
* @param {Color} [color=
|
|
1671
|
+
* @param {Color} [color=WHITE]
|
|
1668
1672
|
* @param {number} [lineWidth]
|
|
1669
|
-
* @param {Color} [lineColor=
|
|
1670
|
-
* @param {Vector2} [pos=(
|
|
1673
|
+
* @param {Color} [lineColor=BLACK]
|
|
1674
|
+
* @param {Vector2} [pos=vec2()] - Offset to apply
|
|
1671
1675
|
* @param {number} [angle] - Angle to rotate by
|
|
1672
1676
|
* @param {boolean} [useWebGL=glEnable]
|
|
1673
1677
|
* @param {boolean} [screenSpace]
|
|
@@ -1676,11 +1680,11 @@ declare module "littlejsengine" {
|
|
|
1676
1680
|
export function drawPoly(points: Array<Vector2>, color?: Color, lineWidth?: number, lineColor?: Color, pos?: Vector2, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1677
1681
|
/** Draw colored ellipse using passed in point
|
|
1678
1682
|
* @param {Vector2} pos
|
|
1679
|
-
* @param {Vector2} [size=(1
|
|
1680
|
-
* @param {Color} [color=
|
|
1683
|
+
* @param {Vector2} [size=vec2(1)] - Width and height diameter
|
|
1684
|
+
* @param {Color} [color=WHITE]
|
|
1681
1685
|
* @param {number} [angle]
|
|
1682
1686
|
* @param {number} [lineWidth]
|
|
1683
|
-
* @param {Color} [lineColor=
|
|
1687
|
+
* @param {Color} [lineColor=BLACK]
|
|
1684
1688
|
* @param {boolean} [useWebGL=glEnable]
|
|
1685
1689
|
* @param {boolean} [screenSpace]
|
|
1686
1690
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1689,9 +1693,9 @@ declare module "littlejsengine" {
|
|
|
1689
1693
|
/** Draw colored circle using passed in point
|
|
1690
1694
|
* @param {Vector2} pos
|
|
1691
1695
|
* @param {number} [size=1] - Diameter
|
|
1692
|
-
* @param {Color} [color=
|
|
1696
|
+
* @param {Color} [color=WHITE]
|
|
1693
1697
|
* @param {number} [lineWidth=0]
|
|
1694
|
-
* @param {Color} [lineColor=
|
|
1698
|
+
* @param {Color} [lineColor=BLACK]
|
|
1695
1699
|
* @param {boolean} [useWebGL=glEnable]
|
|
1696
1700
|
* @param {boolean} [screenSpace]
|
|
1697
1701
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1717,9 +1721,9 @@ declare module "littlejsengine" {
|
|
|
1717
1721
|
* @param {string|number} text
|
|
1718
1722
|
* @param {Vector2} pos
|
|
1719
1723
|
* @param {number} [size]
|
|
1720
|
-
* @param {Color} [color=
|
|
1724
|
+
* @param {Color} [color=WHITE]
|
|
1721
1725
|
* @param {number} [lineWidth]
|
|
1722
|
-
* @param {Color} [lineColor=
|
|
1726
|
+
* @param {Color} [lineColor=BLACK]
|
|
1723
1727
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1724
1728
|
* @param {string} [font=fontDefault]
|
|
1725
1729
|
* @param {string} [fontStyle]
|
|
@@ -1732,10 +1736,10 @@ declare module "littlejsengine" {
|
|
|
1732
1736
|
* Automatically splits new lines into rows
|
|
1733
1737
|
* @param {string|number} text
|
|
1734
1738
|
* @param {Vector2} pos
|
|
1735
|
-
* @param {number}
|
|
1736
|
-
* @param {Color} [color=
|
|
1739
|
+
* @param {number} size
|
|
1740
|
+
* @param {Color} [color=WHITE]
|
|
1737
1741
|
* @param {number} [lineWidth]
|
|
1738
|
-
* @param {Color} [lineColor=
|
|
1742
|
+
* @param {Color} [lineColor=BLACK]
|
|
1739
1743
|
* @param {CanvasTextAlign} [textAlign]
|
|
1740
1744
|
* @param {string} [font=fontDefault]
|
|
1741
1745
|
* @param {string} [fontStyle]
|
|
@@ -1743,7 +1747,7 @@ declare module "littlejsengine" {
|
|
|
1743
1747
|
* @param {number} [angle]
|
|
1744
1748
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1745
1749
|
* @memberof Draw */
|
|
1746
|
-
export function drawTextScreen(text: string | number, pos: Vector2, size
|
|
1750
|
+
export function drawTextScreen(text: string | number, pos: Vector2, size: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1747
1751
|
/** Enable normal or additive blend mode
|
|
1748
1752
|
* @param {boolean} [additive]
|
|
1749
1753
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
@@ -1753,46 +1757,52 @@ declare module "littlejsengine" {
|
|
|
1753
1757
|
* This is necessary for things like screenshots and video
|
|
1754
1758
|
* @memberof Draw */
|
|
1755
1759
|
export function combineCanvases(): void;
|
|
1756
|
-
|
|
1760
|
+
/** Engine font image, 8x8 font provided by the engine
|
|
1761
|
+
* @type {FontImage}
|
|
1762
|
+
* @memberof Draw */
|
|
1763
|
+
export let engineFontImage: FontImage;
|
|
1757
1764
|
/**
|
|
1758
|
-
* Font Image Object - Draw text
|
|
1765
|
+
* Font Image Object - Draw text by using tiles in an image
|
|
1759
1766
|
* - 96 characters (from space to tilde) are stored in an image
|
|
1760
|
-
* -
|
|
1761
|
-
* -
|
|
1767
|
+
* - A 8x8 default engine font is supplied for general use
|
|
1768
|
+
* - This system is WebGL enabled for fast text rendering
|
|
1769
|
+
* - Fonts can also be colored and scaled along each axis
|
|
1770
|
+
*
|
|
1762
1771
|
* @memberof Draw
|
|
1763
1772
|
* @example
|
|
1764
1773
|
* // use built in font
|
|
1765
|
-
* const font =
|
|
1774
|
+
* const font = engineFontImage;
|
|
1766
1775
|
*
|
|
1767
1776
|
* // draw text
|
|
1768
1777
|
* font.drawTextScreen('LittleJS\nHello World!', vec2(200, 50));
|
|
1769
1778
|
*/
|
|
1770
1779
|
export class FontImage {
|
|
1771
1780
|
/** Create an image font
|
|
1772
|
-
* @param {
|
|
1773
|
-
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1774
|
-
* @param {Vector2} [paddingSize=(0,1)] - How much space between characters
|
|
1781
|
+
* @param {TileInfo} tileInfo - Tile info of first characeter in font
|
|
1775
1782
|
*/
|
|
1776
|
-
constructor(
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
paddingSize: Vector2;
|
|
1783
|
+
constructor(tileInfo: TileInfo);
|
|
1784
|
+
/** @property {TileInfo} - Tile info for the font */
|
|
1785
|
+
tileInfo: TileInfo;
|
|
1780
1786
|
/** Draw text in world space using the image font
|
|
1781
|
-
* @param {string|number}
|
|
1787
|
+
* @param {string|number} text
|
|
1782
1788
|
* @param {Vector2} pos
|
|
1783
|
-
* @param {number}
|
|
1784
|
-
* @param {boolean} [center]
|
|
1785
|
-
* @param {
|
|
1789
|
+
* @param {Vector2|number} [size]
|
|
1790
|
+
* @param {boolean} [center=true]
|
|
1791
|
+
* @param {Color} [color=WHITE]
|
|
1792
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1793
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1786
1794
|
*/
|
|
1787
|
-
drawText(text: string | number, pos: Vector2,
|
|
1795
|
+
drawText(text: string | number, pos: Vector2, size?: Vector2 | number, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1788
1796
|
/** Draw text in screen space using the image font
|
|
1789
|
-
* @param {string|number}
|
|
1797
|
+
* @param {string|number} text
|
|
1790
1798
|
* @param {Vector2} pos
|
|
1791
|
-
* @param {number}
|
|
1799
|
+
* @param {Vector2|number} size
|
|
1792
1800
|
* @param {boolean} [center]
|
|
1793
|
-
* @param {
|
|
1801
|
+
* @param {Color} [color=WHITE]
|
|
1802
|
+
* @param {boolean} [useWebGL=glEnable]
|
|
1803
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
|
|
1794
1804
|
*/
|
|
1795
|
-
drawTextScreen(text: string | number, pos: Vector2,
|
|
1805
|
+
drawTextScreen(text: string | number, pos: Vector2, size: Vector2 | number, center?: boolean, color?: Color, useWebGL?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1796
1806
|
}
|
|
1797
1807
|
/** Returns true if fullscreen mode is active
|
|
1798
1808
|
* @return {boolean}
|
|
@@ -1829,6 +1839,10 @@ declare module "littlejsengine" {
|
|
|
1829
1839
|
* @type {WebGL2RenderingContext}
|
|
1830
1840
|
* @memberof WebGL */
|
|
1831
1841
|
export let glContext: WebGL2RenderingContext;
|
|
1842
|
+
/** Should WebGL be setup with anti-aliasing? must be set before calling engineInit
|
|
1843
|
+
* @type {boolean}
|
|
1844
|
+
* @memberof WebGL */
|
|
1845
|
+
export let glAntialias: boolean;
|
|
1832
1846
|
/** Clear the canvas and setup the viewport
|
|
1833
1847
|
* @memberof WebGL */
|
|
1834
1848
|
export function glClearCanvas(): void;
|
|
@@ -1924,21 +1938,18 @@ declare module "littlejsengine" {
|
|
|
1924
1938
|
* @param {Array<number>} pointColors - Array of 32-bit integer colors
|
|
1925
1939
|
* @memberof WebGL */
|
|
1926
1940
|
export function glDrawColoredPoints(points: Array<Vector2>, pointColors: Array<number>): void;
|
|
1927
|
-
/**
|
|
1928
|
-
* @
|
|
1941
|
+
/** Set the WebGL render target to the given texture or back to the canvas
|
|
1942
|
+
* @param {WebGLTexture} [texture] - a texture or undefined to use normal glCanvas
|
|
1943
|
+
* @param {boolean} [clear] - should the render target be cleared
|
|
1929
1944
|
* @memberof WebGL */
|
|
1930
|
-
export
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
export
|
|
1938
|
-
export let glGeometryBuffer: any;
|
|
1939
|
-
export let glPositionData: any;
|
|
1940
|
-
export let glColorData: any;
|
|
1941
|
-
export let glBatchCount: any;
|
|
1945
|
+
export function glSetRenderTarget(texture?: WebGLTexture, clear?: boolean): void;
|
|
1946
|
+
/** Clear out a rectangle area of the WebGL canvas or render target
|
|
1947
|
+
* @param {number} x
|
|
1948
|
+
* @param {number} y
|
|
1949
|
+
* @param {number} width
|
|
1950
|
+
* @param {number} height
|
|
1951
|
+
* @memberof WebGL */
|
|
1952
|
+
export function glClearRect(x: number, y: number, width: number, height: number): void;
|
|
1942
1953
|
/** Returns true if device key is down
|
|
1943
1954
|
* @param {string|number} key
|
|
1944
1955
|
* @param {number} [device]
|
|
@@ -2039,6 +2050,9 @@ declare module "littlejsengine" {
|
|
|
2039
2050
|
* @type {number}
|
|
2040
2051
|
* @memberof Input */
|
|
2041
2052
|
export let gamepadPrimary: number;
|
|
2053
|
+
/** True if a touch device has been detected
|
|
2054
|
+
* @memberof Input */
|
|
2055
|
+
export const isTouchDevice: boolean;
|
|
2042
2056
|
/** Prevents input continuing to the default browser handling
|
|
2043
2057
|
* This is useful to disable for html menus so the browser can handle input normally
|
|
2044
2058
|
* @param {boolean} preventDefault
|
|
@@ -2085,9 +2099,6 @@ declare module "littlejsengine" {
|
|
|
2085
2099
|
/** Cancel any ongoing vibration
|
|
2086
2100
|
* @memberof Input */
|
|
2087
2101
|
export function vibrateStop(): void;
|
|
2088
|
-
/** True if a touch device has been detected
|
|
2089
|
-
* @memberof Input */
|
|
2090
|
-
export const isTouchDevice: boolean;
|
|
2091
2102
|
/** Request to lock the pointer, does not work on touch devices
|
|
2092
2103
|
* @memberof Input */
|
|
2093
2104
|
export function pointerLockRequest(): void;
|
|
@@ -2394,10 +2405,10 @@ declare module "littlejsengine" {
|
|
|
2394
2405
|
*/
|
|
2395
2406
|
export class EngineObject {
|
|
2396
2407
|
/** Create an engine object and adds it to the list of objects
|
|
2397
|
-
* @param {Vector2} [pos=(
|
|
2398
|
-
* @param {Vector2} [size=(1
|
|
2399
|
-
* @param {TileInfo} [tileInfo]
|
|
2400
|
-
* @param {number} [angle]
|
|
2408
|
+
* @param {Vector2} [pos=vec2()] - World space position of the object
|
|
2409
|
+
* @param {Vector2} [size=vec2(1)] - World space size of the object
|
|
2410
|
+
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
|
|
2411
|
+
* @param {number} [angle] - Angle the object is rotated by
|
|
2401
2412
|
* @param {Color} [color=WHITE] - Color to apply to tile when rendered
|
|
2402
2413
|
* @param {number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
2403
2414
|
*/
|
|
@@ -2481,14 +2492,14 @@ declare module "littlejsengine" {
|
|
|
2481
2492
|
/** Convert from world space to local space for a vector (rotation only)
|
|
2482
2493
|
* @param {Vector2} vec - world space vector */
|
|
2483
2494
|
worldToLocalVector(vec: Vector2): Vector2;
|
|
2484
|
-
/** Called to check if a tile collision should be resolved
|
|
2495
|
+
/** Called to check if a tile collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually.
|
|
2485
2496
|
* @param {number} tileData - the value of the tile at the position
|
|
2486
|
-
* @param {Vector2} pos
|
|
2487
|
-
* @return {boolean}
|
|
2497
|
+
* @param {Vector2} pos - tile where the collision occurred
|
|
2498
|
+
* @return {boolean} - true if the collision should be resolved by modifying it's position and velocity */
|
|
2488
2499
|
collideWithTile(tileData: number, pos: Vector2): boolean;
|
|
2489
|
-
/** Called to check if
|
|
2500
|
+
/** Called by the engine to check if an object collision should be resolved. Return true for physics to resolve the collision or false to ignore and resolve it manually.
|
|
2490
2501
|
* @param {EngineObject} object - the object to test against
|
|
2491
|
-
* @return {boolean}
|
|
2502
|
+
* @return {boolean} - true if the collision should be resolved by modifying it's position and velocity
|
|
2492
2503
|
*/
|
|
2493
2504
|
collideWithObject(object: EngineObject): boolean;
|
|
2494
2505
|
/** Get this object's up vector
|
|
@@ -2519,7 +2530,7 @@ declare module "littlejsengine" {
|
|
|
2519
2530
|
getMirrorSign(): number;
|
|
2520
2531
|
/** Attaches a child to this with a local transform, returns child for chaining
|
|
2521
2532
|
* @param {EngineObject} child
|
|
2522
|
-
* @param {Vector2} [localPos=(
|
|
2533
|
+
* @param {Vector2} [localPos=vec2()]
|
|
2523
2534
|
* @param {number} [localAngle]
|
|
2524
2535
|
* @return {EngineObject} The child object added */
|
|
2525
2536
|
addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): EngineObject;
|
|
@@ -2533,7 +2544,7 @@ declare module "littlejsengine" {
|
|
|
2533
2544
|
isOverlappingObject(object: EngineObject): boolean;
|
|
2534
2545
|
/** Check if overlapping a point or aligned bounding box
|
|
2535
2546
|
* @param {Vector2} pos - Center of box
|
|
2536
|
-
* @param {Vector2} [size=(
|
|
2547
|
+
* @param {Vector2} [size=vec2()] - Size of box, uses a point if undefined
|
|
2537
2548
|
* @return {boolean} */
|
|
2538
2549
|
isOverlapping(pos: Vector2, size?: Vector2): boolean;
|
|
2539
2550
|
/** Set how this object collides
|
|
@@ -2567,7 +2578,7 @@ declare module "littlejsengine" {
|
|
|
2567
2578
|
export function tileCollisionGetData(pos: Vector2): number;
|
|
2568
2579
|
/** Check if a tile layer collides with another object
|
|
2569
2580
|
* @param {Vector2} pos
|
|
2570
|
-
* @param {Vector2} [size=(
|
|
2581
|
+
* @param {Vector2} [size=vec2()]
|
|
2571
2582
|
* @param {EngineObject} [object] - An object or undefined for generic test
|
|
2572
2583
|
* @param {boolean} [solidOnly] - Only check solid layers if true
|
|
2573
2584
|
* @return {TileCollisionLayer}
|
|
@@ -2606,18 +2617,18 @@ declare module "littlejsengine" {
|
|
|
2606
2617
|
*/
|
|
2607
2618
|
export class TileLayerData {
|
|
2608
2619
|
/** Create a tile layer data object, one for each tile in a TileLayer
|
|
2609
|
-
* @param {number} [tile]
|
|
2620
|
+
* @param {number} [tile] - The tile to use, untextured if undefined
|
|
2610
2621
|
* @param {number} [direction] - Integer direction of tile, in 90 degree increments
|
|
2611
|
-
* @param {boolean} [mirror]
|
|
2612
|
-
* @param {Color} [color]
|
|
2622
|
+
* @param {boolean} [mirror] - If the tile should be mirrored along the x axis
|
|
2623
|
+
* @param {Color} [color] - Color of the tile */
|
|
2613
2624
|
constructor(tile?: number, direction?: number, mirror?: boolean, color?: Color);
|
|
2614
|
-
/** @property {number}
|
|
2625
|
+
/** @property {number} - The tile to use, untextured if undefined */
|
|
2615
2626
|
tile: number;
|
|
2616
|
-
/** @property {number}
|
|
2627
|
+
/** @property {number} - Integer direction of tile, in 90 degree increments */
|
|
2617
2628
|
direction: number;
|
|
2618
2629
|
/** @property {boolean} - If the tile should be mirrored along the x axis */
|
|
2619
2630
|
mirror: boolean;
|
|
2620
|
-
/** @property {Color}
|
|
2631
|
+
/** @property {Color} - Color of the tile */
|
|
2621
2632
|
color: Color;
|
|
2622
2633
|
/** Set this tile to clear, it will not be rendered */
|
|
2623
2634
|
clear(): void;
|
|
@@ -2625,7 +2636,7 @@ declare module "littlejsengine" {
|
|
|
2625
2636
|
/**
|
|
2626
2637
|
* Canvas Layer - cached off screen rendering system
|
|
2627
2638
|
* - Contains an offscreen canvas that can be rendered to
|
|
2628
|
-
* - WebGL rendering is optional, call
|
|
2639
|
+
* - WebGL rendering is optional, call updateWebGL to enable/update
|
|
2629
2640
|
* @extends EngineObject
|
|
2630
2641
|
* @memberof TileLayers
|
|
2631
2642
|
* @example
|
|
@@ -2638,15 +2649,15 @@ declare module "littlejsengine" {
|
|
|
2638
2649
|
* @param {number} [angle] - Angle the layer is rotated by
|
|
2639
2650
|
* @param {number} [renderOrder] - Objects sorted by renderOrder
|
|
2640
2651
|
* @param {Vector2} [canvasSize] - Default size of canvas, can be changed later
|
|
2652
|
+
* @param {boolean} [useWebGL] - Should this layer use WebGL for rendering
|
|
2641
2653
|
*/
|
|
2642
|
-
constructor(position?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2);
|
|
2654
|
+
constructor(position?: Vector2, size?: Vector2, angle?: number, renderOrder?: number, canvasSize?: Vector2, useWebGL?: boolean);
|
|
2643
2655
|
/** @property {HTMLCanvasElement} - The canvas used by this layer */
|
|
2644
2656
|
canvas: OffscreenCanvas;
|
|
2645
2657
|
/** @property {OffscreenCanvasRenderingContext2D} - The 2D canvas context used by this layer */
|
|
2646
2658
|
context: OffscreenCanvasRenderingContext2D;
|
|
2659
|
+
/** @property {TextureInfo} - Texture info to use for this object rendering */
|
|
2647
2660
|
textureInfo: TextureInfo;
|
|
2648
|
-
/** @property {boolean} - True if WebGL texture needs to be refreshed */
|
|
2649
|
-
refreshWebGL: boolean;
|
|
2650
2661
|
/** Draw this canvas layer centered in world space, with color applied if using WebGL
|
|
2651
2662
|
* @param {Vector2} pos - Center in world space
|
|
2652
2663
|
* @param {Vector2} [size] - Size in world space
|
|
@@ -2657,38 +2668,26 @@ declare module "littlejsengine" {
|
|
|
2657
2668
|
* @param {boolean} [screenSpace] - If true the pos and size are in screen space
|
|
2658
2669
|
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
2659
2670
|
* @memberof Draw */
|
|
2660
|
-
draw(pos: Vector2, size?: Vector2,
|
|
2661
|
-
/**
|
|
2662
|
-
* @callback Canvas2DDrawCallback - Function that draws to a canvas 2D context
|
|
2663
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} context
|
|
2664
|
-
* @memberof TileLayers
|
|
2665
|
-
*/
|
|
2666
|
-
/** Draw onto the layer canvas in world space (bypass WebGL)
|
|
2667
|
-
* @param {Vector2} pos
|
|
2668
|
-
* @param {Vector2} size
|
|
2669
|
-
* @param {number} angle
|
|
2670
|
-
* @param {boolean} mirror
|
|
2671
|
-
* @param {Canvas2DDrawCallback} drawFunction */
|
|
2672
|
-
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: (context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D) => any): void;
|
|
2671
|
+
draw(pos: Vector2, size?: Vector2, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
2673
2672
|
/** Draw a tile onto the layer canvas in world space
|
|
2674
2673
|
* @param {Vector2} pos
|
|
2675
|
-
* @param {Vector2} [size=(1
|
|
2674
|
+
* @param {Vector2} [size=vec2(1)]
|
|
2676
2675
|
* @param {TileInfo} [tileInfo]
|
|
2677
|
-
* @param {Color} [color=
|
|
2678
|
-
* @param {number} [angle
|
|
2679
|
-
* @param {boolean} [mirror
|
|
2676
|
+
* @param {Color} [color=WHITE]
|
|
2677
|
+
* @param {number} [angle]
|
|
2678
|
+
* @param {boolean} [mirror] */
|
|
2680
2679
|
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2681
2680
|
/** Draw a rectangle onto the layer canvas in world space
|
|
2682
2681
|
* @param {Vector2} pos
|
|
2683
|
-
* @param {Vector2} [size=(1
|
|
2684
|
-
* @param {Color} [color=
|
|
2685
|
-
* @param {number} [angle
|
|
2682
|
+
* @param {Vector2} [size=vec2(1)]
|
|
2683
|
+
* @param {Color} [color=WHITE]
|
|
2684
|
+
* @param {number} [angle] */
|
|
2686
2685
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
2687
|
-
/** Create
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
*/
|
|
2691
|
-
|
|
2686
|
+
/** Create WebGL texture if necessary and copy layer canvas to it */
|
|
2687
|
+
updateWebGL(): void;
|
|
2688
|
+
/** Check if this layer is using WebGL
|
|
2689
|
+
* @return {boolean} */
|
|
2690
|
+
hasWebGL(): boolean;
|
|
2692
2691
|
}
|
|
2693
2692
|
/**
|
|
2694
2693
|
* Tile Layer - cached rendering system for tile layers
|
|
@@ -2704,18 +2703,21 @@ declare module "littlejsengine" {
|
|
|
2704
2703
|
*/
|
|
2705
2704
|
export class TileLayer extends CanvasLayer {
|
|
2706
2705
|
/** Create a tile layer object
|
|
2707
|
-
* @param {Vector2} position
|
|
2708
|
-
* @param {Vector2} size
|
|
2709
|
-
* @param {TileInfo} [tileInfo]
|
|
2706
|
+
* @param {Vector2} position - World space position
|
|
2707
|
+
* @param {Vector2} size - World space size
|
|
2708
|
+
* @param {TileInfo} [tileInfo] - Default tile info for layer (used for size and texture)
|
|
2710
2709
|
* @param {number} [renderOrder] - Objects are sorted by renderOrder
|
|
2711
2710
|
*/
|
|
2712
2711
|
constructor(position: Vector2, size: Vector2, tileInfo?: TileInfo, renderOrder?: number);
|
|
2712
|
+
/** @property {Array<TileLayerData>} - Default tile info for layer */
|
|
2713
2713
|
data: TileLayerData[];
|
|
2714
|
+
/** @property {boolean} - Is this layer using a webgl texture? */
|
|
2715
|
+
isUsingWebGL: boolean;
|
|
2714
2716
|
/** Draw all the tile data to an offscreen canvas
|
|
2715
|
-
* - This may be slow
|
|
2717
|
+
* - This may be slow if not using webgl but only needs to be done once */
|
|
2716
2718
|
redraw(): void;
|
|
2717
2719
|
/** Call to start the redraw process
|
|
2718
|
-
* - This can be used to manually update
|
|
2720
|
+
* - This can be used to manually update parts of the level
|
|
2719
2721
|
* @param {boolean} [clear] - Should it clear the canvas before drawing */
|
|
2720
2722
|
redrawStart(clear?: boolean): void;
|
|
2721
2723
|
/** Call to end the redraw process */
|
|
@@ -2727,15 +2729,45 @@ declare module "littlejsengine" {
|
|
|
2727
2729
|
* @param {boolean} [clear] - should the old tile be cleared out
|
|
2728
2730
|
*/
|
|
2729
2731
|
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2732
|
+
/** Draw the tile at a given position in the tile grid
|
|
2733
|
+
* This can be used to clear tiles when they are destroyed
|
|
2734
|
+
* For better performance use drawTileData inside a redrawStart/End block
|
|
2735
|
+
* @param {Vector2} layerPos
|
|
2736
|
+
* @param {boolean} [clear] - should the old tile be cleared
|
|
2737
|
+
*/
|
|
2738
|
+
redrawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
2739
|
+
/** Draw textured tile in layer space
|
|
2740
|
+
* @param {Vector2} pos - Position in pixel coordinates
|
|
2741
|
+
* @param {Vector2} [size=vec2(1)] - Size of the tile
|
|
2742
|
+
* @param {TileInfo} [tileInfo] - Tile info to use, untextured if undefined
|
|
2743
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
2744
|
+
* @param {number} [angle] - Angle to rotate by
|
|
2745
|
+
* @param {boolean} [mirror] - Is image flipped along the Y axis?
|
|
2746
|
+
* @param {Color} [additiveColor] - Additive color to be applied if any */
|
|
2747
|
+
drawLayerTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean, additiveColor?: Color): void;
|
|
2748
|
+
/** Clear a rectangle in layer space
|
|
2749
|
+
* @param {Vector2} pos
|
|
2750
|
+
* @param {Vector2} size
|
|
2751
|
+
* @param {Color} [color=WHITE] - Color to modulate with
|
|
2752
|
+
* @param {number} [angle] - Angle to rotate by
|
|
2753
|
+
*/
|
|
2754
|
+
drawLayerRect(pos: Vector2, size: Vector2, color?: Color, angle?: number): void;
|
|
2755
|
+
/** Clear a rectangle in layer space
|
|
2756
|
+
* @param {Vector2} pos - position in pixel coordinates
|
|
2757
|
+
* @param {Vector2} size
|
|
2758
|
+
*/
|
|
2759
|
+
clearLayerRect(pos: Vector2, size: Vector2): void;
|
|
2730
2760
|
/** Set data at a given position in the array
|
|
2731
2761
|
* @param {Vector2} layerPos - Local position in array
|
|
2732
|
-
* @param {TileLayerData} data
|
|
2762
|
+
* @param {TileLayerData} data - Data to set
|
|
2733
2763
|
* @param {boolean} [redraw] - Force the tile to redraw if true */
|
|
2734
2764
|
setData(layerPos: Vector2, data: TileLayerData, redraw?: boolean): void;
|
|
2735
2765
|
/** Get data at a given position in the array
|
|
2736
2766
|
* @param {Vector2} layerPos - Local position in array
|
|
2737
2767
|
* @return {TileLayerData} */
|
|
2738
2768
|
getData(layerPos: Vector2): TileLayerData;
|
|
2769
|
+
/** Called after this layer is redrawn, does nothing by default */
|
|
2770
|
+
onRedraw(): void;
|
|
2739
2771
|
/** @type {[CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color]} */
|
|
2740
2772
|
savedRenderSettings: [CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D, Vector2, Vector2, number, Color];
|
|
2741
2773
|
}
|
|
@@ -2743,7 +2775,6 @@ declare module "littlejsengine" {
|
|
|
2743
2775
|
* Tile Collision Layer - a tile layer with collision
|
|
2744
2776
|
* - adds collision data and functions to TileLayer
|
|
2745
2777
|
* - there can be multiple tile collision layers
|
|
2746
|
-
* - tile collision layers should not overlap each other
|
|
2747
2778
|
* @extends TileLayer
|
|
2748
2779
|
* @memberof TileLayers
|
|
2749
2780
|
*/
|
|
@@ -2763,7 +2794,7 @@ declare module "littlejsengine" {
|
|
|
2763
2794
|
getCollisionData(gridPos: Vector2): number;
|
|
2764
2795
|
/** Check if collision with another object should occur
|
|
2765
2796
|
* @param {Vector2} pos
|
|
2766
|
-
* @param {Vector2} [size=(
|
|
2797
|
+
* @param {Vector2} [size=vec2()]
|
|
2767
2798
|
* @param {EngineObject} [object]
|
|
2768
2799
|
* @return {boolean} */
|
|
2769
2800
|
collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
|
|
@@ -3086,16 +3117,19 @@ declare module "littlejsengine" {
|
|
|
3086
3117
|
export class PostProcessPlugin {
|
|
3087
3118
|
/** Create global post processing shader
|
|
3088
3119
|
* @param {string} shaderCode
|
|
3089
|
-
* @param {boolean} [includeMainCanvas]
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3120
|
+
* @param {boolean} [includeMainCanvas] - combine mainCanvs onto glCanvas
|
|
3121
|
+
* @param {boolean} [feedbackTexture] - use glCanvas from previous frame as the texture
|
|
3122
|
+
* @example
|
|
3123
|
+
* // create the post process plugin object
|
|
3124
|
+
* new PostProcessPlugin(shaderCode);
|
|
3125
|
+
*/
|
|
3126
|
+
constructor(shaderCode: string, includeMainCanvas?: boolean, feedbackTexture?: boolean);
|
|
3095
3127
|
/** @property {WebGLProgram} - Shader for post processing */
|
|
3096
3128
|
shader: any;
|
|
3097
3129
|
/** @property {WebGLTexture} - Texture for post processing */
|
|
3098
3130
|
texture: any;
|
|
3131
|
+
/** @property {WebGLVertexArrayObject} - Vertex array object */
|
|
3132
|
+
vao: any;
|
|
3099
3133
|
}
|
|
3100
3134
|
/**
|
|
3101
3135
|
* LittleJS ZzFXM Plugin
|
|
@@ -3338,8 +3372,8 @@ declare module "littlejsengine" {
|
|
|
3338
3372
|
* @memberof UISystem */
|
|
3339
3373
|
export class UIObject {
|
|
3340
3374
|
/** Create a UIObject
|
|
3341
|
-
* @param {Vector2} [pos=(
|
|
3342
|
-
* @param {Vector2} [size=(1
|
|
3375
|
+
* @param {Vector2} [pos=vec2()]
|
|
3376
|
+
* @param {Vector2} [size=vec2(1)]
|
|
3343
3377
|
*/
|
|
3344
3378
|
constructor(pos?: Vector2, size?: Vector2);
|
|
3345
3379
|
/** @property {Vector2} - Local position of the object */
|
|
@@ -3350,7 +3384,7 @@ declare module "littlejsengine" {
|
|
|
3350
3384
|
size: Vector2;
|
|
3351
3385
|
/** @property {Color} - Color of the object */
|
|
3352
3386
|
color: Color;
|
|
3353
|
-
/** @property {Color} - Color of the object when active, uses
|
|
3387
|
+
/** @property {Color} - Color of the object when active, uses hoverColor if undefined */
|
|
3354
3388
|
activeColor: any;
|
|
3355
3389
|
/** @property {string} - Text for this ui object */
|
|
3356
3390
|
text: any;
|