littlejsengine 1.6.0 → 1.6.6
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 +138 -34
- package/build/littlejs.d.ts +104 -92
- package/build/littlejs.esm.js +414 -342
- package/build/littlejs.esm.min.js +1 -1
- package/build/littlejs.js +365 -296
- package/build/littlejs.min.js +1 -1
- package/build/littlejs.release.js +359 -291
- package/examples/breakout/game.js +5 -0
- package/examples/breakout/gameObjects.js +41 -48
- package/examples/breakout/index.html +3 -3
- package/examples/breakoutTutorial/README.md +514 -0
- package/examples/breakoutTutorial/game.js +181 -0
- package/examples/breakoutTutorial/images/1.png +0 -0
- package/examples/breakoutTutorial/images/10.png +0 -0
- package/examples/breakoutTutorial/images/11.png +0 -0
- package/examples/breakoutTutorial/images/2.png +0 -0
- package/examples/breakoutTutorial/images/3.png +0 -0
- package/examples/breakoutTutorial/images/4.png +0 -0
- package/examples/breakoutTutorial/images/5.png +0 -0
- package/examples/breakoutTutorial/images/6.png +0 -0
- package/examples/breakoutTutorial/images/7.png +0 -0
- package/examples/breakoutTutorial/images/8.png +0 -0
- package/examples/breakoutTutorial/images/9.png +0 -0
- package/examples/breakoutTutorial/index.html +10 -0
- package/examples/empty/game.js +10 -0
- package/examples/favicon.png +0 -0
- package/examples/module/index.html +1 -1
- package/examples/particles/index.html +1 -1
- package/examples/platformer/gameLevel.js +1 -1
- package/examples/platformer/gamePlayer.js +1 -1
- package/examples/platformer/index.html +6 -6
- package/examples/puzzle/game.js +1 -1
- package/examples/puzzle/index.html +2 -2
- package/examples/starter/build.bat +3 -2
- package/examples/starter/game.js +9 -9
- package/examples/starter/index.html +13 -13
- package/examples/stress/index.html +1 -1
- package/examples/typescript/game.js +89 -89
- package/examples/typescript/game.ts +10 -10
- package/examples/typescript/index.html +1 -1
- package/package.json +4 -4
- package/src/engine.js +29 -31
- package/src/engineAudio.js +53 -29
- package/src/engineBuild.bat +3 -1
- package/src/engineDebug.js +25 -24
- package/src/engineDraw.js +43 -39
- package/src/engineExport.js +49 -46
- package/src/engineInput.js +83 -74
- package/src/engineMedals.js +31 -8
- package/src/engineObject.js +25 -25
- package/src/engineParticles.js +3 -6
- package/src/engineRelease.js +19 -19
- package/src/engineSettings.js +4 -4
- package/src/engineTileLayer.js +18 -14
- package/src/engineUtilities.js +43 -34
- package/src/engineWebGL.js +8 -8
package/build/littlejs.d.ts
CHANGED
|
@@ -1,160 +1,164 @@
|
|
|
1
1
|
declare module "littlejs.esm" {
|
|
2
2
|
/**
|
|
3
3
|
* LittleJS Module Export
|
|
4
|
-
*
|
|
4
|
+
* - Export engine as a module with extra functions where necessary
|
|
5
5
|
*/
|
|
6
6
|
/** Set position of camera in world space
|
|
7
7
|
* @param {Vector2} pos
|
|
8
8
|
* @memberof Settings */
|
|
9
|
-
export function setCameraPos(pos: Vector2):
|
|
9
|
+
export function setCameraPos(pos: Vector2): void;
|
|
10
10
|
/** Set scale of camera in world space
|
|
11
11
|
* @param {Number} scale
|
|
12
12
|
* @memberof Settings */
|
|
13
|
-
export function setCameraScale(scale: number):
|
|
13
|
+
export function setCameraScale(scale: number): void;
|
|
14
14
|
/** Set max size of the canvas
|
|
15
15
|
* @param {Vector2} size
|
|
16
16
|
* @memberof Settings */
|
|
17
|
-
export function setCanvasMaxSize(size: Vector2):
|
|
17
|
+
export function setCanvasMaxSize(size: Vector2): void;
|
|
18
18
|
/** Set fixed size of the canvas
|
|
19
19
|
* @param {Vector2} size
|
|
20
20
|
* @memberof Settings */
|
|
21
|
-
export function setCanvasFixedSize(size: Vector2):
|
|
21
|
+
export function setCanvasFixedSize(size: Vector2): void;
|
|
22
22
|
/** Disables anti aliasing for pixel art if true
|
|
23
23
|
* @param {Boolean} pixelated
|
|
24
24
|
* @memberof Settings */
|
|
25
|
-
export function
|
|
25
|
+
export function setCanvasPixelated(pixelated: boolean): void;
|
|
26
26
|
/** Set default font used for text rendering
|
|
27
27
|
* @param {String} font
|
|
28
28
|
* @memberof Settings */
|
|
29
|
-
export function setFontDefault(font: string):
|
|
29
|
+
export function setFontDefault(font: string): void;
|
|
30
30
|
/** Set if webgl rendering is enabled
|
|
31
31
|
* @param {Boolean} enable
|
|
32
32
|
* @memberof Settings */
|
|
33
|
-
export function setGlEnable(enable: boolean):
|
|
33
|
+
export function setGlEnable(enable: boolean): void;
|
|
34
34
|
/** Set to not composite the WebGL canvas
|
|
35
35
|
* @param {Boolean} overlay
|
|
36
36
|
* @memberof Settings */
|
|
37
|
-
export function setGlOverlay(overlay: boolean):
|
|
37
|
+
export function setGlOverlay(overlay: boolean): void;
|
|
38
38
|
/** Set default size of tiles in pixels
|
|
39
39
|
* @param {Vector2} size
|
|
40
40
|
* @memberof Settings */
|
|
41
|
-
export function setTileSizeDefault(size: Vector2):
|
|
41
|
+
export function setTileSizeDefault(size: Vector2): void;
|
|
42
42
|
/** Set to prevent tile bleeding from neighbors in pixels
|
|
43
43
|
* @param {Number} scale
|
|
44
44
|
* @memberof Settings */
|
|
45
|
-
export function setTileFixBleedScale(scale: number):
|
|
45
|
+
export function setTileFixBleedScale(scale: number): void;
|
|
46
46
|
/** Set if collisions between objects are enabled
|
|
47
47
|
* @param {Boolean} enable
|
|
48
48
|
* @memberof Settings */
|
|
49
|
-
export function setEnablePhysicsSolver(enable: boolean):
|
|
49
|
+
export function setEnablePhysicsSolver(enable: boolean): void;
|
|
50
50
|
/** Set default object mass for collison calcuations
|
|
51
51
|
* @param {Number} mass
|
|
52
52
|
* @memberof Settings */
|
|
53
|
-
export function setObjectDefaultMass(mass: number):
|
|
53
|
+
export function setObjectDefaultMass(mass: number): void;
|
|
54
54
|
/** Set how much to slow velocity by each frame
|
|
55
55
|
* @param {Number} damping
|
|
56
56
|
* @memberof Settings */
|
|
57
|
-
export function setObjectDefaultDamping(damp: any):
|
|
57
|
+
export function setObjectDefaultDamping(damp: any): void;
|
|
58
58
|
/** Set how much to slow angular velocity each frame
|
|
59
59
|
* @param {Number} damping
|
|
60
60
|
* @memberof Settings */
|
|
61
|
-
export function setObjectDefaultAngleDamping(damp: any):
|
|
61
|
+
export function setObjectDefaultAngleDamping(damp: any): void;
|
|
62
62
|
/** Set how much to bounce when a collision occur
|
|
63
63
|
* @param {Number} elasticity
|
|
64
64
|
* @memberof Settings */
|
|
65
|
-
export function setObjectDefaultElasticity(elasticity: number):
|
|
65
|
+
export function setObjectDefaultElasticity(elasticity: number): void;
|
|
66
66
|
/** Set how much to slow when touching
|
|
67
67
|
* @param {Number} friction
|
|
68
68
|
* @memberof Settings */
|
|
69
|
-
export function setObjectDefaultFriction(friction: number):
|
|
69
|
+
export function setObjectDefaultFriction(friction: number): void;
|
|
70
70
|
/** Set max speed to avoid fast objects missing collisions
|
|
71
71
|
* @param {Number} speed
|
|
72
72
|
* @memberof Settings */
|
|
73
|
-
export function setObjectMaxSpeed(speed: number):
|
|
73
|
+
export function setObjectMaxSpeed(speed: number): void;
|
|
74
74
|
/** Set how much gravity to apply to objects along the Y axis
|
|
75
75
|
* @param {Number} gravity
|
|
76
76
|
* @memberof Settings */
|
|
77
|
-
export function setGravity(g: any):
|
|
77
|
+
export function setGravity(g: any): void;
|
|
78
78
|
/** Set to scales emit rate of particles
|
|
79
79
|
* @param {Number} scale
|
|
80
80
|
* @memberof Settings */
|
|
81
|
-
export function setParticleEmitRateScale(scale: number):
|
|
81
|
+
export function setParticleEmitRateScale(scale: number): void;
|
|
82
82
|
/** Set if gamepads are enabled
|
|
83
83
|
* @param {Boolean} enable
|
|
84
84
|
* @memberof Settings */
|
|
85
|
-
export function setGamepadsEnable(enable: boolean):
|
|
85
|
+
export function setGamepadsEnable(enable: boolean): void;
|
|
86
86
|
/** Set if the dpad input is also routed to the left analog stick
|
|
87
87
|
* @param {Boolean} enable
|
|
88
88
|
* @memberof Settings */
|
|
89
|
-
export function setGamepadDirectionEmulateStick(enable: boolean):
|
|
89
|
+
export function setGamepadDirectionEmulateStick(enable: boolean): void;
|
|
90
90
|
/** Set if true the WASD keys are also routed to the direction keys
|
|
91
91
|
* @param {Boolean} enable
|
|
92
92
|
* @memberof Settings */
|
|
93
|
-
export function setInputWASDEmulateDirection(enable: boolean):
|
|
93
|
+
export function setInputWASDEmulateDirection(enable: boolean): void;
|
|
94
94
|
/** Set if touch gamepad should appear on mobile devices
|
|
95
95
|
* @param {Boolean} enable
|
|
96
96
|
* @memberof Settings */
|
|
97
|
-
export function setTouchGamepadEnable(enable: boolean):
|
|
97
|
+
export function setTouchGamepadEnable(enable: boolean): void;
|
|
98
98
|
/** Set if touch gamepad should be analog stick or 8 way dpad
|
|
99
99
|
* @param {Boolean} analog
|
|
100
100
|
* @memberof Settings */
|
|
101
|
-
export function setTouchGamepadAnalog(analog: boolean):
|
|
101
|
+
export function setTouchGamepadAnalog(analog: boolean): void;
|
|
102
102
|
/** Set size of virutal gamepad for touch devices in pixels
|
|
103
103
|
* @param {Number} size
|
|
104
104
|
* @memberof Settings */
|
|
105
|
-
export function setTouchGamepadSize(size: number):
|
|
105
|
+
export function setTouchGamepadSize(size: number): void;
|
|
106
106
|
/** Set transparency of touch gamepad overlay
|
|
107
107
|
* @param {Number} alpha
|
|
108
108
|
* @memberof Settings */
|
|
109
|
-
export function setTouchGamepadAlpha(alpha: number):
|
|
109
|
+
export function setTouchGamepadAlpha(alpha: number): void;
|
|
110
110
|
/** Set to allow vibration hardware if it exists
|
|
111
111
|
* @param {Boolean} enable
|
|
112
112
|
* @memberof Settings */
|
|
113
|
-
export function setVibrateEnable(enable: boolean):
|
|
113
|
+
export function setVibrateEnable(enable: boolean): void;
|
|
114
114
|
/** Set to disable all audio code
|
|
115
115
|
* @param {Boolean} enable
|
|
116
116
|
* @memberof Settings */
|
|
117
|
-
export function setSoundEnable(enable: boolean):
|
|
117
|
+
export function setSoundEnable(enable: boolean): void;
|
|
118
118
|
/** Set volume scale to apply to all sound, music and speech
|
|
119
119
|
* @param {Number} volume
|
|
120
120
|
* @memberof Settings */
|
|
121
|
-
export function setSoundVolume(volume: number):
|
|
121
|
+
export function setSoundVolume(volume: number): void;
|
|
122
122
|
/** Set default range where sound no longer plays
|
|
123
123
|
* @param {Number} range
|
|
124
124
|
* @memberof Settings */
|
|
125
|
-
export function setSoundDefaultRange(range: number):
|
|
125
|
+
export function setSoundDefaultRange(range: number): void;
|
|
126
126
|
/** Set default range percent to start tapering off sound
|
|
127
127
|
* @param {Number} taper
|
|
128
128
|
* @memberof Settings */
|
|
129
|
-
export function setSoundDefaultTaper(taper: number):
|
|
129
|
+
export function setSoundDefaultTaper(taper: number): void;
|
|
130
130
|
/** Set how long to show medals for in seconds
|
|
131
131
|
* @param {Number} time
|
|
132
132
|
* @memberof Settings */
|
|
133
|
-
export function setMedalDisplayTime(time: number):
|
|
133
|
+
export function setMedalDisplayTime(time: number): void;
|
|
134
134
|
/** Set how quickly to slide on/off medals in seconds
|
|
135
135
|
* @param {Number} time
|
|
136
136
|
* @memberof Settings */
|
|
137
|
-
export function setMedalDisplaySlideTime(time: number):
|
|
137
|
+
export function setMedalDisplaySlideTime(time: number): void;
|
|
138
138
|
/** Set size of medal display
|
|
139
139
|
* @param {Vector2} size
|
|
140
140
|
* @memberof Settings */
|
|
141
|
-
export function setMedalDisplaySize(size: Vector2):
|
|
141
|
+
export function setMedalDisplaySize(size: Vector2): void;
|
|
142
142
|
/** Set size of icon in medal display
|
|
143
143
|
* @param {Number} size
|
|
144
144
|
* @memberof Settings */
|
|
145
|
-
export function setMedalDisplayIconSize(size: number):
|
|
145
|
+
export function setMedalDisplayIconSize(size: number): void;
|
|
146
146
|
/** Set to stop medals from being unlockable
|
|
147
147
|
* @param {Boolean} preventUnlock
|
|
148
148
|
* @memberof Settings */
|
|
149
|
-
export function setMedalsPreventUnlock(prevent: any):
|
|
149
|
+
export function setMedalsPreventUnlock(prevent: any): void;
|
|
150
150
|
/** Set if watermark with FPS should be shown
|
|
151
151
|
* @param {Boolean} show
|
|
152
152
|
* @memberof Debug */
|
|
153
|
-
export function setShowWatermark(show: boolean):
|
|
153
|
+
export function setShowWatermark(show: boolean): void;
|
|
154
154
|
/** Set if god mode is enabled
|
|
155
155
|
* @param {Boolean} enable
|
|
156
156
|
* @memberof Debug */
|
|
157
|
-
export function setGodMode(enable: boolean):
|
|
157
|
+
export function setGodMode(enable: boolean): void;
|
|
158
|
+
/** Set key code used to toggle debug mode, Esc by default
|
|
159
|
+
* @param {Number} key
|
|
160
|
+
* @memberof Debug */
|
|
161
|
+
export function setDebugKey(key: number): void;
|
|
158
162
|
/** The max size of the canvas, centered if window is larger
|
|
159
163
|
* @type {Vector2}
|
|
160
164
|
* @default Vector2(1920,1200)
|
|
@@ -166,11 +170,11 @@ declare module "littlejs.esm" {
|
|
|
166
170
|
* @default Vector2()
|
|
167
171
|
* @memberof Settings */
|
|
168
172
|
export let canvasFixedSize: Vector2;
|
|
169
|
-
/** Disables
|
|
173
|
+
/** Disables filtering for crisper pixel art if true
|
|
170
174
|
* @type {Boolean}
|
|
171
175
|
* @default
|
|
172
176
|
* @memberof Settings */
|
|
173
|
-
export let
|
|
177
|
+
export let canvasPixelated: boolean;
|
|
174
178
|
/** Default font used for text rendering
|
|
175
179
|
* @type {String}
|
|
176
180
|
* @default
|
|
@@ -267,8 +271,8 @@ declare module "littlejs.esm" {
|
|
|
267
271
|
* @memberof Settings */
|
|
268
272
|
export let inputWASDEmulateDirection: boolean;
|
|
269
273
|
/** True if touch gamepad should appear on mobile devices
|
|
270
|
-
*
|
|
271
|
-
*
|
|
274
|
+
* - Supports left analog stick, 4 face buttons and start button (button 9)
|
|
275
|
+
* - Must be set by end of gameInit to be activated
|
|
272
276
|
* @type {Boolean}
|
|
273
277
|
* @default 0
|
|
274
278
|
* @memberof Settings */
|
|
@@ -348,6 +352,10 @@ declare module "littlejs.esm" {
|
|
|
348
352
|
* @default
|
|
349
353
|
* @memberof Debug */
|
|
350
354
|
export let godMode: boolean;
|
|
355
|
+
/** Asserts if the experssion is false, does not do anything in release builds
|
|
356
|
+
* @param {Boolean} assertion
|
|
357
|
+
* @param {Object} output
|
|
358
|
+
* @memberof Debug */
|
|
351
359
|
export function ASSERT(...assert: any[]): void;
|
|
352
360
|
/** Draw a debug rectangle in world space
|
|
353
361
|
* @param {Vector2} pos
|
|
@@ -401,7 +409,7 @@ declare module "littlejs.esm" {
|
|
|
401
409
|
export function debugText(text: string, pos: Vector2, size?: number, color?: string, time?: number, angle?: number, font?: string): void;
|
|
402
410
|
/** Clear all debug primitives in the list
|
|
403
411
|
* @memberof Debug */
|
|
404
|
-
export function debugClear():
|
|
412
|
+
export function debugClear(): void;
|
|
405
413
|
/** Save a canvas to disk
|
|
406
414
|
* @param {HTMLCanvasElement} canvas
|
|
407
415
|
* @param {String} [filename]
|
|
@@ -535,7 +543,7 @@ declare module "littlejs.esm" {
|
|
|
535
543
|
/** Set seed used by the randSeeded function, should not be 0
|
|
536
544
|
* @param {Number} seed
|
|
537
545
|
* @memberof Random */
|
|
538
|
-
export function setRandSeed(seed: number):
|
|
546
|
+
export function setRandSeed(seed: number): void;
|
|
539
547
|
/** Returns a seeded random value between the two values passed in using randSeed
|
|
540
548
|
* @param {Number} [valueA=1]
|
|
541
549
|
* @param {Number} [valueB=0]
|
|
@@ -544,7 +552,7 @@ declare module "littlejs.esm" {
|
|
|
544
552
|
export function randSeeded(a?: number, b?: number): number;
|
|
545
553
|
/**
|
|
546
554
|
* 2D Vector object with vector math library
|
|
547
|
-
*
|
|
555
|
+
* - Functions do not change this so they can be chained together
|
|
548
556
|
* @example
|
|
549
557
|
* let a = new Vector2(2, 3); // vector with coordinates (2, 3)
|
|
550
558
|
* let b = new Vector2; // vector with coordinates (0, 0)
|
|
@@ -657,8 +665,8 @@ declare module "littlejs.esm" {
|
|
|
657
665
|
* let a = new Color; // white
|
|
658
666
|
* let b = new Color(1, 0, 0); // red
|
|
659
667
|
* let c = new Color(0, 0, 0, 0); // transparent black
|
|
660
|
-
* let d =
|
|
661
|
-
* let e =
|
|
668
|
+
* let d = RGB(0, 0, 1); // blue using rgb color
|
|
669
|
+
* let e = HSL(.3, 1, .5); // green using hsl color
|
|
662
670
|
*/
|
|
663
671
|
export class Color {
|
|
664
672
|
/** Create a color with the components passed in, white by default
|
|
@@ -798,7 +806,7 @@ declare module "littlejs.esm" {
|
|
|
798
806
|
* @return {Color}
|
|
799
807
|
* @memberof Utilities
|
|
800
808
|
*/
|
|
801
|
-
export function
|
|
809
|
+
export function rgb(r?: number, g?: number, b?: number, a?: number): Color;
|
|
802
810
|
/**
|
|
803
811
|
* Create a color object with HSLA values
|
|
804
812
|
* @param {Number} [h=0]
|
|
@@ -808,27 +816,27 @@ declare module "littlejs.esm" {
|
|
|
808
816
|
* @return {Color}
|
|
809
817
|
* @memberof Utilities
|
|
810
818
|
*/
|
|
811
|
-
export function
|
|
819
|
+
export function hsl(h?: number, s?: number, l?: number, a?: number): Color;
|
|
812
820
|
/**
|
|
813
821
|
* LittleJS Object Base Object Class
|
|
814
|
-
*
|
|
815
|
-
*
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
*
|
|
822
|
-
*
|
|
823
|
-
*
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
822
|
+
* - Base object class used by the engine
|
|
823
|
+
* - Automatically adds self to object list
|
|
824
|
+
* - Will be updated and rendered each frame
|
|
825
|
+
* - Renders as a sprite from a tilesheet by default
|
|
826
|
+
* - Can have color and addtive color applied
|
|
827
|
+
* - 2d Physics and collision system
|
|
828
|
+
* - Sorted by renderOrder
|
|
829
|
+
* - Objects can have children attached
|
|
830
|
+
* - Parents are updated before children, and set child transform
|
|
831
|
+
* - Call destroy() to get rid of objects
|
|
832
|
+
*
|
|
833
|
+
* The physics system used by objects is simple and fast with some caveats...
|
|
834
|
+
* - Collision uses the axis aligned size, the object's rotation angle is only for rendering
|
|
835
|
+
* - Objects are guaranteed to not intersect tile collision from physics
|
|
836
|
+
* - If an object starts or is moved inside tile collision, it will not collide with that tile
|
|
837
|
+
* - Collision for objects can be set to be solid to block other objects
|
|
838
|
+
* - Objects may get pushed into overlapping other solid objects, if so they will push away
|
|
839
|
+
* - Solid objects are more performance intensive and should be used sparingly
|
|
832
840
|
* @example
|
|
833
841
|
* // create an engine object, normally you would first extend the class with your own
|
|
834
842
|
* const pos = vec2(2,3);
|
|
@@ -1039,6 +1047,8 @@ declare module "littlejs.esm" {
|
|
|
1039
1047
|
* @param {Number} [lineWidth=0]
|
|
1040
1048
|
* @param {Color} [lineColor=Color(0,0,0)]
|
|
1041
1049
|
* @param {String} [textAlign='center']
|
|
1050
|
+
* @param {String} [font=fontDefault]
|
|
1051
|
+
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
1042
1052
|
* @memberof Draw */
|
|
1043
1053
|
export function drawTextScreen(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font?: string, context?: CanvasRenderingContext2D): void;
|
|
1044
1054
|
/** Draw text on overlay canvas in world space
|
|
@@ -1050,14 +1060,16 @@ declare module "littlejs.esm" {
|
|
|
1050
1060
|
* @param {Number} [lineWidth=0]
|
|
1051
1061
|
* @param {Color} [lineColor=Color(0,0,0)]
|
|
1052
1062
|
* @param {String} [textAlign='center']
|
|
1063
|
+
* @param {String} [font=fontDefault]
|
|
1064
|
+
* @param {CanvasRenderingContext2D} [context=overlayContext]
|
|
1053
1065
|
* @memberof Draw */
|
|
1054
|
-
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font
|
|
1066
|
+
export function drawText(text: string, pos: Vector2, size?: number, color?: Color, lineWidth?: number, lineColor?: Color, textAlign?: string, font?: string, context?: CanvasRenderingContext2D): void;
|
|
1055
1067
|
export let engineFontImage: any;
|
|
1056
1068
|
/**
|
|
1057
1069
|
* Font Image Object - Draw text on a 2D canvas by using characters in an image
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
1070
|
+
* - 96 characters (from space to tilde) are stored in an image
|
|
1071
|
+
* - Uses a default 8x8 font if none is supplied
|
|
1072
|
+
* - You can also use fonts from the main tile sheet
|
|
1061
1073
|
* @example
|
|
1062
1074
|
* // use built in font
|
|
1063
1075
|
* const font = new ImageFont;
|
|
@@ -1121,7 +1133,7 @@ declare module "littlejs.esm" {
|
|
|
1121
1133
|
export function keyWasReleased(key: number, device?: number): boolean;
|
|
1122
1134
|
/** Clears all input
|
|
1123
1135
|
* @memberof Input */
|
|
1124
|
-
export function clearInput():
|
|
1136
|
+
export function clearInput(): void;
|
|
1125
1137
|
/** Returns true if device key is down
|
|
1126
1138
|
* @param {Number} key
|
|
1127
1139
|
* @param {Number} [device=0]
|
|
@@ -1189,17 +1201,17 @@ declare module "littlejs.esm" {
|
|
|
1189
1201
|
/** Pulse the vibration hardware if it exists
|
|
1190
1202
|
* @param {Number} [pattern=100] - a single value in miliseconds or vibration interval array
|
|
1191
1203
|
* @memberof Input */
|
|
1192
|
-
export function vibrate(pattern?: number):
|
|
1204
|
+
export function vibrate(pattern?: number): void;
|
|
1193
1205
|
/** Cancel any ongoing vibration
|
|
1194
1206
|
* @memberof Input */
|
|
1195
|
-
export function vibrateStop():
|
|
1207
|
+
export function vibrateStop(): void;
|
|
1196
1208
|
/** True if a touch device has been detected
|
|
1197
1209
|
* @memberof Input */
|
|
1198
1210
|
export const isTouchDevice: boolean;
|
|
1199
1211
|
/**
|
|
1200
1212
|
* Sound Object - Stores a zzfx sound for later use and can be played positionally
|
|
1201
|
-
*
|
|
1202
|
-
* <
|
|
1213
|
+
*
|
|
1214
|
+
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1203
1215
|
* @example
|
|
1204
1216
|
* // create a sound
|
|
1205
1217
|
* const sound_example = new Sound([.5,.5]);
|
|
@@ -1219,7 +1231,7 @@ declare module "littlejs.esm" {
|
|
|
1219
1231
|
/** @property {Number} - At what percentage of range should it start tapering off */
|
|
1220
1232
|
taper: number;
|
|
1221
1233
|
randomness: any;
|
|
1222
|
-
cachedSamples:
|
|
1234
|
+
cachedSamples: any[];
|
|
1223
1235
|
/** Play the sound
|
|
1224
1236
|
* @param {Vector2} [pos] - World space position to play the sound, sound is not attenuated if null
|
|
1225
1237
|
* @param {Number} [volume=1] - How much to scale volume by (in addition to range fade)
|
|
@@ -1238,8 +1250,8 @@ declare module "littlejs.esm" {
|
|
|
1238
1250
|
}
|
|
1239
1251
|
/**
|
|
1240
1252
|
* Music Object - Stores a zzfx music track for later use
|
|
1241
|
-
*
|
|
1242
|
-
* <
|
|
1253
|
+
*
|
|
1254
|
+
* <a href=https://keithclark.github.io/ZzFXM/>Create music with the ZzFXM tracker.</a>
|
|
1243
1255
|
* @example
|
|
1244
1256
|
* // create some music
|
|
1245
1257
|
* const music_example = new Music(
|
|
@@ -1324,12 +1336,12 @@ declare module "littlejs.esm" {
|
|
|
1324
1336
|
* @memberof Audio */
|
|
1325
1337
|
export function playSamples(sampleChannels: any[], volume?: number, rate?: number, pan?: number, loop?: boolean): AudioBufferSourceNode;
|
|
1326
1338
|
/** Generate and play a ZzFX sound
|
|
1327
|
-
*
|
|
1328
|
-
* <
|
|
1339
|
+
*
|
|
1340
|
+
* <a href=https://killedbyapixel.github.io/ZzFX/>Create sounds using the ZzFX Sound Designer.</a>
|
|
1329
1341
|
* @param {Array} zzfxSound - Array of ZzFX parameters, ex. [.5,.5]
|
|
1330
|
-
* @return {
|
|
1342
|
+
* @return {AudioBufferSourceNode} - The audio node of the sound played
|
|
1331
1343
|
* @memberof Audio */
|
|
1332
|
-
export function zzfx(...zzfxSound: any[]):
|
|
1344
|
+
export function zzfx(...zzfxSound: any[]): AudioBufferSourceNode;
|
|
1333
1345
|
/** The tile collision layer array, use setTileCollisionData and getTileCollisionData to access
|
|
1334
1346
|
* @type {Array}
|
|
1335
1347
|
* @memberof TileCollision */
|
|
@@ -1346,7 +1358,7 @@ declare module "littlejs.esm" {
|
|
|
1346
1358
|
* @param {Vector2} pos
|
|
1347
1359
|
* @param {Number} [data=0]
|
|
1348
1360
|
* @memberof TileCollision */
|
|
1349
|
-
export function setTileCollisionData(pos: Vector2, data?: number):
|
|
1361
|
+
export function setTileCollisionData(pos: Vector2, data?: number): void;
|
|
1350
1362
|
/** Get tile collision data
|
|
1351
1363
|
* @param {Vector2} pos
|
|
1352
1364
|
* @return {Number}
|
|
@@ -1396,10 +1408,10 @@ declare module "littlejs.esm" {
|
|
|
1396
1408
|
}
|
|
1397
1409
|
/**
|
|
1398
1410
|
* Tile layer object - cached rendering system for tile layers
|
|
1399
|
-
*
|
|
1400
|
-
*
|
|
1401
|
-
*
|
|
1402
|
-
*
|
|
1411
|
+
* - Each Tile layer is rendered to an off screen canvas
|
|
1412
|
+
* - To allow dynamic modifications, layers are rendered using canvas 2d
|
|
1413
|
+
* - Some devices like mobile phones are limited to 4k texture resolution
|
|
1414
|
+
* - So with 16x16 tiles this limits layers to 256x256 on mobile devices
|
|
1403
1415
|
* @extends EngineObject
|
|
1404
1416
|
* @example
|
|
1405
1417
|
* // create tile collision and visible tile layer
|
|
@@ -1589,8 +1601,8 @@ declare module "littlejs.esm" {
|
|
|
1589
1601
|
* @memberof Settings */
|
|
1590
1602
|
export let medalsPreventUnlock: boolean;
|
|
1591
1603
|
/** Initialize medals with a save name used for storage
|
|
1592
|
-
*
|
|
1593
|
-
*
|
|
1604
|
+
* - Call this after creating all medals
|
|
1605
|
+
* - Checks if medals are unlocked
|
|
1594
1606
|
* @param {String} saveName
|
|
1595
1607
|
* @memberof Medals */
|
|
1596
1608
|
export function medalsInit(saveName: string): void;
|
|
@@ -1700,7 +1712,7 @@ declare module "littlejs.esm" {
|
|
|
1700
1712
|
* @memberof WebGL */
|
|
1701
1713
|
export function glSetBlendMode(additive?: boolean): void;
|
|
1702
1714
|
/** Set the WebGl texture, not normally necessary unless multiple tile sheets are used
|
|
1703
|
-
*
|
|
1715
|
+
* - This may also flush the gl buffer resulting in more draw calls and worse performance
|
|
1704
1716
|
* @param {WebGLTexture} [texture=glTileTexture]
|
|
1705
1717
|
* @memberof WebGL */
|
|
1706
1718
|
export function glSetTexture(texture?: WebGLTexture): void;
|