java - Loop not working with float? -


(libGDX, Java) I'm trying to move an object from one side of the screen and when it is on the other side Access, which initiates the code I use for action:

  if (position.x <300) {position.x - = 1; } If (position.x == -70) {position.x = 131; }  

The situation is a vector 2. 1 is the speed of the movement of the object and where I have the problem. Position the loop if it is okay. X - = a whole number, but if I want it to be 0.3F, 1.5 F ... the loop will not work and the object is still moving forward. How can it fix so that the loop works with any number?

This is due to binary because the temporary numbers represent each integer (not very large) representing a binary Number is in the form but it does not have an accurate representation in 0.3.

Required) & lt; 0.000001); }


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -