littlejsengine 1.14.5 → 1.14.8
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 +53 -19
- package/dist/littlejs.esm.js +183 -106
- package/dist/littlejs.esm.min.js +1 -1
- package/dist/littlejs.js +179 -104
- package/dist/littlejs.min.js +1 -1
- package/dist/littlejs.release.js +178 -103
- package/examples/box2d/game.js +1 -3
- package/examples/box2d/gameObjects.js +2 -2
- package/examples/htmlMenu/game.js +1 -1
- package/examples/index.html +92 -51
- package/examples/puzzle/game.js +1 -2
- package/examples/shorts/animation.js +2 -2
- package/examples/shorts/box2d.js +1 -0
- package/examples/shorts/box2dCar.js +1 -0
- package/examples/shorts/flappyGame.js +2 -1
- package/examples/shorts/helloWorld.js +2 -2
- package/examples/shorts/hillGlideGame.js +6 -3
- package/examples/shorts/maze.js +1 -0
- package/examples/shorts/medals.js +3 -0
- package/examples/shorts/music.js +3 -5
- package/examples/shorts/piano.js +24 -25
- package/examples/shorts/platformer.js +1 -0
- package/examples/shorts/shapes.js +6 -6
- package/examples/shorts/sound.js +21 -32
- package/examples/shorts/spriteAtlas.js +1 -2
- package/examples/shorts/tileLayer.js +1 -0
- package/examples/shorts/tiltedView.js +1 -1
- package/examples/shorts/timers.js +34 -31
- package/examples/shorts/topDown.js +2 -1
- package/examples/shorts/uiSystem.js +15 -10
- package/examples/stress/index.html +1 -1
- package/examples/uiSystem/game.js +1 -1
- package/package.json +1 -1
- package/plugins/uiSystem.js +83 -58
- package/reference.md +1 -0
- package/src/engine.js +23 -6
- package/src/engineDebug.js +1 -1
- package/src/engineDraw.js +19 -12
- package/src/engineExport.js +4 -2
- package/src/engineInput.js +7 -0
- package/src/engineObject.js +4 -4
- package/src/engineSettings.js +11 -1
- package/src/engineTileLayer.js +2 -2
- package/src/engineUtilities.js +9 -2
- package/src/engineWebGL.js +20 -18
package/dist/littlejs.d.ts
CHANGED
|
@@ -268,6 +268,10 @@ declare module "littlejsengine" {
|
|
|
268
268
|
* @default
|
|
269
269
|
* @memberof Settings */
|
|
270
270
|
export let canvasColorTiles: boolean;
|
|
271
|
+
/** Color to clear the canvas to before render
|
|
272
|
+
* @type {Color}
|
|
273
|
+
* @memberof Draw */
|
|
274
|
+
export let canvasClearColor: Color;
|
|
271
275
|
/** The max size of the canvas, centered if window is larger
|
|
272
276
|
* @type {Vector2}
|
|
273
277
|
* @default Vector2(1920,1080)
|
|
@@ -467,6 +471,10 @@ declare module "littlejsengine" {
|
|
|
467
471
|
* @param {boolean} colorTiles
|
|
468
472
|
* @memberof Settings */
|
|
469
473
|
export function setCanvasColorTiles(colorTiles: boolean): void;
|
|
474
|
+
/** Set color to clear the canvas to before render
|
|
475
|
+
* @param {Color} color
|
|
476
|
+
* @memberof Settings */
|
|
477
|
+
export function setCanvasClearColor(color: Color): void;
|
|
470
478
|
/** Set max size of the canvas
|
|
471
479
|
* @param {Vector2} size
|
|
472
480
|
* @memberof Settings */
|
|
@@ -1105,6 +1113,9 @@ declare module "littlejsengine" {
|
|
|
1105
1113
|
/** Get percentage elapsed based on time it was set to, returns 0 if not set
|
|
1106
1114
|
* @return {number} */
|
|
1107
1115
|
getPercent(): number;
|
|
1116
|
+
/** Get the time this timer was set to, returns 0 if not set
|
|
1117
|
+
* @return {number} */
|
|
1118
|
+
getSetTime(): number;
|
|
1108
1119
|
/** Returns this timer expressed as a string
|
|
1109
1120
|
* @return {string} */
|
|
1110
1121
|
toString(): string;
|
|
@@ -1212,14 +1223,6 @@ declare module "littlejsengine" {
|
|
|
1212
1223
|
* @type {Color}
|
|
1213
1224
|
* @memberof Utilities */
|
|
1214
1225
|
export const MAGENTA: Color;
|
|
1215
|
-
/** Array containing texture info for batch rendering system
|
|
1216
|
-
* @type {Array<TextureInfo>}
|
|
1217
|
-
* @memberof Draw */
|
|
1218
|
-
export let textureInfos: Array<TextureInfo>;
|
|
1219
|
-
/** Keeps track of how many draw calls there were each frame for debugging
|
|
1220
|
-
* @type {number}
|
|
1221
|
-
* @memberof Draw */
|
|
1222
|
-
export let drawCount: number;
|
|
1223
1226
|
/**
|
|
1224
1227
|
* Create a tile info object using a grid based system
|
|
1225
1228
|
* - This can take vecs or floats for easier use and conversion
|
|
@@ -1245,8 +1248,9 @@ declare module "littlejsengine" {
|
|
|
1245
1248
|
* @param {Vector2} [size=tileSizeDefault] - Size of tile in pixels
|
|
1246
1249
|
* @param {number} [textureIndex] - Texture index to use
|
|
1247
1250
|
* @param {number} [padding] - How many pixels padding around tiles
|
|
1251
|
+
* @param {number} [bleedScale] - How many pixels smaller to draw tiles
|
|
1248
1252
|
*/
|
|
1249
|
-
constructor(pos?: Vector2, size?: Vector2, textureIndex?: number, padding?: number);
|
|
1253
|
+
constructor(pos?: Vector2, size?: Vector2, textureIndex?: number, padding?: number, bleedScale?: number);
|
|
1250
1254
|
/** @property {Vector2} - Top left corner of tile in pixels */
|
|
1251
1255
|
pos: Vector2;
|
|
1252
1256
|
/** @property {Vector2} - Size of tile in pixels */
|
|
@@ -1257,6 +1261,8 @@ declare module "littlejsengine" {
|
|
|
1257
1261
|
padding: number;
|
|
1258
1262
|
/** @property {TextureInfo} - The texture info for this tile */
|
|
1259
1263
|
textureInfo: TextureInfo;
|
|
1264
|
+
/** @property {float} - Shrinks tile by this many pixels to prevent neighbors bleeding */
|
|
1265
|
+
bleedScale: number;
|
|
1260
1266
|
/** Returns a copy of this tile offset by a vector
|
|
1261
1267
|
* @param {Vector2} offset - Offset to apply in pixels
|
|
1262
1268
|
* @return {TileInfo}
|
|
@@ -1342,6 +1348,14 @@ declare module "littlejsengine" {
|
|
|
1342
1348
|
* @type {Vector2}
|
|
1343
1349
|
* @memberof Draw */
|
|
1344
1350
|
export let mainCanvasSize: Vector2;
|
|
1351
|
+
/** Array containing texture info for batch rendering system
|
|
1352
|
+
* @type {Array<TextureInfo>}
|
|
1353
|
+
* @memberof Draw */
|
|
1354
|
+
export let textureInfos: Array<TextureInfo>;
|
|
1355
|
+
/** Keeps track of how many draw calls there were each frame for debugging
|
|
1356
|
+
* @type {number}
|
|
1357
|
+
* @memberof Draw */
|
|
1358
|
+
export let drawCount: number;
|
|
1345
1359
|
/** Convert from screen to world space coordinates
|
|
1346
1360
|
* @param {Vector2} screenPos
|
|
1347
1361
|
* @return {Vector2}
|
|
@@ -1533,7 +1547,7 @@ declare module "littlejsengine" {
|
|
|
1533
1547
|
* @param {Vector2} pos
|
|
1534
1548
|
* @param {number} [scale=.25]
|
|
1535
1549
|
* @param {boolean} [center]
|
|
1536
|
-
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D}[context=drawContext]
|
|
1550
|
+
* @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
|
|
1537
1551
|
*/
|
|
1538
1552
|
drawText(text: string, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
|
|
1539
1553
|
/** Draw text on overlay canvas in world space using the image font
|
|
@@ -1609,6 +1623,7 @@ declare module "littlejsengine" {
|
|
|
1609
1623
|
* @memberof WebGL */
|
|
1610
1624
|
export function glCreateProgram(vsSource: string, fsSource: string): WebGLProgram;
|
|
1611
1625
|
/** Create WebGL texture from an image and init the texture settings
|
|
1626
|
+
* Restores the active texture when done
|
|
1612
1627
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} [image]
|
|
1613
1628
|
* @return {WebGLTexture}
|
|
1614
1629
|
* @memberof WebGL */
|
|
@@ -1617,7 +1632,7 @@ declare module "littlejsengine" {
|
|
|
1617
1632
|
* @param {WebGLTexture} [texture]
|
|
1618
1633
|
* @memberof WebGL */
|
|
1619
1634
|
export function glDeleteTexture(texture?: WebGLTexture): void;
|
|
1620
|
-
/** Set WebGL texture data from an image
|
|
1635
|
+
/** Set WebGL texture data from an image, restores the active texture when done
|
|
1621
1636
|
* @param {WebGLTexture} texture
|
|
1622
1637
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} image
|
|
1623
1638
|
* @memberof WebGL */
|
|
@@ -2364,7 +2379,7 @@ declare module "littlejsengine" {
|
|
|
2364
2379
|
* @param {TileInfo} [tileInfo]
|
|
2365
2380
|
* @param {Color} [color=(1,1,1,1)]
|
|
2366
2381
|
* @param {number} [angle=0]
|
|
2367
|
-
* @param {boolean} [mirror=
|
|
2382
|
+
* @param {boolean} [mirror=false] */
|
|
2368
2383
|
drawTile(pos: Vector2, size?: Vector2, tileInfo?: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
|
|
2369
2384
|
/** Draw a rectangle onto the layer canvas in world space
|
|
2370
2385
|
* @param {Vector2} pos
|
|
@@ -2859,6 +2874,8 @@ declare module "littlejsengine" {
|
|
|
2859
2874
|
defaultLineWidth: number;
|
|
2860
2875
|
/** @property {number} - Default rounded rect corner radius for UI elements */
|
|
2861
2876
|
defaultCornerRadius: number;
|
|
2877
|
+
/** @property {number} - Default scale to use for fitting text to object */
|
|
2878
|
+
defaultTextScale: number;
|
|
2862
2879
|
/** @property {string} - Default font for UI elements */
|
|
2863
2880
|
defaultFont: string;
|
|
2864
2881
|
/** @property {Sound} - Default sound when interactive UI element is pressed */
|
|
@@ -2871,6 +2888,10 @@ declare module "littlejsengine" {
|
|
|
2871
2888
|
uiObjects: any[];
|
|
2872
2889
|
/** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
|
|
2873
2890
|
uiContext: CanvasRenderingContext2D;
|
|
2891
|
+
/** @property {UIObject} - Top most object user is over */
|
|
2892
|
+
hoverObject: any;
|
|
2893
|
+
/** @property {UIObject} - Object user is currently interacting with */
|
|
2894
|
+
activeObject: any;
|
|
2874
2895
|
/** Draw a rectangle to the UI context
|
|
2875
2896
|
* @param {Vector2} pos
|
|
2876
2897
|
* @param {Vector2} size
|
|
@@ -2901,8 +2922,9 @@ declare module "littlejsengine" {
|
|
|
2901
2922
|
* @param {number} [lineWidth=uiSystem.defaultLineWidth]
|
|
2902
2923
|
* @param {Color} [lineColor=uiSystem.defaultLineColor]
|
|
2903
2924
|
* @param {string} [align]
|
|
2904
|
-
* @param {string} [font=uiSystem.defaultFont]
|
|
2905
|
-
|
|
2925
|
+
* @param {string} [font=uiSystem.defaultFont]
|
|
2926
|
+
* @param {boolean} [applyMaxWidth=true] */
|
|
2927
|
+
drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, applyMaxWidth?: boolean): void;
|
|
2906
2928
|
}
|
|
2907
2929
|
/**
|
|
2908
2930
|
* UI Object - Base level object for all UI elements
|
|
@@ -2921,6 +2943,8 @@ declare module "littlejsengine" {
|
|
|
2921
2943
|
size: Vector2;
|
|
2922
2944
|
/** @property {Color} - Color of the object */
|
|
2923
2945
|
color: Color;
|
|
2946
|
+
/** @property {Color} - Color of the object when active, uses color if undefined */
|
|
2947
|
+
activeColor: any;
|
|
2924
2948
|
/** @property {string} - Text for this ui object */
|
|
2925
2949
|
text: any;
|
|
2926
2950
|
/** @property {Color} - Color when disabled */
|
|
@@ -2939,15 +2963,19 @@ declare module "littlejsengine" {
|
|
|
2939
2963
|
cornerRadius: number;
|
|
2940
2964
|
/** @property {string} - Font for this objecct */
|
|
2941
2965
|
font: string;
|
|
2966
|
+
/** @property {number} - Override for text width */
|
|
2967
|
+
textWidth: any;
|
|
2942
2968
|
/** @property {number} - Override for text height */
|
|
2943
2969
|
textHeight: any;
|
|
2970
|
+
/** @property {number} - Scale text to fit in the object */
|
|
2971
|
+
textScale: number;
|
|
2944
2972
|
/** @property {boolean} - Should this object be drawn */
|
|
2945
2973
|
visible: boolean;
|
|
2946
2974
|
/** @property {Array<UIObject>} - A list of this object's children */
|
|
2947
2975
|
children: any[];
|
|
2948
2976
|
/** @property {UIObject} - This object's parent, position is in parent space */
|
|
2949
2977
|
parent: any;
|
|
2950
|
-
/** @property {number} -
|
|
2978
|
+
/** @property {number} - Added size to make small buttons easier to touch on mobile devices */
|
|
2951
2979
|
extraTouchSize: number;
|
|
2952
2980
|
/** @property {Sound} - Sound when interactive element is pressed */
|
|
2953
2981
|
soundPress: any;
|
|
@@ -2955,12 +2983,10 @@ declare module "littlejsengine" {
|
|
|
2955
2983
|
soundRelease: any;
|
|
2956
2984
|
/** @property {Sound} - Sound when interactive element is clicked */
|
|
2957
2985
|
soundClick: any;
|
|
2958
|
-
/** @property {boolean} - Is the mouse over this element */
|
|
2959
|
-
mouseIsOver: boolean;
|
|
2960
2986
|
/** @property {boolean} - Is this element interactive */
|
|
2961
2987
|
interactive: boolean;
|
|
2962
|
-
/** @property {boolean} -
|
|
2963
|
-
|
|
2988
|
+
/** @property {boolean} - Activate when dragged over with mouse held down */
|
|
2989
|
+
dragActivate: boolean;
|
|
2964
2990
|
/** Add a child UIObject to this object
|
|
2965
2991
|
* @param {UIObject} child
|
|
2966
2992
|
*/
|
|
@@ -2975,6 +3001,14 @@ declare module "littlejsengine" {
|
|
|
2975
3001
|
render(): void;
|
|
2976
3002
|
/** Special update when object is not visible */
|
|
2977
3003
|
updateInvisible(): void;
|
|
3004
|
+
/** Get the size for text with overrides and scale
|
|
3005
|
+
* @return {Vector2}
|
|
3006
|
+
*/
|
|
3007
|
+
getTextSize(): Vector2;
|
|
3008
|
+
/** @return {boolean} - Is the mouse hovering over this element */
|
|
3009
|
+
isHoverObject(): boolean;
|
|
3010
|
+
/** @return {boolean} - Is the mouse held onto this element */
|
|
3011
|
+
isActiveObject(): boolean;
|
|
2978
3012
|
/** Called when the mouse enters the object */
|
|
2979
3013
|
onEnter(): void;
|
|
2980
3014
|
/** Called when the mouse leaves the object */
|