littlejsengine 1.17.15 → 1.18.0

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.
@@ -35,7 +35,7 @@ const engineName = 'LittleJS';
35
35
  * @type {string}
36
36
  * @default
37
37
  * @memberof Engine */
38
- const engineVersion = '1.17.15';
38
+ const engineVersion = '1.18.0';
39
39
 
40
40
  /** Frames per second to update
41
41
  * @type {number}
@@ -2336,6 +2336,12 @@ let touchGamepadSize = 99;
2336
2336
  * @memberof Settings */
2337
2337
  let touchGamepadAlpha = .3;
2338
2338
 
2339
+ /** How long to display the touch gamepad on screen in seconds, set to 0 to always display
2340
+ * @type {number}
2341
+ * @default
2342
+ * @memberof Settings */
2343
+ let touchGamepadDisplayTime = 3;
2344
+
2339
2345
  /** Allow vibration hardware if it exists
2340
2346
  * @type {boolean}
2341
2347
  * @default
@@ -2610,6 +2616,11 @@ function setTouchGamepadSize(size) { touchGamepadSize = size; }
2610
2616
  * @memberof Settings */
2611
2617
  function setTouchGamepadAlpha(alpha) { touchGamepadAlpha = alpha; }
2612
2618
 
2619
+ /** Set how long to display the touch gamepad on screen in seconds, set to 0 to always display
2620
+ * @param {number} time
2621
+ * @memberof Settings */
2622
+ function setTouchGamepadDisplayTime(time) { touchGamepadDisplayTime = time; }
2623
+
2613
2624
  /** Set to allow vibration hardware if it exists
2614
2625
  * @param {boolean} enable
2615
2626
  * @memberof Settings */
@@ -5081,10 +5092,10 @@ function inputRender()
5081
5092
  function touchGamepadRender()
5082
5093
  {
5083
5094
  if (!touchInputEnable || !isTouchDevice || headlessMode) return;
5084
- if (!touchGamepadEnable || !touchGamepadTimer.isSet()) return;
5095
+ if (!touchGamepadEnable || !touchGamepadTimer.isSet() && touchGamepadDisplayTime) return;
5085
5096
 
5086
5097
  // fade off when not touching or paused
5087
- const alpha = percent(touchGamepadTimer.get(), 4, 3);
5098
+ const alpha = touchGamepadDisplayTime ? percent(touchGamepadTimer.get(), touchGamepadDisplayTime+1, touchGamepadDisplayTime) : 1;
5088
5099
  if (!alpha || paused) return;
5089
5100
 
5090
5101
  // setup the canvas
@@ -8655,7 +8666,7 @@ function zzfxM(instruments, patterns, sequence, BPM = 125)
8655
8666
  * - Buttons
8656
8667
  * - Checkboxes
8657
8668
  * - Images
8658
- * - Scrollbars
8669
+ * - Sliders
8659
8670
  * - Video
8660
8671
  * @namespace UISystem
8661
8672
  */
@@ -9852,7 +9863,7 @@ class UICheckbox extends UIObject
9852
9863
  ASSERT(isString(text), 'ui checkbox must be a string');
9853
9864
  ASSERT(isColor(color), 'ui checkbox color must be a color');
9854
9865
 
9855
- /** @property {boolean} - Current percentage value of this scrollbar 0-1 */
9866
+ /** @property {boolean} - Current percentage value of this slider 0-1 */
9856
9867
  this.checked = checked;
9857
9868
  // set properties
9858
9869
  this.text = text;
@@ -9887,13 +9898,13 @@ class UICheckbox extends UIObject
9887
9898
 
9888
9899
  ///////////////////////////////////////////////////////////////////////////////
9889
9900
  /**
9890
- * UIScrollbar - A UI object that acts as a scrollbar
9901
+ * UISlider - A UI object that acts as a slider or scrollbar
9891
9902
  * @extends UIObject
9892
9903
  * @memberof UISystem
9893
9904
  */
9894
- class UIScrollbar extends UIObject
9905
+ class UISlider extends UIObject
9895
9906
  {
9896
- /** Create a UIScrollbar object
9907
+ /** Create a UISlider object
9897
9908
  * @param {Vector2} [pos]
9898
9909
  * @param {Vector2} [size]
9899
9910
  * @param {number} [value]
@@ -9905,14 +9916,14 @@ class UIScrollbar extends UIObject
9905
9916
  {
9906
9917
  super(pos, size);
9907
9918
 
9908
- ASSERT(isNumber(value), 'ui scrollbar value must be a number');
9909
- ASSERT(isString(text), 'ui scrollbar must be a string');
9910
- ASSERT(isColor(color), 'ui scrollbar color must be a color');
9911
- ASSERT(isColor(handleColor), 'ui scrollbar handleColor must be a color');
9919
+ ASSERT(isNumber(value), 'ui slider value must be a number');
9920
+ ASSERT(isString(text), 'ui slider must be a string');
9921
+ ASSERT(isColor(color), 'ui slider color must be a color');
9922
+ ASSERT(isColor(handleColor), 'ui slider handleColor must be a color');
9912
9923
 
9913
- /** @property {number} - Current percentage value of this scrollbar 0-1 */
9924
+ /** @property {number} - Current percentage value of this slider 0-1 */
9914
9925
  this.value = value;
9915
- /** @property {Color} - Color for the handle part of the scrollbar */
9926
+ /** @property {Color} - Color for the handle part of the slider */
9916
9927
  this.handleColor = handleColor.copy();
9917
9928
  /** @property {boolean} - Should it fill up like a progress bar? */
9918
9929
  this.fillMode = false;
@@ -9931,7 +9942,7 @@ class UIScrollbar extends UIObject
9931
9942
  const oldValue = this.value;
9932
9943
  if (this.isActiveObject())
9933
9944
  {
9934
- // handle horizontal or vertical scrollbar
9945
+ // handle horizontal or vertical slider
9935
9946
  const isHorizontal = this.size.x > this.size.y;
9936
9947
  const handleSize = isHorizontal ? this.size.y : this.size.x;
9937
9948
  const barSize = isHorizontal ? this.size.x : this.size.y;
@@ -9959,7 +9970,7 @@ class UIScrollbar extends UIObject
9959
9970
  {
9960
9971
  super.render();
9961
9972
 
9962
- // handle horizontal or vertical scrollbar
9973
+ // handle horizontal or vertical slider
9963
9974
  const isHorizontal = this.size.x > this.size.y;
9964
9975
  const barWidth = isHorizontal ? this.size.x : this.size.y;
9965
9976
  const handleWidth = isHorizontal ? this.size.y : this.size.x;
@@ -9977,7 +9988,7 @@ class UIScrollbar extends UIObject
9977
9988
  }
9978
9989
  else
9979
9990
  {
9980
- // draw the scrollbar handle
9991
+ // draw the slider handle
9981
9992
  const value = clamp(isHorizontal ? this.value : 1 - this.value);
9982
9993
  const p = (barWidth - handleWidth) * (value - .5);
9983
9994
  const pos = this.pos.add(isHorizontal ? vec2(p, 0) : vec2(0, p));
@@ -9986,7 +9997,7 @@ class UIScrollbar extends UIObject
9986
9997
  uiSystem.drawRect(pos, drawSize, color, this.lineWidth, this.lineColor, this.cornerRadius, this.gradientColor);
9987
9998
  }
9988
9999
 
9989
- // draw the text scaled to fit on the scrollbar
10000
+ // draw the text scaled to fit on the slider
9990
10001
  const textSize = this.getTextSize();
9991
10002
  uiSystem.drawText(this.text, this.pos, textSize,
9992
10003
  this.textColor, this.textLineWidth, this.textLineColor, this.align, this.font, this.fontStyle, true, this.textShadow);
@@ -10261,7 +10272,7 @@ class Box2dObject extends EngineObject
10261
10272
  // draw non-edge fixtures
10262
10273
  this.getFixtureList().forEach((fixture)=>
10263
10274
  {
10264
- const shape = box2d.castObjectType(fixture.GetShape());
10275
+ const shape = box2d.castShapeObject(fixture.GetShape());
10265
10276
  if (shape.GetType() !== box2d.instance.b2Shape.e_edge)
10266
10277
  {
10267
10278
  box2d.drawFixture(fixture, this.pos, this.angle, color, lineColor, lineWidth, useWebGL, context);
@@ -10901,7 +10912,7 @@ class Box2dJoint
10901
10912
  constructor(jointDef)
10902
10913
  {
10903
10914
  /** @property {Object} - The Box2d joint */
10904
- this.box2dJoint = box2d.castObjectType(box2d.world.CreateJoint(jointDef));
10915
+ this.box2dJoint = box2d.castJointObject(box2d.world.CreateJoint(jointDef));
10905
10916
  }
10906
10917
 
10907
10918
  /** Destroy this joint */
@@ -11186,7 +11197,7 @@ class Box2dRevoluteJoint extends Box2dJoint
11186
11197
 
11187
11198
  /** Enable/disable the joint limit
11188
11199
  * @param {boolean} [enable] */
11189
- enableLimit(enable=true) { return this.box2dJoint.enableLimit(enable); }
11200
+ enableLimit(enable=true) { return this.box2dJoint.EnableLimit(enable); }
11190
11201
 
11191
11202
  /** Get the lower joint limit
11192
11203
  * @return {number} */
@@ -11344,7 +11355,7 @@ class Box2dPrismaticJoint extends Box2dJoint
11344
11355
 
11345
11356
  /** Enable/disable the joint limit
11346
11357
  * @param {boolean} [enable] */
11347
- enableLimit(enable=true) { return this.box2dJoint.enableLimit(enable); }
11358
+ enableLimit(enable=true) { return this.box2dJoint.EnableLimit(enable); }
11348
11359
 
11349
11360
  /** Get the lower joint limit
11350
11361
  * @return {number} */
@@ -11958,7 +11969,7 @@ class Box2dPlugin
11958
11969
  * @param {CanvasRenderingContext2D} [context] */
11959
11970
  drawFixture(fixture, pos, angle, color=WHITE, lineColor=BLACK, lineWidth=.1, useWebgl, context)
11960
11971
  {
11961
- const shape = box2d.castObjectType(fixture.GetShape());
11972
+ const shape = box2d.castShapeObject(fixture.GetShape());
11962
11973
  switch (shape.GetType())
11963
11974
  {
11964
11975
  case box2d.instance.b2Shape.e_polygon:
@@ -12016,9 +12027,9 @@ class Box2dPlugin
12016
12027
  * @param {Object} o */
12017
12028
  isNull(o) { return !box2d.instance.getPointer(o); }
12018
12029
 
12019
- /** casts a box2d object to its correct type
12030
+ /** casts a box2d object to a shape type
12020
12031
  * @param {Object} o */
12021
- castObjectType(o)
12032
+ castShapeObject(o)
12022
12033
  {
12023
12034
  switch (o.GetType())
12024
12035
  {
@@ -12030,6 +12041,17 @@ class Box2dPlugin
12030
12041
  return box2d.instance.castObject(o, box2d.instance.b2PolygonShape);
12031
12042
  case box2d.instance.b2Shape.e_chain:
12032
12043
  return box2d.instance.castObject(o, box2d.instance.b2ChainShape);
12044
+ }
12045
+
12046
+ ASSERT(false, 'Unknown box2d object type');
12047
+ }
12048
+
12049
+ /** casts a box2d object to a joint type
12050
+ * @param {Object} o */
12051
+ castJointObject(o)
12052
+ {
12053
+ switch (o.GetType())
12054
+ {
12033
12055
  case box2d.instance.e_revoluteJoint:
12034
12056
  return box2d.instance.castObject(o, box2d.instance.b2RevoluteJoint);
12035
12057
  case box2d.instance.e_prismaticJoint:
@@ -1,5 +1,5 @@
1
1
  <!DOCTYPE html><meta charset=utf-8><body>
2
- <script src=../../dist/littlejs.js?1.17.15></script>
2
+ <script src=../../dist/littlejs.js?1.18.0></script>
3
3
  <script src=../../dist/box2d.wasm.js></script>
4
4
 
5
5
  <!-- LittleJS Engine Source
@@ -20,7 +20,7 @@ function gameInit()
20
20
  musicPlayer.addChild(infoText);
21
21
 
22
22
  // volume slider
23
- const volumeSlider = new UIScrollbar(vec2(0, -20), vec2(400, 30),
23
+ const volumeSlider = new UISlider(vec2(0, -20), vec2(400, 30),
24
24
  musicVolume, 'Music Volume');
25
25
  volumeSlider.fillMode = true;
26
26
  musicPlayer.addChild(volumeSlider);
@@ -26,7 +26,7 @@ function gameInit()
26
26
  musicPlayer.addChild(dropZoneText);
27
27
 
28
28
  // volume slider
29
- const volumeSlider = new UIScrollbar(vec2(0, -20), vec2(400, 30),
29
+ const volumeSlider = new UISlider(vec2(0, -20), vec2(400, 30),
30
30
  musicVolume, 'Music Volume');
31
31
  volumeSlider.fillMode = true;
32
32
  musicPlayer.addChild(volumeSlider);
@@ -58,8 +58,8 @@ function gameInit()
58
58
  stopButton.onClick = ()=> musicInstance?.stop();
59
59
  musicPlayer.addChild(stopButton);
60
60
 
61
- // progress bar and scrollbar for seeking
62
- progressBar = new UIScrollbar(vec2(0, 120), vec2(400, 30), 0);
61
+ // progress bar and slider for seeking
62
+ progressBar = new UISlider(vec2(0, 120), vec2(400, 30), 0);
63
63
  progressBar.disabledColor = RED;
64
64
  progressBar.onChange = ()=>
65
65
  {
@@ -91,7 +91,7 @@ function gameInit()
91
91
  // create tempo slider
92
92
  const minTempo = 120, maxTempo = 480;
93
93
  const tempoPercent = percent(tempo, minTempo, maxTempo);
94
- const tempoSlider = new UIScrollbar(vec2(380,500), vec2(340,40), tempoPercent);
94
+ const tempoSlider = new UISlider(vec2(380,500), vec2(340,40), tempoPercent);
95
95
  tempoSlider.onChange = ()=>
96
96
  {
97
97
  tempo = lerp(minTempo, maxTempo, tempoSlider.value);
@@ -30,7 +30,7 @@ function gameInit()
30
30
  }
31
31
 
32
32
  // create non-interactive slider to display timer
33
- timerSlider = new UIScrollbar(vec2(0, 100), vec2(400, 50));
33
+ timerSlider = new UISlider(vec2(0, 100), vec2(400, 50));
34
34
  timerSlider.interactive = false;
35
35
  timerSlider.update = ()=>
36
36
  {
@@ -33,12 +33,12 @@ function gameInit()
33
33
  uiMenu.addChild(textInput);
34
34
  textInput.onChange = ()=> canvasClearColor = randColor();
35
35
 
36
- // example scrollbar
37
- const scrollbar = new UIScrollbar(vec2(0,90), vec2(400, 50),
36
+ // example slider
37
+ const slider = new UISlider(vec2(0,90), vec2(400, 50),
38
38
  soundVolume, 'Volume');
39
- scrollbar.navigationIndex = ++navigationIndex;
40
- uiMenu.addChild(scrollbar);
41
- scrollbar.onChange = ()=> setSoundVolume(scrollbar.value);
39
+ slider.navigationIndex = ++navigationIndex;
40
+ uiMenu.addChild(slider);
41
+ slider.onChange = ()=> setSoundVolume(slider.value);
42
42
 
43
43
  // exit button
44
44
  const button1 = new UIButton(vec2(0,170), vec2(200, 50), 'Exit Menu');
@@ -7,7 +7,7 @@
7
7
  </head><body>
8
8
 
9
9
  <!-- LittleJS Engine -->
10
- <script src=../../dist/littlejs.js?1.17.15></script>
10
+ <script src=../../dist/littlejs.js?1.18.0></script>
11
11
 
12
12
  <!-- LittleJS Engine Source
13
13
  <script src=../../src/engine.js></script>
@@ -32,4 +32,4 @@
32
32
  -->
33
33
 
34
34
  <!-- Add your game scripts here -->
35
- <script src=game.js?1.17.15></script>
35
+ <script src=game.js?1.18.0></script>
@@ -67,12 +67,12 @@ function createUI()
67
67
  checkbox.navigationIndex = ++navigationIndex;
68
68
  checkbox.text = 'Test Checkbox';
69
69
 
70
- // example scrollbar
71
- const scrollbar = new LJS.UIScrollbar(vec2(0,60), vec2(350, 50));
72
- uiMenu.addChild(scrollbar);
73
- scrollbar.onChange = ()=> scrollbar.text = scrollbar.value.toFixed(2)
74
- scrollbar.onChange();
75
- scrollbar.navigationIndex = ++navigationIndex;
70
+ // example slider
71
+ const slider = new LJS.UISlider(vec2(0,60), vec2(350, 50));
72
+ uiMenu.addChild(slider);
73
+ slider.onChange = ()=> slider.text = slider.value.toFixed(2)
74
+ slider.onChange();
75
+ slider.navigationIndex = ++navigationIndex;
76
76
 
77
77
  // example button
78
78
  const button1 = new LJS.UIButton(vec2(0,140), vec2(350, 50), 'Test Button');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "littlejsengine",
3
- "version": "1.17.15",
3
+ "version": "1.18.0",
4
4
  "description": "LittleJS - Tiny and Fast HTML5 Game Engine",
5
5
  "main": "dist/littlejs.esm.js",
6
6
  "types": "dist/littlejs.d.ts",
package/plugins/box2d.js CHANGED
@@ -119,7 +119,7 @@ class Box2dObject extends EngineObject
119
119
  // draw non-edge fixtures
120
120
  this.getFixtureList().forEach((fixture)=>
121
121
  {
122
- const shape = box2d.castObjectType(fixture.GetShape());
122
+ const shape = box2d.castShapeObject(fixture.GetShape());
123
123
  if (shape.GetType() !== box2d.instance.b2Shape.e_edge)
124
124
  {
125
125
  box2d.drawFixture(fixture, this.pos, this.angle, color, lineColor, lineWidth, useWebGL, context);
@@ -759,7 +759,7 @@ class Box2dJoint
759
759
  constructor(jointDef)
760
760
  {
761
761
  /** @property {Object} - The Box2d joint */
762
- this.box2dJoint = box2d.castObjectType(box2d.world.CreateJoint(jointDef));
762
+ this.box2dJoint = box2d.castJointObject(box2d.world.CreateJoint(jointDef));
763
763
  }
764
764
 
765
765
  /** Destroy this joint */
@@ -1044,7 +1044,7 @@ class Box2dRevoluteJoint extends Box2dJoint
1044
1044
 
1045
1045
  /** Enable/disable the joint limit
1046
1046
  * @param {boolean} [enable] */
1047
- enableLimit(enable=true) { return this.box2dJoint.enableLimit(enable); }
1047
+ enableLimit(enable=true) { return this.box2dJoint.EnableLimit(enable); }
1048
1048
 
1049
1049
  /** Get the lower joint limit
1050
1050
  * @return {number} */
@@ -1202,7 +1202,7 @@ class Box2dPrismaticJoint extends Box2dJoint
1202
1202
 
1203
1203
  /** Enable/disable the joint limit
1204
1204
  * @param {boolean} [enable] */
1205
- enableLimit(enable=true) { return this.box2dJoint.enableLimit(enable); }
1205
+ enableLimit(enable=true) { return this.box2dJoint.EnableLimit(enable); }
1206
1206
 
1207
1207
  /** Get the lower joint limit
1208
1208
  * @return {number} */
@@ -1816,7 +1816,7 @@ class Box2dPlugin
1816
1816
  * @param {CanvasRenderingContext2D} [context] */
1817
1817
  drawFixture(fixture, pos, angle, color=WHITE, lineColor=BLACK, lineWidth=.1, useWebgl, context)
1818
1818
  {
1819
- const shape = box2d.castObjectType(fixture.GetShape());
1819
+ const shape = box2d.castShapeObject(fixture.GetShape());
1820
1820
  switch (shape.GetType())
1821
1821
  {
1822
1822
  case box2d.instance.b2Shape.e_polygon:
@@ -1874,9 +1874,9 @@ class Box2dPlugin
1874
1874
  * @param {Object} o */
1875
1875
  isNull(o) { return !box2d.instance.getPointer(o); }
1876
1876
 
1877
- /** casts a box2d object to its correct type
1877
+ /** casts a box2d object to a shape type
1878
1878
  * @param {Object} o */
1879
- castObjectType(o)
1879
+ castShapeObject(o)
1880
1880
  {
1881
1881
  switch (o.GetType())
1882
1882
  {
@@ -1888,6 +1888,17 @@ class Box2dPlugin
1888
1888
  return box2d.instance.castObject(o, box2d.instance.b2PolygonShape);
1889
1889
  case box2d.instance.b2Shape.e_chain:
1890
1890
  return box2d.instance.castObject(o, box2d.instance.b2ChainShape);
1891
+ }
1892
+
1893
+ ASSERT(false, 'Unknown box2d object type');
1894
+ }
1895
+
1896
+ /** casts a box2d object to a joint type
1897
+ * @param {Object} o */
1898
+ castJointObject(o)
1899
+ {
1900
+ switch (o.GetType())
1901
+ {
1891
1902
  case box2d.instance.e_revoluteJoint:
1892
1903
  return box2d.instance.castObject(o, box2d.instance.b2RevoluteJoint);
1893
1904
  case box2d.instance.e_prismaticJoint:
@@ -27,7 +27,7 @@ export
27
27
  UITile,
28
28
  UIButton,
29
29
  UICheckbox,
30
- UIScrollbar,
30
+ UISlider,
31
31
  UIVideo,
32
32
 
33
33
  // Box2D Physics
@@ -7,7 +7,7 @@
7
7
  * - Buttons
8
8
  * - Checkboxes
9
9
  * - Images
10
- * - Scrollbars
10
+ * - Sliders
11
11
  * - Video
12
12
  * @namespace UISystem
13
13
  */
@@ -1206,7 +1206,7 @@ class UICheckbox extends UIObject
1206
1206
  ASSERT(isString(text), 'ui checkbox must be a string');
1207
1207
  ASSERT(isColor(color), 'ui checkbox color must be a color');
1208
1208
 
1209
- /** @property {boolean} - Current percentage value of this scrollbar 0-1 */
1209
+ /** @property {boolean} - Current percentage value of this slider 0-1 */
1210
1210
  this.checked = checked;
1211
1211
  // set properties
1212
1212
  this.text = text;
@@ -1241,13 +1241,13 @@ class UICheckbox extends UIObject
1241
1241
 
1242
1242
  ///////////////////////////////////////////////////////////////////////////////
1243
1243
  /**
1244
- * UIScrollbar - A UI object that acts as a scrollbar
1244
+ * UISlider - A UI object that acts as a slider or scrollbar
1245
1245
  * @extends UIObject
1246
1246
  * @memberof UISystem
1247
1247
  */
1248
- class UIScrollbar extends UIObject
1248
+ class UISlider extends UIObject
1249
1249
  {
1250
- /** Create a UIScrollbar object
1250
+ /** Create a UISlider object
1251
1251
  * @param {Vector2} [pos]
1252
1252
  * @param {Vector2} [size]
1253
1253
  * @param {number} [value]
@@ -1259,14 +1259,14 @@ class UIScrollbar extends UIObject
1259
1259
  {
1260
1260
  super(pos, size);
1261
1261
 
1262
- ASSERT(isNumber(value), 'ui scrollbar value must be a number');
1263
- ASSERT(isString(text), 'ui scrollbar must be a string');
1264
- ASSERT(isColor(color), 'ui scrollbar color must be a color');
1265
- ASSERT(isColor(handleColor), 'ui scrollbar handleColor must be a color');
1262
+ ASSERT(isNumber(value), 'ui slider value must be a number');
1263
+ ASSERT(isString(text), 'ui slider must be a string');
1264
+ ASSERT(isColor(color), 'ui slider color must be a color');
1265
+ ASSERT(isColor(handleColor), 'ui slider handleColor must be a color');
1266
1266
 
1267
- /** @property {number} - Current percentage value of this scrollbar 0-1 */
1267
+ /** @property {number} - Current percentage value of this slider 0-1 */
1268
1268
  this.value = value;
1269
- /** @property {Color} - Color for the handle part of the scrollbar */
1269
+ /** @property {Color} - Color for the handle part of the slider */
1270
1270
  this.handleColor = handleColor.copy();
1271
1271
  /** @property {boolean} - Should it fill up like a progress bar? */
1272
1272
  this.fillMode = false;
@@ -1285,7 +1285,7 @@ class UIScrollbar extends UIObject
1285
1285
  const oldValue = this.value;
1286
1286
  if (this.isActiveObject())
1287
1287
  {
1288
- // handle horizontal or vertical scrollbar
1288
+ // handle horizontal or vertical slider
1289
1289
  const isHorizontal = this.size.x > this.size.y;
1290
1290
  const handleSize = isHorizontal ? this.size.y : this.size.x;
1291
1291
  const barSize = isHorizontal ? this.size.x : this.size.y;
@@ -1313,7 +1313,7 @@ class UIScrollbar extends UIObject
1313
1313
  {
1314
1314
  super.render();
1315
1315
 
1316
- // handle horizontal or vertical scrollbar
1316
+ // handle horizontal or vertical slider
1317
1317
  const isHorizontal = this.size.x > this.size.y;
1318
1318
  const barWidth = isHorizontal ? this.size.x : this.size.y;
1319
1319
  const handleWidth = isHorizontal ? this.size.y : this.size.x;
@@ -1331,7 +1331,7 @@ class UIScrollbar extends UIObject
1331
1331
  }
1332
1332
  else
1333
1333
  {
1334
- // draw the scrollbar handle
1334
+ // draw the slider handle
1335
1335
  const value = clamp(isHorizontal ? this.value : 1 - this.value);
1336
1336
  const p = (barWidth - handleWidth) * (value - .5);
1337
1337
  const pos = this.pos.add(isHorizontal ? vec2(p, 0) : vec2(0, p));
@@ -1340,7 +1340,7 @@ class UIScrollbar extends UIObject
1340
1340
  uiSystem.drawRect(pos, drawSize, color, this.lineWidth, this.lineColor, this.cornerRadius, this.gradientColor);
1341
1341
  }
1342
1342
 
1343
- // draw the text scaled to fit on the scrollbar
1343
+ // draw the text scaled to fit on the slider
1344
1344
  const textSize = this.getTextSize();
1345
1345
  uiSystem.drawText(this.text, this.pos, textSize,
1346
1346
  this.textColor, this.textLineWidth, this.textLineColor, this.align, this.font, this.fontStyle, true, this.textShadow);
package/src/engine.js CHANGED
@@ -32,7 +32,7 @@ const engineName = 'LittleJS';
32
32
  * @type {string}
33
33
  * @default
34
34
  * @memberof Engine */
35
- const engineVersion = '1.17.15';
35
+ const engineVersion = '1.18.0';
36
36
 
37
37
  /** Frames per second to update
38
38
  * @type {number}
@@ -276,8 +276,6 @@ function debugUpdate()
276
276
  debugOverlay = !debugOverlay;
277
277
  if (debugOverlay)
278
278
  {
279
- if (keyWasPressed('Digit0'))
280
- debugWatermark = !debugWatermark;
281
279
  if (keyWasPressed('Digit1'))
282
280
  debugPhysics = !debugPhysics, debugParticles = false;
283
281
  if (keyWasPressed('Digit2'))
@@ -565,7 +563,7 @@ function debugRenderPost()
565
563
  return;
566
564
  }
567
565
 
568
- if (!debugWatermark) return;
566
+ if (!debugWatermark && !debugOverlay) return;
569
567
 
570
568
  // update fps display
571
569
  mainContext.textAlign = 'right';
@@ -83,6 +83,7 @@ export
83
83
  touchGamepadAnalog,
84
84
  touchGamepadSize,
85
85
  touchGamepadAlpha,
86
+ touchGamepadDisplayTime,
86
87
  vibrateEnable,
87
88
  soundEnable,
88
89
  soundVolume,
@@ -727,10 +727,10 @@ function inputRender()
727
727
  function touchGamepadRender()
728
728
  {
729
729
  if (!touchInputEnable || !isTouchDevice || headlessMode) return;
730
- if (!touchGamepadEnable || !touchGamepadTimer.isSet()) return;
730
+ if (!touchGamepadEnable || !touchGamepadTimer.isSet() && touchGamepadDisplayTime) return;
731
731
 
732
732
  // fade off when not touching or paused
733
- const alpha = percent(touchGamepadTimer.get(), 4, 3);
733
+ const alpha = touchGamepadDisplayTime ? percent(touchGamepadTimer.get(), touchGamepadDisplayTime+1, touchGamepadDisplayTime) : 1;
734
734
  if (!alpha || paused) return;
735
735
 
736
736
  // setup the canvas
@@ -260,6 +260,12 @@ let touchGamepadSize = 99;
260
260
  * @memberof Settings */
261
261
  let touchGamepadAlpha = .3;
262
262
 
263
+ /** How long to display the touch gamepad on screen in seconds, set to 0 to always display
264
+ * @type {number}
265
+ * @default
266
+ * @memberof Settings */
267
+ let touchGamepadDisplayTime = 3;
268
+
263
269
  /** Allow vibration hardware if it exists
264
270
  * @type {boolean}
265
271
  * @default
@@ -534,6 +540,11 @@ function setTouchGamepadSize(size) { touchGamepadSize = size; }
534
540
  * @memberof Settings */
535
541
  function setTouchGamepadAlpha(alpha) { touchGamepadAlpha = alpha; }
536
542
 
543
+ /** Set how long to display the touch gamepad on screen in seconds, set to 0 to always display
544
+ * @param {number} time
545
+ * @memberof Settings */
546
+ function setTouchGamepadDisplayTime(time) { touchGamepadDisplayTime = time; }
547
+
537
548
  /** Set to allow vibration hardware if it exists
538
549
  * @param {boolean} enable
539
550
  * @memberof Settings */