truncate float refactor

This commit is contained in:
KadeDev
2021-04-23 11:21:44 -07:00
parent 57478c3ef2
commit 412d611f04
2 changed files with 15 additions and 21 deletions

View File

@ -93,12 +93,6 @@ class OptionsMenu extends MusicBeatState
var isCat:Bool = false;
public static function truncateFloat( number : Float, precision : Int): Float {
var num = number;
num = num * Math.pow(10, precision);
num = Math.round( num ) / Math.pow(10, precision);
return num;
}
override function update(elapsed:Float)
{
@ -159,7 +153,7 @@ class OptionsMenu extends MusicBeatState
else if (FlxG.keys.pressed.LEFT)
FlxG.save.data.offset -= 0.1;
versionShit.text = "Offset (Left, Right, Shift for slow): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription;
versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription;
}
}
else
@ -176,7 +170,7 @@ class OptionsMenu extends MusicBeatState
else if (FlxG.keys.pressed.LEFT)
FlxG.save.data.offset -= 0.1;
versionShit.text = "Offset (Left, Right, Shift for slow): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription;
versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription;
}
@ -234,7 +228,7 @@ class OptionsMenu extends MusicBeatState
currentDescription = currentSelectedCat.getOptions()[curSelected].getDescription();
else
currentDescription = "Please select a catagory";
versionShit.text = "Offset (Left, Right, Shift for slow): " + truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription;
versionShit.text = "Offset (Left, Right, Shift for slow): " + HelperFunctions.truncateFloat(FlxG.save.data.offset,2) + " - Description - " + currentDescription;
// selector.y = (70 * curSelected) + 30;