I made a float that adds 1 to it every second using deltaTime then printing it out on the screen, I don't wan't to see all the numbers after the point.
float+=1*deltaTime;
//result is something like this 1.1149411, I instead want it to be just 1.
I made a float that adds 1 to it every second using deltaTime then printing it out on the screen, I don't wan't to see all the numbers after the point.
float+=1*deltaTime;
//result is something like this 1.1149411, I instead want it to be just 1.
There are two options:
casting: this will produce an unrounded result. For example: 2.7 will be converted to 2.
int someInt = (int) someFloat;
rounding: the result will be rounded correctly.
int someInt = Math.round(someFloat);
You could just use a cast to an int
like so:
int integerNumber = (int) yourFloat;