littlejsengine 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/{build → dist}/littlejs.d.ts +84 -77
- package/{build → dist}/littlejs.esm.js +245 -143
- package/dist/littlejs.esm.min.js +1 -0
- package/{build → dist}/littlejs.js +245 -143
- package/dist/littlejs.min.js +1 -0
- package/{build → dist}/littlejs.release.js +239 -141
- package/examples/breakout/game.js +2 -2
- package/examples/breakout/gameObjects.js +3 -3
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/index.html +2 -2
- package/examples/electron/build.js +1 -1
- package/examples/electron/game.js +49 -38
- package/examples/electron/index.html +2 -2
- package/examples/electron/tiles.png +0 -0
- package/examples/empty/index.html +1 -1
- package/examples/js13k/build.js +2 -2
- package/examples/js13k/game.js +10 -9
- package/examples/js13k/index.html +13 -13
- package/examples/js13k/tiles.png +0 -0
- package/examples/module/game.js +45 -41
- package/examples/module/index.html +1 -1
- package/examples/module/tiles.png +0 -0
- package/examples/particles/index.html +1 -1
- package/examples/platformer/data/gameTileData.tmx +143 -0
- package/examples/platformer/data/gameTileData.tsx +4 -0
- package/examples/platformer/game.js +0 -1
- package/examples/platformer/gameCharacter.js +1 -1
- package/examples/platformer/gameEffects.js +42 -110
- package/examples/platformer/gameLevel.js +149 -183
- package/examples/platformer/gameObjects.js +61 -16
- package/examples/platformer/gamePlayer.js +3 -2
- package/examples/platformer/gameTileData.js +181 -0
- package/examples/platformer/index.html +8 -7
- package/examples/platformer/tiles.png +0 -0
- package/examples/platformer/tilesLevel.png +0 -0
- package/examples/puzzle/game.js +12 -12
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/build.js +2 -2
- package/examples/starter/game.js +6 -6
- package/examples/starter/index.html +13 -13
- package/examples/starter/tiles.png +0 -0
- package/examples/stress/index.html +2 -2
- package/examples/typescript/build.bat +4 -1
- package/examples/typescript/game.js +34 -31
- package/examples/typescript/game.ts +40 -36
- package/examples/typescript/index.html +1 -1
- package/examples/typescript/tiles.png +0 -0
- package/package.json +3 -3
- package/src/engine.js +1 -1
- package/src/engineAudio.js +4 -10
- package/src/engineBuild.js +9 -2
- package/src/engineDebug.js +6 -2
- package/src/engineDraw.js +27 -27
- package/src/engineInput.js +7 -7
- package/src/engineMedals.js +2 -2
- package/src/engineObject.js +7 -7
- package/src/engineParticles.js +9 -9
- package/src/engineTileLayer.js +38 -33
- package/src/engineUtilities.js +136 -35
- package/src/engineWebGL.js +8 -10
- package/build/littlejs.esm.min.js +0 -1
- package/build/littlejs.min.js +0 -1
package/README.md
CHANGED
|
@@ -54,7 +54,7 @@ LittleJS is a small but powerful game engine with many features and no dependenc
|
|
|
54
54
|
|
|
55
55
|
### 💥 Physics
|
|
56
56
|
|
|
57
|
-
- Robust
|
|
57
|
+
- Robust arcade physics system with collision handling
|
|
58
58
|
- Very fast collision and raycasting for tile maps
|
|
59
59
|
|
|
60
60
|
### 🚀 Flexibility
|
|
@@ -91,7 +91,7 @@ These examples are for both learning and using as starter projects to create you
|
|
|
91
91
|
- [Starter Project](https://killedbyapixel.github.io/LittleJS/examples/starter/) - Clean example with only a few things to get you started
|
|
92
92
|
- [Breakout](https://killedbyapixel.github.io/LittleJS/examples/breakout/) - Block breaking game with post-processing effects
|
|
93
93
|
- [Puzzle Game](https://killedbyapixel.github.io/LittleJS/examples/puzzle/) - Match 3 puzzle game with HD rendering and high score tracking
|
|
94
|
-
- [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer/) - Platformer/shooter with
|
|
94
|
+
- [Platformer](https://killedbyapixel.github.io/LittleJS/examples/platformer/) - Platformer/shooter with level data from [Tiled Editor](https://github.com/mapeditor/tiled)
|
|
95
95
|
- [Stress Test](https://killedbyapixel.github.io/LittleJS/examples/stress/) - Max sprite/object test and music system demo
|
|
96
96
|
- [Particle System Designer](https://killedbyapixel.github.io/LittleJS/examples/particles/) - Particle system editor and visualizer
|
|
97
97
|
|
|
@@ -99,11 +99,11 @@ These examples are for both learning and using as starter projects to create you
|
|
|
99
99
|
|
|
100
100
|
To easily include LittleJS in your game, you can use one of the pre-built js files.
|
|
101
101
|
|
|
102
|
-
- [littlejs.js](https://github.com/KilledByAPixel/LittleJS/blob/main/
|
|
103
|
-
- [littlejs.release.js](https://github.com/KilledByAPixel/LittleJS/blob/main/
|
|
104
|
-
- [littlejs.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/
|
|
105
|
-
- [littlejs.esm.js](https://github.com/KilledByAPixel/LittleJS/blob/main/
|
|
106
|
-
- [littlejs.esm.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/
|
|
102
|
+
- [littlejs.js](https://github.com/KilledByAPixel/LittleJS/blob/main/dist/littlejs.js) - The full game engine with debug mode available
|
|
103
|
+
- [littlejs.release.js](https://github.com/KilledByAPixel/LittleJS/blob/main/dist/littlejs.release.js) - The engine optimized for release builds
|
|
104
|
+
- [littlejs.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/dist/littlejs.min.js) - The engine in release mode and minified
|
|
105
|
+
- [littlejs.esm.js](https://github.com/KilledByAPixel/LittleJS/blob/main/dist/littlejs.esm.js) - The engine exported as a module with debug mode available
|
|
106
|
+
- [littlejs.esm.min.js](https://github.com/KilledByAPixel/LittleJS/blob/main/dist/littlejs.esm.min.js) - The engine exported as a minified module in release mode
|
|
107
107
|
|
|
108
108
|
To rebuild the engine you must first run ```npm install``` to setup the necessary npm dependencies. Then call ```npm run build``` to build the engine.
|
|
109
109
|
|
|
@@ -111,9 +111,9 @@ declare module "littlejs.esm" {
|
|
|
111
111
|
export let showWatermark: boolean;
|
|
112
112
|
/** Asserts if the experssion is false, does not do anything in release builds
|
|
113
113
|
* @param {Boolean} assert
|
|
114
|
-
* @param {Object} output
|
|
114
|
+
* @param {Object} [output]
|
|
115
115
|
* @memberof Debug */
|
|
116
|
-
export function ASSERT(assert: boolean, output
|
|
116
|
+
export function ASSERT(assert: boolean, output?: any): void;
|
|
117
117
|
/** Draw a debug rectangle in world space
|
|
118
118
|
* @param {Vector2} pos
|
|
119
119
|
* @param {Vector2} [size=Vector2()]
|
|
@@ -619,13 +619,13 @@ 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
|
|
623
|
-
* @param {Vector2} sizeA
|
|
624
|
-
* @param {Vector2} pointB
|
|
625
|
-
* @param {Vector2} sizeB
|
|
626
|
-
* @return {Boolean}
|
|
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=(0,0)] - Size of box B, a point if undefined
|
|
626
|
+
* @return {Boolean} - True if overlapping
|
|
627
627
|
* @memberof Utilities */
|
|
628
|
-
export function isOverlapping(pointA: Vector2, sizeA: Vector2, pointB: Vector2, sizeB
|
|
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
|
|
630
630
|
* @param {Number} [frequency] - Frequency of the wave in Hz
|
|
631
631
|
* @param {Number} [amplitude] - Amplitude (max height) of the wave
|
|
@@ -668,8 +668,8 @@ declare module "littlejs.esm" {
|
|
|
668
668
|
* @memberof Random */
|
|
669
669
|
export function randVector(length?: number): Vector2;
|
|
670
670
|
/** Returns a random color between the two passed in colors, combine components if linear
|
|
671
|
-
* @param {Color} [colorA=
|
|
672
|
-
* @param {Color} [colorB=
|
|
671
|
+
* @param {Color} [colorA=(1,1,1,1)]
|
|
672
|
+
* @param {Color} [colorB=(0,0,0,1)]
|
|
673
673
|
* @param {Boolean} [linear]
|
|
674
674
|
* @return {Color}
|
|
675
675
|
* @memberof Random */
|
|
@@ -787,6 +787,10 @@ declare module "littlejs.esm" {
|
|
|
787
787
|
* @param {Number} angle
|
|
788
788
|
* @return {Vector2} */
|
|
789
789
|
rotate(angle: number): Vector2;
|
|
790
|
+
/** Set the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
|
|
791
|
+
* @param {Number} [direction]
|
|
792
|
+
* @param {Number} [length] */
|
|
793
|
+
setDirection(direction?: number, length?: number): Vector2;
|
|
790
794
|
/** Returns the integer direction of this vector, corrosponding to multiples of 90 degree rotation (0-3)
|
|
791
795
|
* @return {Number} */
|
|
792
796
|
direction(): number;
|
|
@@ -819,8 +823,8 @@ declare module "littlejs.esm" {
|
|
|
819
823
|
* let a = new Color; // white
|
|
820
824
|
* let b = new Color(1, 0, 0); // red
|
|
821
825
|
* let c = new Color(0, 0, 0, 0); // transparent black
|
|
822
|
-
* let d =
|
|
823
|
-
* let e =
|
|
826
|
+
* let d = rgb(0, 0, 1); // blue using rgb color
|
|
827
|
+
* let e = hsl(.3, 1, .5); // green using hsl color
|
|
824
828
|
*/
|
|
825
829
|
export class Color {
|
|
826
830
|
/** Create a color with the rgba components passed in, white by default
|
|
@@ -952,7 +956,7 @@ declare module "littlejs.esm" {
|
|
|
952
956
|
*/
|
|
953
957
|
export function vec2(x?: (number | Vector2), y?: number): Vector2;
|
|
954
958
|
/**
|
|
955
|
-
* Create a color object with RGBA values
|
|
959
|
+
* Create a color object with RGBA values, white by default
|
|
956
960
|
* @param {Number} [r=1] - red
|
|
957
961
|
* @param {Number} [g=1] - green
|
|
958
962
|
* @param {Number} [b=1] - blue
|
|
@@ -962,7 +966,7 @@ declare module "littlejs.esm" {
|
|
|
962
966
|
*/
|
|
963
967
|
export function rgb(r?: number, g?: number, b?: number, a?: number): Color;
|
|
964
968
|
/**
|
|
965
|
-
* Create a color object with HSLA values
|
|
969
|
+
* Create a color object with HSLA values, white by default
|
|
966
970
|
* @param {Number} [h=0] - hue
|
|
967
971
|
* @param {Number} [s=0] - saturation
|
|
968
972
|
* @param {Number} [l=1] - lightness
|
|
@@ -979,7 +983,7 @@ declare module "littlejs.esm" {
|
|
|
979
983
|
* Create a tile info object
|
|
980
984
|
* - This can take vecs or floats for easier use and conversion
|
|
981
985
|
* - If an index is passed in, the tile size and index will determine the position
|
|
982
|
-
* @param {(Number|Vector2)} [pos=
|
|
986
|
+
* @param {(Number|Vector2)} [pos=(0,0)] - Top left corner of tile in pixels or index
|
|
983
987
|
* @param {(Number|Vector2)} [size=tileSizeDefault] - Size of tile in pixels
|
|
984
988
|
* @param {Number} [textureIndex] - Texture index to use
|
|
985
989
|
* @return {TileInfo}
|
|
@@ -996,7 +1000,7 @@ declare module "littlejs.esm" {
|
|
|
996
1000
|
*/
|
|
997
1001
|
export class TileInfo {
|
|
998
1002
|
/** Create a tile info object
|
|
999
|
-
* @param {Vector2} [pos=
|
|
1003
|
+
* @param {Vector2} [pos=(0,0)] - Top left corner of tile in pixels
|
|
1000
1004
|
* @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
|
|
1001
1005
|
* @param {Number} [textureIndex] - Texture index to use
|
|
1002
1006
|
*/
|
|
@@ -1085,25 +1089,25 @@ declare module "littlejs.esm" {
|
|
|
1085
1089
|
* @memberof Draw */
|
|
1086
1090
|
export function worldToScreen(worldPos: Vector2): Vector2;
|
|
1087
1091
|
/** Draw textured tile centered in world space, with color applied if using WebGL
|
|
1088
|
-
* @param {Vector2} pos
|
|
1089
|
-
* @param {Vector2} [size=
|
|
1090
|
-
* @param {TileInfo}[tileInfo]
|
|
1091
|
-
* @param {Color} [color=
|
|
1092
|
-
* @param {Number} [angle]
|
|
1093
|
-
* @param {Boolean} [mirror]
|
|
1094
|
-
* @param {Color} [additiveColor=
|
|
1095
|
-
* @param {Boolean} [useWebGL=glEnable]
|
|
1096
|
-
* @param {Boolean} [screenSpace]
|
|
1097
|
-
* @param {CanvasRenderingContext2D} [context]
|
|
1092
|
+
* @param {Vector2} pos - Center of the tile in world space
|
|
1093
|
+
* @param {Vector2} [size=(1,1)] - Size of the tile in world space
|
|
1094
|
+
* @param {TileInfo}[tileInfo] - Tile info to use, untextured if undefined
|
|
1095
|
+
* @param {Color} [color=(1,1,1,1)] - Color to modulate with
|
|
1096
|
+
* @param {Number} [angle] - Angle to rotate by
|
|
1097
|
+
* @param {Boolean} [mirror] - If true image is flipped along the Y axis
|
|
1098
|
+
* @param {Color} [additiveColor=(0,0,0,0)] - Additive color to be applied
|
|
1099
|
+
* @param {Boolean} [useWebGL=glEnable] - Use accelerated WebGL rendering
|
|
1100
|
+
* @param {Boolean} [screenSpace=false] - If true the pos and size are in screen space
|
|
1101
|
+
* @param {CanvasRenderingContext2D} [context] - Canvas 2D context to draw to
|
|
1098
1102
|
* @memberof Draw */
|
|
1099
1103
|
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
1104
|
/** Draw colored rect centered on pos
|
|
1101
1105
|
* @param {Vector2} pos
|
|
1102
|
-
* @param {Vector2} [size=
|
|
1103
|
-
* @param {Color} [color=
|
|
1106
|
+
* @param {Vector2} [size=(1,1)]
|
|
1107
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1104
1108
|
* @param {Number} [angle]
|
|
1105
1109
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1106
|
-
* @param {Boolean} [screenSpace]
|
|
1110
|
+
* @param {Boolean} [screenSpace=false]
|
|
1107
1111
|
* @param {CanvasRenderingContext2D} [context]
|
|
1108
1112
|
* @memberof Draw */
|
|
1109
1113
|
export function drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
@@ -1111,9 +1115,9 @@ declare module "littlejs.esm" {
|
|
|
1111
1115
|
* @param {Vector2} posA
|
|
1112
1116
|
* @param {Vector2} posB
|
|
1113
1117
|
* @param {Number} [thickness]
|
|
1114
|
-
* @param {Color} [color=
|
|
1118
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1115
1119
|
* @param {Boolean} [useWebGL=glEnable]
|
|
1116
|
-
* @param {Boolean} [screenSpace]
|
|
1120
|
+
* @param {Boolean} [screenSpace=false]
|
|
1117
1121
|
* @param {CanvasRenderingContext2D} [context]
|
|
1118
1122
|
* @memberof Draw */
|
|
1119
1123
|
export function drawLine(posA: Vector2, posB: Vector2, thickness?: number, color?: Color, useWebGL?: boolean, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
@@ -1123,7 +1127,7 @@ declare module "littlejs.esm" {
|
|
|
1123
1127
|
* @param {Number} angle
|
|
1124
1128
|
* @param {Boolean} mirror
|
|
1125
1129
|
* @param {Function} drawFunction
|
|
1126
|
-
* @param {Boolean} [screenSpace]
|
|
1130
|
+
* @param {Boolean} [screenSpace=false]
|
|
1127
1131
|
* @param {CanvasRenderingContext2D} [context=mainContext]
|
|
1128
1132
|
* @memberof Draw */
|
|
1129
1133
|
export function drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function, screenSpace?: boolean, context?: CanvasRenderingContext2D): void;
|
|
@@ -1138,9 +1142,9 @@ declare module "littlejs.esm" {
|
|
|
1138
1142
|
* @param {String} text
|
|
1139
1143
|
* @param {Vector2} pos
|
|
1140
1144
|
* @param {Number} [size]
|
|
1141
|
-
* @param {Color} [color=
|
|
1145
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1142
1146
|
* @param {Number} [lineWidth]
|
|
1143
|
-
* @param {Color} [lineColor=
|
|
1147
|
+
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1144
1148
|
* @param {CanvasTextAlign} [textAlign]
|
|
1145
1149
|
* @param {String} [font=fontDefault]
|
|
1146
1150
|
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
@@ -1151,9 +1155,9 @@ declare module "littlejs.esm" {
|
|
|
1151
1155
|
* @param {String} text
|
|
1152
1156
|
* @param {Vector2} pos
|
|
1153
1157
|
* @param {Number} [size]
|
|
1154
|
-
* @param {Color} [color=
|
|
1158
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1155
1159
|
* @param {Number} [lineWidth]
|
|
1156
|
-
* @param {Color} [lineColor=
|
|
1160
|
+
* @param {Color} [lineColor=(0,0,0,1)]
|
|
1157
1161
|
* @param {CanvasTextAlign} [textAlign='center']
|
|
1158
1162
|
* @param {String} [font=fontDefault]
|
|
1159
1163
|
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
@@ -1174,9 +1178,9 @@ declare module "littlejs.esm" {
|
|
|
1174
1178
|
*/
|
|
1175
1179
|
export class FontImage {
|
|
1176
1180
|
/** Create an image font
|
|
1177
|
-
* @param {HTMLImageElement} [image]
|
|
1178
|
-
* @param {Vector2} [tileSize=
|
|
1179
|
-
* @param {Vector2} [paddingSize=
|
|
1181
|
+
* @param {HTMLImageElement} [image] - Image for the font, if undefined default font is used
|
|
1182
|
+
* @param {Vector2} [tileSize=(8,8)] - Size of the font source tiles
|
|
1183
|
+
* @param {Vector2} [paddingSize=(0,1)] - How much extra space to add between characters
|
|
1180
1184
|
* @param {CanvasRenderingContext2D} [context=overlayContext] - context to draw to
|
|
1181
1185
|
*/
|
|
1182
1186
|
constructor(image?: HTMLImageElement, tileSize?: Vector2, paddingSize?: Vector2, context?: CanvasRenderingContext2D);
|
|
@@ -1251,7 +1255,7 @@ declare module "littlejs.esm" {
|
|
|
1251
1255
|
* @param {String} shaderCode
|
|
1252
1256
|
* @param {Boolean} includeOverlay
|
|
1253
1257
|
* @memberof WebGL */
|
|
1254
|
-
export function glInitPostProcess(shaderCode: string, includeOverlay
|
|
1258
|
+
export function glInitPostProcess(shaderCode: string, includeOverlay?: boolean): void;
|
|
1255
1259
|
/**
|
|
1256
1260
|
* LittleJS Input System
|
|
1257
1261
|
* - Tracks keyboard down, pressed, and released
|
|
@@ -1354,9 +1358,9 @@ declare module "littlejs.esm" {
|
|
|
1354
1358
|
export function mouseToScreen(mousePos: any): Vector2;
|
|
1355
1359
|
export function gamepadsUpdate(): void;
|
|
1356
1360
|
/** Pulse the vibration hardware if it exists
|
|
1357
|
-
* @param {Number} [pattern] -
|
|
1361
|
+
* @param {Number|Array} [pattern] - single value in ms or vibration interval array
|
|
1358
1362
|
* @memberof Input */
|
|
1359
|
-
export function vibrate(pattern?: number): void;
|
|
1363
|
+
export function vibrate(pattern?: number | any[]): void;
|
|
1360
1364
|
/** Cancel any ongoing vibration
|
|
1361
1365
|
* @memberof Input */
|
|
1362
1366
|
export function vibrateStop(): void;
|
|
@@ -1520,8 +1524,9 @@ declare module "littlejs.esm" {
|
|
|
1520
1524
|
* @memberof Audio */
|
|
1521
1525
|
export function getNoteFrequency(semitoneOffset: number, rootFrequency?: number): number;
|
|
1522
1526
|
/** Audio context used by the engine
|
|
1527
|
+
* @type {AudioContext}
|
|
1523
1528
|
* @memberof Audio */
|
|
1524
|
-
export let audioContext:
|
|
1529
|
+
export let audioContext: AudioContext;
|
|
1525
1530
|
/** Play cached audio samples with given settings
|
|
1526
1531
|
* @param {Array} sampleChannels - Array of arrays of samples to play (for stereo playback)
|
|
1527
1532
|
* @param {Number} [volume] - How much to scale volume by
|
|
@@ -1569,12 +1574,12 @@ declare module "littlejs.esm" {
|
|
|
1569
1574
|
*/
|
|
1570
1575
|
export class EngineObject {
|
|
1571
1576
|
/** Create an engine object and adds it to the list of objects
|
|
1572
|
-
* @param {Vector2} [pos=
|
|
1573
|
-
* @param {Vector2} [size=
|
|
1574
|
-
* @param {TileInfo} [tileInfo]
|
|
1575
|
-
* @param {Number} [angle]
|
|
1576
|
-
* @param {Color} [color=
|
|
1577
|
-
* @param {Number} [renderOrder]
|
|
1577
|
+
* @param {Vector2} [pos=(0,0)] - World space position of the object
|
|
1578
|
+
* @param {Vector2} [size=(1,1)] - World space size of the object
|
|
1579
|
+
* @param {TileInfo} [tileInfo] - Tile info to render object (undefined is untextured)
|
|
1580
|
+
* @param {Number} [angle] - Angle the object is rotated by
|
|
1581
|
+
* @param {Color} [color=(1,1,1,1)] - Color to apply to tile when rendered
|
|
1582
|
+
* @param {Number} [renderOrder] - Objects sorted by renderOrder before being rendered
|
|
1578
1583
|
*/
|
|
1579
1584
|
constructor(pos?: Vector2, size?: Vector2, tileInfo?: TileInfo, angle?: number, color?: Color, renderOrder?: number);
|
|
1580
1585
|
/** @property {Vector2} - World space position of the object */
|
|
@@ -1664,7 +1669,7 @@ declare module "littlejs.esm" {
|
|
|
1664
1669
|
getMirrorSign(): number;
|
|
1665
1670
|
/** Attaches a child to this with a given local transform
|
|
1666
1671
|
* @param {EngineObject} child
|
|
1667
|
-
* @param {Vector2} [localPos=
|
|
1672
|
+
* @param {Vector2} [localPos=(0,0)]
|
|
1668
1673
|
* @param {Number} [localAngle] */
|
|
1669
1674
|
addChild(child: EngineObject, localPos?: Vector2, localAngle?: number): void;
|
|
1670
1675
|
/** Removes a child from this one
|
|
@@ -1714,7 +1719,7 @@ declare module "littlejs.esm" {
|
|
|
1714
1719
|
export function getTileCollisionData(pos: Vector2): number;
|
|
1715
1720
|
/** Check if collision with another object should occur
|
|
1716
1721
|
* @param {Vector2} pos
|
|
1717
|
-
* @param {Vector2} [size=
|
|
1722
|
+
* @param {Vector2} [size=(1,1)]
|
|
1718
1723
|
* @param {EngineObject} [object]
|
|
1719
1724
|
* @return {Boolean}
|
|
1720
1725
|
* @memberof TileCollision */
|
|
@@ -1768,11 +1773,11 @@ declare module "littlejs.esm" {
|
|
|
1768
1773
|
*/
|
|
1769
1774
|
export class TileLayer extends EngineObject {
|
|
1770
1775
|
/** Create a tile layer object
|
|
1771
|
-
* @param {Vector2} [position=
|
|
1776
|
+
* @param {Vector2} [position=(0,0)] - World space position
|
|
1772
1777
|
* @param {Vector2} [size=tileCollisionSize] - World space size
|
|
1773
|
-
* @param {TileInfo} [tileInfo]
|
|
1774
|
-
* @param {Vector2} [scale=
|
|
1775
|
-
* @param {Number} [renderOrder]
|
|
1778
|
+
* @param {TileInfo} [tileInfo] - Tile info for layer
|
|
1779
|
+
* @param {Vector2} [scale=(1,1)] - How much to scale this layer when rendered
|
|
1780
|
+
* @param {Number} [renderOrder] - Objects are sorted by renderOrder
|
|
1776
1781
|
*/
|
|
1777
1782
|
constructor(position?: Vector2, size?: Vector2, tileInfo?: TileInfo, scale?: Vector2, renderOrder?: number);
|
|
1778
1783
|
/** @property {HTMLCanvasElement} - The canvas used by this tile layer */
|
|
@@ -1794,21 +1799,23 @@ declare module "littlejs.esm" {
|
|
|
1794
1799
|
* @return {TileLayerData} */
|
|
1795
1800
|
getData(layerPos: Vector2): TileLayerData;
|
|
1796
1801
|
/** Draw all the tile data to an offscreen canvas
|
|
1797
|
-
* - This may be slow in some browsers
|
|
1798
|
-
*/
|
|
1802
|
+
* - This may be slow in some browsers but only needs to be done once */
|
|
1799
1803
|
redraw(): void;
|
|
1800
1804
|
/** Call to start the redraw process
|
|
1805
|
+
* - This can be used to manually update small parts of the level
|
|
1801
1806
|
* @param {Boolean} [clear] - Should it clear the canvas before drawing */
|
|
1802
1807
|
redrawStart(clear?: boolean): void;
|
|
1803
1808
|
/** @type {[HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number]} */
|
|
1804
1809
|
savedRenderSettings: [HTMLCanvasElement, CanvasRenderingContext2D, Vector2, Vector2, number];
|
|
1805
1810
|
/** Call to end the redraw process */
|
|
1806
1811
|
redrawEnd(): void;
|
|
1807
|
-
/** Draw the tile at a given position
|
|
1808
|
-
*
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
+
/** Draw the tile at a given position in the tile grid
|
|
1813
|
+
* This can be used to clear out tiles when they are destroyed
|
|
1814
|
+
* Tiles can also be redrawn if isinde a redrawStart/End block
|
|
1815
|
+
* @param {Vector2} layerPos
|
|
1816
|
+
* @param {Boolean} [clear] - should the old tile be cleared out
|
|
1817
|
+
*/
|
|
1818
|
+
drawTileData(layerPos: Vector2, clear?: boolean): void;
|
|
1812
1819
|
/** Draw directly to the 2D canvas in world space (bipass webgl)
|
|
1813
1820
|
* @param {Vector2} pos
|
|
1814
1821
|
* @param {Vector2} size
|
|
@@ -1816,18 +1823,18 @@ declare module "littlejs.esm" {
|
|
|
1816
1823
|
* @param {Boolean} mirror
|
|
1817
1824
|
* @param {Function} drawFunction */
|
|
1818
1825
|
drawCanvas2D(pos: Vector2, size: Vector2, angle: number, mirror: boolean, drawFunction: Function): void;
|
|
1819
|
-
/** Draw a tile directly onto the layer canvas
|
|
1826
|
+
/** Draw a tile directly onto the layer canvas in world space
|
|
1820
1827
|
* @param {Vector2} pos
|
|
1821
|
-
* @param {Vector2} [size=
|
|
1828
|
+
* @param {Vector2} [size=(1,1)]
|
|
1822
1829
|
* @param {TileInfo} [tileInfo]
|
|
1823
|
-
* @param {Color} [color=
|
|
1830
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1824
1831
|
* @param {Number} [angle=0]
|
|
1825
1832
|
* @param {Boolean} [mirror=0] */
|
|
1826
1833
|
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
1827
|
-
/** Draw a rectangle directly onto the layer canvas
|
|
1834
|
+
/** Draw a rectangle directly onto the layer canvas in world space
|
|
1828
1835
|
* @param {Vector2} pos
|
|
1829
|
-
* @param {Vector2} [size=
|
|
1830
|
-
* @param {Color} [color=
|
|
1836
|
+
* @param {Vector2} [size=(1,1)]
|
|
1837
|
+
* @param {Color} [color=(1,1,1,1)]
|
|
1831
1838
|
* @param {Number} [angle=0] */
|
|
1832
1839
|
drawRect(pos: Vector2, size?: Vector2, color?: Color, angle?: number): void;
|
|
1833
1840
|
}
|
|
@@ -1840,12 +1847,12 @@ declare module "littlejs.esm" {
|
|
|
1840
1847
|
* @example
|
|
1841
1848
|
* // create a particle emitter
|
|
1842
1849
|
* let pos = vec2(2,3);
|
|
1843
|
-
* let
|
|
1850
|
+
* let particleEmitter = new ParticleEmitter
|
|
1844
1851
|
* (
|
|
1845
|
-
* pos, 0, 1, 0, 500, PI,
|
|
1846
|
-
* tile(0, 16),
|
|
1847
|
-
*
|
|
1848
|
-
*
|
|
1852
|
+
* pos, 0, 1, 0, 500, PI, // pos, angle, emitSize, emitTime, emitRate, emiteCone
|
|
1853
|
+
* tile(0, 16), // tileInfo
|
|
1854
|
+
* rgb(1,1,1), rgb(0,0,0), // colorStartA, colorStartB
|
|
1855
|
+
* rgb(1,1,1,0), rgb(0,0,0,0), // colorEndA, colorEndB
|
|
1849
1856
|
* 2, .2, .2, .1, .05, // particleTime, sizeStart, sizeEnd, particleSpeed, particleAngleSpeed
|
|
1850
1857
|
* .99, 1, 1, PI, .05, // damping, angleDamping, gravityScale, particleCone, fadeRate,
|
|
1851
1858
|
* .5, 1 // randomness, collide, additive, randomColorLinear, renderOrder
|
|
@@ -1860,10 +1867,10 @@ declare module "littlejs.esm" {
|
|
|
1860
1867
|
* @param {Number} [emitRate] - How many particles per second to spawn, does not emit if 0
|
|
1861
1868
|
* @param {Number} [emitConeAngle=PI] - Local angle to apply velocity to particles from emitter
|
|
1862
1869
|
* @param {TileInfo} [tileInfo] - Tile info to render particles (undefined is untextured)
|
|
1863
|
-
* @param {Color} [colorStartA=
|
|
1864
|
-
* @param {Color} [colorStartB=
|
|
1865
|
-
* @param {Color} [colorEndA=
|
|
1866
|
-
* @param {Color} [colorEndB=
|
|
1870
|
+
* @param {Color} [colorStartA=(1,1,1,1)] - Color at start of life 1, randomized between start colors
|
|
1871
|
+
* @param {Color} [colorStartB=(1,1,1,1)] - Color at start of life 2, randomized between start colors
|
|
1872
|
+
* @param {Color} [colorEndA=(1,1,1,0)] - Color at end of life 1, randomized between end colors
|
|
1873
|
+
* @param {Color} [colorEndB=(1,1,1,0)] - Color at end of life 2, randomized between end colors
|
|
1867
1874
|
* @param {Number} [particleTime] - How long particles live
|
|
1868
1875
|
* @param {Number} [sizeStart] - How big are particles at start
|
|
1869
1876
|
* @param {Number} [sizeEnd] - How big are particles at end
|