File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -896,16 +896,29 @@ Phaser.Math = {
896896 } ,
897897
898898 /**
899- * Force a value within the boundaries by clamping `x` to the range `[a, b] `.
899+ * Force a value within the boundaries by clamping it to the range `min`, `max `.
900900 *
901901 * @method Phaser.Math#clamp
902- * @param {number } x
903- * @param {number } a
904- * @param {number } b
905- * @return {number }
902+ * @param {float } v - The value to be clamped.
903+ * @param {float } min - The minimum bounds.
904+ * @param {float } max - The maximum bounds.
905+ * @return {number } The clamped value.
906906 */
907- clamp : function ( x , a , b ) {
908- return ( x < a ) ? a : ( ( x > b ) ? b : x ) ;
907+ clamp : function ( v , min , max ) {
908+
909+ if ( v < min )
910+ {
911+ return min ;
912+ }
913+ else if ( max < v )
914+ {
915+ return max ;
916+ }
917+ else
918+ {
919+ return v ;
920+ }
921+
909922 } ,
910923
911924 /**
You can’t perform that action at this time.
0 commit comments