Advertisement
Guest User

run nanoTime() usage

a guest
Sep 5th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public void run() {
  2. Rect dstRect = new Rect();
  3. long startTime = System.nanoTime();
  4. while(running) {
  5. if(!holder.getSurface().isValid())
  6. continue;
  7.  
  8. float deltaTime = (System.nanoTime()-startTime) / 1000000000.0f;
  9. startTime = System.nanoTime();
  10.  
  11. game.getCurrentScreen().update(deltaTime);
  12. game.getCurrentScreen().present(deltaTime);
  13.  
  14. Canvas canvas = holder.lockCanvas();
  15. canvas.getClipBounds(dstRect);
  16. canvas.drawBitmap(framebuffer, null, dstRect, null);
  17. holder.unlockCanvasAndPost(canvas);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement