Wednesday 15 August 2012

Simple java math function not working -


This is driving me crazy and does not make any sense.

  Private double current time, old time; Float DT; Float xMove = .125f; Name yMove = .125f; Float camera posen = 1.0 f; Float camera POSY = 1.0f; Private Zero camera menu animation () {cameraPosX + = xMove * dt; CameraPC + = yMove * dt; Game CameraAssetCamRapos (CameraPoxX, CameraPossy); System.out.println ("xMove:" + xMove + "cameraDT:" + DT + "Camera PosX:" + cameraPosX); } @ Override Public Zero Update () {currentTime = System.currentTimeMillis (); DT = (float) (current time - old time); OldTime = Current Time; CameraMenuAnimation (); }  

In the println statement above

System.out (21557): xMove: 0.125 Camera DT: 20.0 Camera Pox: 1.7832686 E11

It prints in a loop and camera DT: the values ​​change for each loop as it should be Camera PosX never changes the value and the price is too high How can this be possible? This camera-menu animation () has just one simple multiplication and additional statement

Also, if I work hard code in the value of DT.

  Private Zero camera menu animation () {cameraPosX + = xMove * 20.0; CameraPC + = yMove * 20.0; ...  

How is this possible?

It seems that you have never started old time Explain the behavior you see, that cameraPosX gets a huge value around for the first time and then hardly changes.


No comments:

Post a Comment