littlejsengine 1.15.3 → 1.15.9

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.
@@ -133,6 +133,7 @@ declare module "littlejsengine" {
133
133
  * @memberof Engine */
134
134
  export function engineInit(gameInit: GameInitCallback, gameUpdate: GameCallback, gameUpdatePost: GameCallback, gameRender: GameCallback, gameRenderPost: GameCallback, imageSources?: Array<string>, rootElement?: HTMLElement): Promise<void>;
135
135
  /** Update each engine object, remove destroyed objects, and update time
136
+ * can be called manually if objects need to be updated outside of main loop
136
137
  * @memberof Engine */
137
138
  export function engineObjectsUpdate(): void;
138
139
  /** Destroy and remove all objects
@@ -266,7 +267,7 @@ declare module "littlejsengine" {
266
267
  * @memberof Debug */
267
268
  export function debugOverlap(posA: Vector2, sizeA: Vector2, posB: Vector2, sizeB: Vector2, color?: Color | string, time?: number, screenSpace?: boolean): void;
268
269
  /** Draw a debug axis aligned bounding box in world space
269
- * @param {string} text
270
+ * @param {string|number} text
270
271
  * @param {Vector2} pos
271
272
  * @param {number} [size]
272
273
  * @param {Color|string} [color]
@@ -275,7 +276,7 @@ declare module "littlejsengine" {
275
276
  * @param {string} [font]
276
277
  * @param {boolean} [screenSpace]
277
278
  * @memberof Debug */
278
- export function debugText(text: string, pos: Vector2, size?: number, color?: Color | string, time?: number, angle?: number, font?: string, screenSpace?: boolean): void;
279
+ export function debugText(text: string | number, pos: Vector2, size?: number, color?: Color | string, time?: number, angle?: number, font?: string, screenSpace?: boolean): void;
279
280
  /** Clear all debug primitives in the list
280
281
  * @memberof Debug */
281
282
  export function debugClear(): void;
@@ -348,6 +349,18 @@ declare module "littlejsengine" {
348
349
  * @default Vector2(1920,1080)
349
350
  * @memberof Settings */
350
351
  export let canvasMaxSize: Vector2;
352
+ /** Minimum aspect ratio of the canvas (width/height), unused if 0
353
+ * Can be used with canvasMaxAspect to limit aspect ratio
354
+ * @type {number}
355
+ * @default
356
+ * @memberof Settings */
357
+ export let canvasMinAspect: number;
358
+ /** Maximum aspect ratio of the canvas (width/height), unused if 0
359
+ * Can be used with canvasMinAspect to limit aspect ratio
360
+ * @type {number}
361
+ * @default
362
+ * @memberof Settings */
363
+ export let canvasMaxAspect: number;
351
364
  /** Fixed size of the canvas, if enabled canvas size never changes
352
365
  * - you may also need to set mainCanvasSize if using screen space coords in startup
353
366
  * @type {Vector2}
@@ -557,6 +570,14 @@ declare module "littlejsengine" {
557
570
  * @param {Vector2} size
558
571
  * @memberof Settings */
559
572
  export function setCanvasMaxSize(size: Vector2): void;
573
+ /** Set minimum aspect ratio of the canvas (width/height), unused if 0
574
+ * @param {number} aspect
575
+ * @memberof Settings */
576
+ export function setCanvasMinAspect(aspect: number): void;
577
+ /** Set maximum aspect ratio of the canvas (width/height), unused if 0
578
+ * @param {number} aspect
579
+ * @memberof Settings */
580
+ export function setCanvasMaxAspect(aspect: number): void;
560
581
  /** Set fixed size of the canvas
561
582
  * @param {Vector2} size
562
583
  * @memberof Settings */
@@ -661,6 +682,10 @@ declare module "littlejsengine" {
661
682
  * @param {boolean} enable
662
683
  * @memberof Settings */
663
684
  export function setTouchGamepadCenterButton(enable: boolean): void;
685
+ /** Set number of buttons on touch gamepad (0-4), if 1 also acts as right analog stick
686
+ * @param {number} count
687
+ * @memberof Settings */
688
+ export function setTouchGamepadButtonCount(count: number): void;
664
689
  /** Set if touch gamepad should be analog stick or 8 way dpad
665
690
  * @param {boolean} analog
666
691
  * @memberof Settings */
@@ -1023,6 +1048,10 @@ declare module "littlejsengine" {
1023
1048
  * @param {number} [y] - Y axis location
1024
1049
  * @return {Vector2} */
1025
1050
  set(x?: number, y?: number): Vector2;
1051
+ /** Sets this vector from another vector and returns self
1052
+ * @param {Vector2} v - other vector
1053
+ * @return {Vector2} */
1054
+ setFrom(v: Vector2): Vector2;
1026
1055
  /** Returns a new vector that is a copy of this
1027
1056
  * @return {Vector2} */
1028
1057
  copy(): Vector2;
@@ -1114,6 +1143,9 @@ declare module "littlejsengine" {
1114
1143
  /** Returns the area this vector covers as a rectangle
1115
1144
  * @return {number} */
1116
1145
  area(): number;
1146
+ /** Returns true if this vector is (0,0)
1147
+ * @return {boolean} */
1148
+ isZero(): boolean;
1117
1149
  /** Returns a new vector that is p percent between this and the vector passed in
1118
1150
  * @param {Vector2} v - other vector
1119
1151
  * @param {number} percent
@@ -1163,6 +1195,10 @@ declare module "littlejsengine" {
1163
1195
  * @param {number} [a] - alpha
1164
1196
  * @return {Color} */
1165
1197
  set(r?: number, g?: number, b?: number, a?: number): Color;
1198
+ /** Sets this color from another color and returns self
1199
+ * @param {Color} c - other color
1200
+ * @return {Color} */
1201
+ setFrom(c: Color): Color;
1166
1202
  /** Returns a new color that is a copy of this
1167
1203
  * @return {Color} */
1168
1204
  copy(): Color;
@@ -1430,7 +1466,7 @@ declare module "littlejsengine" {
1430
1466
  padding: number;
1431
1467
  /** @property {TextureInfo} - The texture info for this tile */
1432
1468
  textureInfo: TextureInfo;
1433
- /** @property {float} - Shrinks tile by this many pixels to prevent neighbors bleeding */
1469
+ /** @property {number} - Shrinks tile by this many pixels to prevent neighbors bleeding */
1434
1470
  bleedScale: number;
1435
1471
  /** Returns a copy of this tile offset by a vector
1436
1472
  * @param {Vector2} offset - Offset to apply in pixels
@@ -1663,7 +1699,7 @@ declare module "littlejsengine" {
1663
1699
  export function drawCanvas2D(pos: Vector2, size: Vector2, angle?: number, mirror?: boolean, drawFunction?: Canvas2DDrawFunction, screenSpace?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1664
1700
  /** Draw text on main canvas in world space
1665
1701
  * Automatically splits new lines into rows
1666
- * @param {string} text
1702
+ * @param {string|number} text
1667
1703
  * @param {Vector2} pos
1668
1704
  * @param {number} [size]
1669
1705
  * @param {Color} [color=(1,1,1,1)]
@@ -1676,10 +1712,10 @@ declare module "littlejsengine" {
1676
1712
  * @param {number} [angle]
1677
1713
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
1678
1714
  * @memberof Draw */
1679
- export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1715
+ export function drawText(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;
1680
1716
  /** Draw text on overlay canvas in world space
1681
1717
  * Automatically splits new lines into rows
1682
- * @param {string} text
1718
+ * @param {string|number} text
1683
1719
  * @param {Vector2} pos
1684
1720
  * @param {number} [size]
1685
1721
  * @param {Color} [color=(1,1,1,1)]
@@ -1691,10 +1727,10 @@ declare module "littlejsengine" {
1691
1727
  * @param {number} [maxWidth]
1692
1728
  * @param {number} [angle]
1693
1729
  * @memberof Draw */
1694
- export function drawTextOverlay(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number): void;
1730
+ export function drawTextOverlay(text: string | number, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number): void;
1695
1731
  /** Draw text on overlay canvas in screen space
1696
1732
  * Automatically splits new lines into rows
1697
- * @param {string} text
1733
+ * @param {string|number} text
1698
1734
  * @param {Vector2} pos
1699
1735
  * @param {number} [size]
1700
1736
  * @param {Color} [color=(1,1,1,1)]
@@ -1707,7 +1743,7 @@ declare module "littlejsengine" {
1707
1743
  * @param {number} [angle]
1708
1744
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=overlayContext]
1709
1745
  * @memberof Draw */
1710
- export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: CanvasTextAlign, font?: string, fontStyle?: string, maxWidth?: number, angle?: number, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1746
+ 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;
1711
1747
  /** Enable normal or additive blend mode
1712
1748
  * @param {boolean} [additive]
1713
1749
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context]
@@ -1742,28 +1778,28 @@ declare module "littlejsengine" {
1742
1778
  tileSize: Vector2;
1743
1779
  paddingSize: Vector2;
1744
1780
  /** Draw text in world space using the image font
1745
- * @param {string} text
1781
+ * @param {string|number} text
1746
1782
  * @param {Vector2} pos
1747
1783
  * @param {number} [scale=.25]
1748
1784
  * @param {boolean} [center]
1749
1785
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
1750
1786
  */
1751
- drawText(text: string, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1787
+ drawText(text: string | number, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1752
1788
  /** Draw text on overlay canvas in world space using the image font
1753
- * @param {string} text
1789
+ * @param {string|number} text
1754
1790
  * @param {Vector2} pos
1755
1791
  * @param {number} [scale]
1756
1792
  * @param {boolean} [center]
1757
1793
  */
1758
- drawTextOverlay(text: string, pos: Vector2, scale?: number, center?: boolean): void;
1794
+ drawTextOverlay(text: string | number, pos: Vector2, scale?: number, center?: boolean): void;
1759
1795
  /** Draw text on overlay canvas in screen space using the image font
1760
- * @param {string} text
1796
+ * @param {string|number} text
1761
1797
  * @param {Vector2} pos
1762
1798
  * @param {number} [scale]
1763
1799
  * @param {boolean} [center]
1764
1800
  * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context=drawContext]
1765
1801
  */
1766
- drawTextScreen(text: string, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1802
+ drawTextScreen(text: string | number, pos: Vector2, scale?: number, center?: boolean, context?: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D): void;
1767
1803
  }
1768
1804
  /** Returns true if fullscreen mode is active
1769
1805
  * @return {boolean}
@@ -1776,7 +1812,7 @@ declare module "littlejsengine" {
1776
1812
  * @param {string} [cursorStyle] - CSS cursor style (auto, none, crosshair, etc)
1777
1813
  * @memberof Draw */
1778
1814
  export function setCursor(cursorStyle?: string): void;
1779
- /** Get the camera's visible area in world space
1815
+ /** Get the size of the camera window in world space
1780
1816
  * @return {Vector2}
1781
1817
  * @memberof Draw */
1782
1818
  export function getCameraSize(): Vector2;
@@ -1910,15 +1946,6 @@ declare module "littlejsengine" {
1910
1946
  export let glPositionData: any;
1911
1947
  export let glColorData: any;
1912
1948
  export let glBatchCount: any;
1913
- /**
1914
- * LittleJS Input System
1915
- * - Tracks keyboard down, pressed, and released
1916
- * - Tracks mouse buttons, position, and wheel
1917
- * - Tracks multiple analog gamepads
1918
- * - Touch input is handled as mouse input
1919
- * - Virtual gamepad for touch devices
1920
- * @namespace Input
1921
- */
1922
1949
  /** Returns true if device key is down
1923
1950
  * @param {string|number} key
1924
1951
  * @param {number} [device]
@@ -1938,6 +1965,10 @@ declare module "littlejsengine" {
1938
1965
  * @memberof Input */
1939
1966
  export function keyWasReleased(key: string | number, device?: number): boolean;
1940
1967
  /** Returns input vector from arrow keys or WASD if enabled
1968
+ * @param {string} [up]
1969
+ * @param {string} [down]
1970
+ * @param {string} [left]
1971
+ * @param {string} [right]
1941
1972
  * @return {Vector2}
1942
1973
  * @memberof Input */
1943
1974
  export function keyDirection(up?: string, down?: string, left?: string, right?: string): Vector2;
@@ -1970,6 +2001,15 @@ declare module "littlejsengine" {
1970
2001
  * @return {boolean}
1971
2002
  * @memberof Input */
1972
2003
  export function mouseWasReleased(button: number): boolean;
2004
+ /**
2005
+ * LittleJS Input System
2006
+ * - Tracks keyboard down, pressed, and released
2007
+ * - Tracks mouse buttons, position, and wheel
2008
+ * - Tracks multiple analog gamepads
2009
+ * - Touch input is handled as mouse input
2010
+ * - Virtual gamepad for touch devices
2011
+ * @namespace Input
2012
+ */
1973
2013
  /** Mouse pos in world space
1974
2014
  * @type {Vector2}
1975
2015
  * @memberof Input */
@@ -2002,6 +2042,10 @@ declare module "littlejsengine" {
2002
2042
  * @type {boolean}
2003
2043
  * @memberof Input */
2004
2044
  export let inputPreventDefault: boolean;
2045
+ /** Primary gamepad index, automatically set to first gamepad with input
2046
+ * @type {number}
2047
+ * @memberof Input */
2048
+ export let gamepadPrimary: number;
2005
2049
  /** Prevents input continuing to the default browser handling
2006
2050
  * This is useful to disable for html menus so the browser can handle input normally
2007
2051
  * @param {boolean} preventDefault
@@ -2031,7 +2075,16 @@ declare module "littlejsengine" {
2031
2075
  * @return {Vector2}
2032
2076
  * @memberof Input */
2033
2077
  export function gamepadStick(stick: number, gamepad?: number): Vector2;
2034
- export function gamepadsUpdate(): void;
2078
+ /** Returns gamepad dpad value
2079
+ * @param {number} [gamepad]
2080
+ * @return {Vector2}
2081
+ * @memberof Input */
2082
+ export function gamepadDpad(gamepad?: number): Vector2;
2083
+ /** Returns true if passed in gamepad is connected
2084
+ * @param {number} [gamepad]
2085
+ * @return {boolean}
2086
+ * @memberof Input */
2087
+ export function gamepadConnected(gamepad?: number): boolean;
2035
2088
  /** Pulse the vibration hardware if it exists
2036
2089
  * @param {number|Array} [pattern] - single value in ms or vibration interval array
2037
2090
  * @memberof Input */
@@ -2414,7 +2467,7 @@ declare module "littlejsengine" {
2414
2467
  collideRaycast: boolean;
2415
2468
  /** Update the object transform, called automatically by engine even when paused */
2416
2469
  updateTransforms(): void;
2417
- /** Update the object physics, called automatically by engine once each frame */
2470
+ /** Update the object physics, called automatically by engine once each frame. Can be overridden to stop or change how physics works for an object. */
2418
2471
  updatePhysics(): void;
2419
2472
  /** Update the object, called automatically by engine once each frame. Does nothing by default. */
2420
2473
  update(): void;
@@ -2526,7 +2579,7 @@ declare module "littlejsengine" {
2526
2579
  * @return {TileCollisionLayer}
2527
2580
  * @memberof TileLayers */
2528
2581
  export function tileCollisionTest(pos: Vector2, size?: Vector2, object?: EngineObject, solidOnly?: boolean): TileCollisionLayer;
2529
- /** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
2582
+ /** Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
2530
2583
  * The point will be inside the colliding tile if it hits (may have a tiny shift)
2531
2584
  * @param {Vector2} posStart
2532
2585
  * @param {Vector2} posEnd
@@ -2720,7 +2773,7 @@ declare module "littlejsengine" {
2720
2773
  * @param {EngineObject} [object]
2721
2774
  * @return {boolean} */
2722
2775
  collisionTest(pos: Vector2, size?: Vector2, object?: EngineObject): boolean;
2723
- /** Return the exact position of the boudnary of first tile hit, undefined if nothing was hit.
2776
+ /** Return the exact position of the boundary of first tile hit, undefined if nothing was hit.
2724
2777
  * The point will be inside the colliding tile if it hits (may have a tiny shift)
2725
2778
  * @param {Vector2} posStart
2726
2779
  * @param {Vector2} posEnd
@@ -3103,17 +3156,31 @@ declare module "littlejsengine" {
3103
3156
  /**
3104
3157
  * LittleJS User Interface Plugin
3105
3158
  * - call new UISystemPlugin() to setup the UI system
3159
+ * - Gamepad and keyboard navigation support
3106
3160
  * - Nested Menus
3107
3161
  * - Text
3108
3162
  * - Buttons
3109
3163
  * - Checkboxes
3110
3164
  * - Images
3165
+ * - Scrollbars
3166
+ * - Video
3111
3167
  * @namespace UISystem
3112
3168
  */
3113
3169
  /** Global UI system plugin object
3114
3170
  * @type {UISystemPlugin}
3115
3171
  * @memberof UISystem */
3116
3172
  export let uiSystem: UISystemPlugin;
3173
+ /** Enable UI system debug drawing
3174
+ * 0=off, 1=normal, 2=show invisible
3175
+ * @type {number}
3176
+ * @default
3177
+ * @memberof UISystem */
3178
+ export let uiDebug: number;
3179
+ /** Enable UI system debug drawing
3180
+ * 0=off, 1=normal, 2=show invisible
3181
+ * @param {number|boolean} enable
3182
+ * @memberof UISystem */
3183
+ export function uiSetDebug(debugMode: any): void;
3117
3184
  /**
3118
3185
  * UI System Global Object
3119
3186
  * @memberof UISystem
@@ -3145,7 +3212,7 @@ declare module "littlejsengine" {
3145
3212
  /** @property {number} - Default rounded rect corner radius for UI elements */
3146
3213
  defaultCornerRadius: number;
3147
3214
  /** @property {number} - Default scale to use for fitting text to object */
3148
- defaultTextScale: number;
3215
+ defaultTextFitScale: number;
3149
3216
  /** @property {string} - Default font for UI elements */
3150
3217
  defaultFont: string;
3151
3218
  /** @property {Sound} - Default sound when interactive UI element is pressed */
@@ -3160,6 +3227,18 @@ declare module "littlejsengine" {
3160
3227
  defaultShadowBlur: number;
3161
3228
  /** @property {Vector2} - Offset of shadow blur */
3162
3229
  defaultShadowOffset: Vector2;
3230
+ /** @property {number} - If set ui coords will be renormalized to this canvas height */
3231
+ nativeHeight: number;
3232
+ /** @property {UIObject} - Object currently selected by navigation (gamepad or keyboard) */
3233
+ navigationObject: any;
3234
+ /** @property {Timer} - Cooldown timer for navigation inputs */
3235
+ navigationTimer: Timer;
3236
+ /** @property {number} - Time between navigation inputs in seconds */
3237
+ navigationDelay: number;
3238
+ /** @property {boolean} - should the navigation be horizontal, vertical, or both? */
3239
+ navigationDirection: number;
3240
+ /** @property {boolean} - True if user last used navigation instead of mouse */
3241
+ navigationMode: boolean;
3163
3242
  /** @property {Array<UIObject>} - List of all UI elements */
3164
3243
  uiObjects: any[];
3165
3244
  /** @property {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} - Context to render UI elements to */
@@ -3170,8 +3249,8 @@ declare module "littlejsengine" {
3170
3249
  hoverObject: any;
3171
3250
  /** @property {UIObject} - Hover object at start of update */
3172
3251
  lastHoverObject: any;
3173
- /** @property {number} - If set ui coords will be renormalized to this canvas height */
3174
- nativeHeight: number;
3252
+ /** @property {UIObject} - Current confirm menu being shown */
3253
+ confirmDialog: any;
3175
3254
  /** Draw a rectangle to the UI context
3176
3255
  * @param {Vector2} pos
3177
3256
  * @param {Vector2} size
@@ -3196,8 +3275,11 @@ declare module "littlejsengine" {
3196
3275
  * @param {TileInfo} tileInfo
3197
3276
  * @param {Color} [color=uiSystem.defaultColor]
3198
3277
  * @param {number} [angle]
3199
- * @param {boolean} [mirror] */
3200
- drawTile(pos: Vector2, size: Vector2, tileInfo: TileInfo, color?: Color, angle?: number, mirror?: boolean): void;
3278
+ * @param {boolean} [mirror]
3279
+ * @param {Color} [shadowColor]
3280
+ * @param {number} [shadowBlur]
3281
+ * @param {Color} [shadowOffset] */
3282
+ drawTile(pos: Vector2, size: Vector2, tileInfo: TileInfo, color?: Color, angle?: number, mirror?: boolean, shadowColor?: Color, shadowBlur?: number, shadowOffset?: Color): void;
3201
3283
  /** Draw text to the UI context
3202
3284
  * @param {string} text
3203
3285
  * @param {Vector2} pos
@@ -3210,8 +3292,10 @@ declare module "littlejsengine" {
3210
3292
  * @param {string} [fontStyle]
3211
3293
  * @param {boolean} [applyMaxWidth=true]
3212
3294
  * @param {Vector2} [textShadow]
3213
- */
3214
- drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean, textShadow?: Vector2): void;
3295
+ * @param {Color} [shadowColor]
3296
+ * @param {number} [shadowBlur]
3297
+ * @param {Color} [shadowOffset] */
3298
+ drawText(text: string, pos: Vector2, size: Vector2, color?: Color, lineWidth?: number, lineColor?: Color, align?: string, font?: string, fontStyle?: string, applyMaxWidth?: boolean, textShadow?: Vector2, shadowColor?: Color, shadowBlur?: number, shadowOffset?: Color): void;
3215
3299
  /**
3216
3300
  * @callback DragAndDropCallback - Callback for drag and drop events
3217
3301
  * @param {DragEvent} event - The drag event
@@ -3222,16 +3306,37 @@ declare module "littlejsengine" {
3222
3306
  * @param {DragAndDropCallback} [onDrop] - when a file is dropped
3223
3307
  * @param {DragAndDropCallback} [onDragEnter] - when a file is dragged onto the window
3224
3308
  * @param {DragAndDropCallback} [onDragLeave] - when a file is dragged off the window
3225
- * @param {DragAndDropCallback} [onDragOver] - continously when dragging over */
3309
+ * @param {DragAndDropCallback} [onDragOver] - continuously when dragging over */
3226
3310
  setupDragAndDrop(onDrop?: (event: DragEvent) => any, onDragEnter?: (event: DragEvent) => any, onDragLeave?: (event: DragEvent) => any, onDragOver?: (event: DragEvent) => any): void;
3227
3311
  /** Convert a screen space position to native UI position
3228
3312
  * @param {Vector2} pos
3229
- * @return {Vector2}
3230
- */
3313
+ * @return {Vector2} */
3231
3314
  screenToNative(pos: Vector2): Vector2;
3232
3315
  /** Destroy and remove all objects
3233
3316
  * @memberof Engine */
3234
3317
  destroyObjects(): void;
3318
+ /** Get all navigable UI objects sorted by navigationIndex
3319
+ * @return {Array<UIObject>} */
3320
+ getNavigableObjects(): Array<UIObject>;
3321
+ /** Get navigation direction from gamepad or keyboard
3322
+ * @return {number} */
3323
+ getNavigationDirection(): number;
3324
+ /** Get other axis navigation direction from gamepad or keyboard
3325
+ * @return {Vector2} */
3326
+ getNavigationOtherDirection(): Vector2;
3327
+ /** Get if navigation button was pressed from gamepad or keyboard
3328
+ * @return {boolean} */
3329
+ getNavigationWasPressed(): boolean;
3330
+ /** Show a confirmation dialog with Yes/No buttons
3331
+ * Centers the dialog on the screen with darkened background
3332
+ * @param {string} [text] - The message to display
3333
+ * @param {Function} [yesCallback] - Called when Yes is clicked
3334
+ * @param {Function} [noCallback] - Called when No is clicked
3335
+ * @param {Vector2} [size] - Size of the confirmation dialog
3336
+ * @param {string} [exitKey] - Key that can exit the menu
3337
+ * @return {UIObject} The confirmation menu object
3338
+ */
3339
+ showConfirmDialog(text?: string, yesCallback?: Function, noCallback?: Function, size?: Vector2, exitKey?: string): UIObject;
3235
3340
  }
3236
3341
  /**
3237
3342
  * UI Object - Base level object for all UI elements
@@ -3279,7 +3384,13 @@ declare module "littlejsengine" {
3279
3384
  /** @property {number} - Override for text height */
3280
3385
  textHeight: any;
3281
3386
  /** @property {number} - Scale text to fit in the object */
3282
- textScale: number;
3387
+ textFitScale: number;
3388
+ /** @property {Vector2} - How much to offset the text shadow or undefined */
3389
+ textShadow: any;
3390
+ /** @property {number} - Color for text line drawing */
3391
+ textLineColor: Color;
3392
+ /** @property {number} - Width for text line drawing */
3393
+ textLineWidth: number;
3283
3394
  /** @property {boolean} - Should this object be drawn */
3284
3395
  visible: boolean;
3285
3396
  /** @property {Array<UIObject>} - A list of this object's children */
@@ -3306,39 +3417,49 @@ declare module "littlejsengine" {
3306
3417
  shadowBlur: number;
3307
3418
  /** @property {Vector2} - Offset of shadow blur */
3308
3419
  shadowOffset: Vector2;
3309
- /** @property {Vector2} - How much to offset the text shadow or undefined */
3310
- textShadow: any;
3420
+ /** @property {number} - Optional navigation order index, lower values are selected first */
3421
+ navigationIndex: any;
3422
+ /** @property {boolean} - Should this be auto selected by navigation? Must also have valid navigation index. */
3423
+ navigationAutoSelect: boolean;
3311
3424
  /** Add a child UIObject to this object
3312
- * @param {UIObject} child
3313
- */
3425
+ * @param {UIObject} child */
3314
3426
  addChild(child: UIObject): void;
3315
3427
  /** Remove a child UIObject from this object
3316
- * @param {UIObject} child
3317
- */
3428
+ * @param {UIObject} child */
3318
3429
  removeChild(child: UIObject): void;
3319
3430
  /** Destroy this object, destroy its children, detach its parent, and mark it for removal */
3320
3431
  destroy(): void;
3321
3432
  destroyed: number;
3322
3433
  /** Check if the mouse is overlapping a box in screen space
3323
- * @return {boolean} - True if overlapping
3324
- */
3434
+ * @return {boolean} - True if overlapping */
3325
3435
  isMouseOverlapping(): boolean;
3326
3436
  /** Update the object, called automatically by plugin once each frame */
3327
3437
  update(): void;
3328
3438
  /** Render the object, called automatically by plugin once each frame */
3329
3439
  render(): void;
3330
- /** Special update when object is not visible */
3331
- updateInvisible(): void;
3332
3440
  /** Get the size for text with overrides and scale
3333
- * @return {Vector2}
3334
- */
3441
+ * @return {Vector2} */
3335
3442
  getTextSize(): Vector2;
3443
+ /** Called when the navigation button is pressed on this object */
3444
+ navigatePressed(): void;
3336
3445
  /** @return {boolean} - Is the mouse hovering over this element */
3337
3446
  isHoverObject(): boolean;
3338
3447
  /** @return {boolean} - Is the mouse held onto this element */
3339
3448
  isActiveObject(): boolean;
3340
- /** Called each frame when object updates */
3449
+ /** @return {boolean} - Is the gamepad or keyboard navigation object */
3450
+ isNavigationObject(): boolean;
3451
+ /** @return {boolean} - Can it be interacted with */
3452
+ isInteractive(): boolean;
3453
+ /** Returns string containing info about this object for debugging
3454
+ * @return {string} */
3455
+ toString(): string;
3456
+ /** Called if uiDebug is enabled
3457
+ * @param {boolean} visible */
3458
+ renderDebug(visible?: boolean): void;
3459
+ /** Called each frame before object updates */
3341
3460
  onUpdate(): void;
3461
+ /** Called each frame before object renders */
3462
+ onRender(): void;
3342
3463
  /** Called when the mouse enters the object */
3343
3464
  onEnter(): void;
3344
3465
  /** Called when the mouse leaves the object */
@@ -3404,6 +3525,8 @@ declare module "littlejsengine" {
3404
3525
  * @param {Color} [color=uiSystem.defaultButtonColor]
3405
3526
  */
3406
3527
  constructor(pos?: Vector2, size?: Vector2, text?: string, color?: Color);
3528
+ /** @property {Vector2} - Text offset for the button */
3529
+ textOffset: Vector2;
3407
3530
  text: string;
3408
3531
  }
3409
3532
  /**
@@ -3464,7 +3587,7 @@ declare module "littlejsengine" {
3464
3587
  * @param {number} [volume=1] - Volume percent scaled by global volume (0-1)
3465
3588
  */
3466
3589
  constructor(pos?: Vector2, size?: Vector2, src: string, autoplay?: boolean, loop?: boolean, volume?: number);
3467
- /** @property {float} - The video volume */
3590
+ /** @property {number} - The video volume */
3468
3591
  volume: number;
3469
3592
  /** @property {HTMLVideoElement} - The video player */
3470
3593
  video: HTMLVideoElement;
@@ -3477,7 +3600,7 @@ declare module "littlejsengine" {
3477
3600
  stop(): void;
3478
3601
  /** Check if video is currently loading
3479
3602
  * @return {boolean} */
3480
- isLoadng(): boolean;
3603
+ isLoading(): boolean;
3481
3604
  /** Check if video is currently paused
3482
3605
  * @return {boolean} */
3483
3606
  isPaused(): boolean;