@@ -35,7 +35,7 @@ const engineName = 'LittleJS';
3535 * @type {string }
3636 * @default
3737 * @memberof Engine */
38- const engineVersion = '1.17.15 ' ;
38+ const engineVersion = '1.18.0 ' ;
3939
4040/** Frames per second to update
4141 * @type {number }
@@ -9344,7 +9344,7 @@ function zzfxM(instruments, patterns, sequence, BPM = 125)
93449344 * - Buttons
93459345 * - Checkboxes
93469346 * - Images
9347- * - Scrollbars
9347+ * - Sliders
93489348 * - Video
93499349 * @namespace UISystem
93509350 */
@@ -10541,7 +10541,7 @@ class UICheckbox extends UIObject
1054110541 ASSERT ( isString ( text ) , 'ui checkbox must be a string' ) ;
1054210542 ASSERT ( isColor ( color ) , 'ui checkbox color must be a color' ) ;
1054310543
10544- /** @property {boolean } - Current percentage value of this scrollbar 0-1 */
10544+ /** @property {boolean } - Current percentage value of this slider 0-1 */
1054510545 this . checked = checked ;
1054610546 // set properties
1054710547 this . text = text ;
@@ -10576,13 +10576,13 @@ class UICheckbox extends UIObject
1057610576
1057710577///////////////////////////////////////////////////////////////////////////////
1057810578/**
10579- * UIScrollbar - A UI object that acts as a scrollbar
10579+ * UISlider - A UI object that acts as a slider or scrollbar
1058010580 * @extends UIObject
1058110581 * @memberof UISystem
1058210582 */
10583- class UIScrollbar extends UIObject
10583+ class UISlider extends UIObject
1058410584{
10585- /** Create a UIScrollbar object
10585+ /** Create a UISlider object
1058610586 * @param {Vector2 } [pos]
1058710587 * @param {Vector2 } [size]
1058810588 * @param {number } [value]
@@ -10594,14 +10594,14 @@ class UIScrollbar extends UIObject
1059410594 {
1059510595 super ( pos , size ) ;
1059610596
10597- ASSERT ( isNumber ( value ) , 'ui scrollbar value must be a number' ) ;
10598- ASSERT ( isString ( text ) , 'ui scrollbar must be a string' ) ;
10599- ASSERT ( isColor ( color ) , 'ui scrollbar color must be a color' ) ;
10600- ASSERT ( isColor ( handleColor ) , 'ui scrollbar handleColor must be a color' ) ;
10597+ ASSERT ( isNumber ( value ) , 'ui slider value must be a number' ) ;
10598+ ASSERT ( isString ( text ) , 'ui slider must be a string' ) ;
10599+ ASSERT ( isColor ( color ) , 'ui slider color must be a color' ) ;
10600+ ASSERT ( isColor ( handleColor ) , 'ui slider handleColor must be a color' ) ;
1060110601
10602- /** @property {number } - Current percentage value of this scrollbar 0-1 */
10602+ /** @property {number } - Current percentage value of this slider 0-1 */
1060310603 this . value = value ;
10604- /** @property {Color } - Color for the handle part of the scrollbar */
10604+ /** @property {Color } - Color for the handle part of the slider */
1060510605 this . handleColor = handleColor . copy ( ) ;
1060610606 /** @property {boolean } - Should it fill up like a progress bar? */
1060710607 this . fillMode = false ;
@@ -10620,7 +10620,7 @@ class UIScrollbar extends UIObject
1062010620 const oldValue = this . value ;
1062110621 if ( this . isActiveObject ( ) )
1062210622 {
10623- // handle horizontal or vertical scrollbar
10623+ // handle horizontal or vertical slider
1062410624 const isHorizontal = this . size . x > this . size . y ;
1062510625 const handleSize = isHorizontal ? this . size . y : this . size . x ;
1062610626 const barSize = isHorizontal ? this . size . x : this . size . y ;
@@ -10648,7 +10648,7 @@ class UIScrollbar extends UIObject
1064810648 {
1064910649 super . render ( ) ;
1065010650
10651- // handle horizontal or vertical scrollbar
10651+ // handle horizontal or vertical slider
1065210652 const isHorizontal = this . size . x > this . size . y ;
1065310653 const barWidth = isHorizontal ? this . size . x : this . size . y ;
1065410654 const handleWidth = isHorizontal ? this . size . y : this . size . x ;
@@ -10666,7 +10666,7 @@ class UIScrollbar extends UIObject
1066610666 }
1066710667 else
1066810668 {
10669- // draw the scrollbar handle
10669+ // draw the slider handle
1067010670 const value = clamp ( isHorizontal ? this . value : 1 - this . value ) ;
1067110671 const p = ( barWidth - handleWidth ) * ( value - .5 ) ;
1067210672 const pos = this . pos . add ( isHorizontal ? vec2 ( p , 0 ) : vec2 ( 0 , p ) ) ;
@@ -10675,7 +10675,7 @@ class UIScrollbar extends UIObject
1067510675 uiSystem . drawRect ( pos , drawSize , color , this . lineWidth , this . lineColor , this . cornerRadius , this . gradientColor ) ;
1067610676 }
1067710677
10678- // draw the text scaled to fit on the scrollbar
10678+ // draw the text scaled to fit on the slider
1067910679 const textSize = this . getTextSize ( ) ;
1068010680 uiSystem . drawText ( this . text , this . pos , textSize ,
1068110681 this . textColor , this . textLineWidth , this . textLineColor , this . align , this . font , this . fontStyle , true , this . textShadow ) ;
@@ -10950,7 +10950,7 @@ class Box2dObject extends EngineObject
1095010950 // draw non-edge fixtures
1095110951 this . getFixtureList ( ) . forEach ( ( fixture ) =>
1095210952 {
10953- const shape = box2d . castObjectType ( fixture . GetShape ( ) ) ;
10953+ const shape = box2d . castShapeObject ( fixture . GetShape ( ) ) ;
1095410954 if ( shape . GetType ( ) !== box2d . instance . b2Shape . e_edge )
1095510955 {
1095610956 box2d . drawFixture ( fixture , this . pos , this . angle , color , lineColor , lineWidth , useWebGL , context ) ;
@@ -11590,7 +11590,7 @@ class Box2dJoint
1159011590 constructor ( jointDef )
1159111591 {
1159211592 /** @property {Object } - The Box2d joint */
11593- this . box2dJoint = box2d . castObjectType ( box2d . world . CreateJoint ( jointDef ) ) ;
11593+ this . box2dJoint = box2d . castJointObject ( box2d . world . CreateJoint ( jointDef ) ) ;
1159411594 }
1159511595
1159611596 /** Destroy this joint */
@@ -11875,7 +11875,7 @@ class Box2dRevoluteJoint extends Box2dJoint
1187511875
1187611876 /** Enable/disable the joint limit
1187711877 * @param {boolean } [enable] */
11878- enableLimit ( enable = true ) { return this . box2dJoint . enableLimit ( enable ) ; }
11878+ enableLimit ( enable = true ) { return this . box2dJoint . EnableLimit ( enable ) ; }
1187911879
1188011880 /** Get the lower joint limit
1188111881 * @return {number } */
@@ -12033,7 +12033,7 @@ class Box2dPrismaticJoint extends Box2dJoint
1203312033
1203412034 /** Enable/disable the joint limit
1203512035 * @param {boolean } [enable] */
12036- enableLimit ( enable = true ) { return this . box2dJoint . enableLimit ( enable ) ; }
12036+ enableLimit ( enable = true ) { return this . box2dJoint . EnableLimit ( enable ) ; }
1203712037
1203812038 /** Get the lower joint limit
1203912039 * @return {number } */
@@ -12647,7 +12647,7 @@ class Box2dPlugin
1264712647 * @param {CanvasRenderingContext2D } [context] */
1264812648 drawFixture ( fixture , pos , angle , color = WHITE , lineColor = BLACK , lineWidth = .1 , useWebgl , context )
1264912649 {
12650- const shape = box2d . castObjectType ( fixture . GetShape ( ) ) ;
12650+ const shape = box2d . castShapeObject ( fixture . GetShape ( ) ) ;
1265112651 switch ( shape . GetType ( ) )
1265212652 {
1265312653 case box2d . instance . b2Shape . e_polygon :
@@ -12705,9 +12705,9 @@ class Box2dPlugin
1270512705 * @param {Object } o */
1270612706 isNull ( o ) { return ! box2d . instance . getPointer ( o ) ; }
1270712707
12708- /** casts a box2d object to its correct type
12708+ /** casts a box2d object to a shape type
1270912709 * @param {Object } o */
12710- castObjectType ( o )
12710+ castShapeObject ( o )
1271112711 {
1271212712 switch ( o . GetType ( ) )
1271312713 {
@@ -12719,6 +12719,17 @@ class Box2dPlugin
1271912719 return box2d . instance . castObject ( o , box2d . instance . b2PolygonShape ) ;
1272012720 case box2d . instance . b2Shape . e_chain :
1272112721 return box2d . instance . castObject ( o , box2d . instance . b2ChainShape ) ;
12722+ }
12723+
12724+ ASSERT ( false , 'Unknown box2d object type' ) ;
12725+ }
12726+
12727+ /** casts a box2d object to a joint type
12728+ * @param {Object } o */
12729+ castJointObject ( o )
12730+ {
12731+ switch ( o . GetType ( ) )
12732+ {
1272212733 case box2d . instance . e_revoluteJoint :
1272312734 return box2d . instance . castObject ( o , box2d . instance . b2RevoluteJoint ) ;
1272412735 case box2d . instance . e_prismaticJoint :
@@ -13370,7 +13381,7 @@ export
1337013381 UITile ,
1337113382 UIButton ,
1337213383 UICheckbox ,
13373- UIScrollbar ,
13384+ UISlider ,
1337413385 UIVideo ,
1337513386
1337613387 // Box2D Physics
0 commit comments