2014-07-08 3 views
0

내 게임을 10 초 동안 실행하고 초를 인쇄하고 0을 치면 게임이 끝납니다. 현재로서는 0에서 10까지 인쇄 할 수 있으며 10 초가 지나면 게임이 끝나지만 역상이 필요합니다.어떻게 카운트 다운 타이머를 인쇄합니까?

time+= delta; 
    System.out.println(String.format("time: %,.2f", time)); 

    if(!tOn) { 
      tOn = true; 

      Timer.schedule(new Task() { 

       @Override 
       public void run() { 
        currentState = GameState.GAMEOVER; 

       } 

      }, 10); 
     } 
+0

그래서 시간을 10 시부 터 시작하고'- = delta;' – BitNinja

답변

-1

time = 10 당신의 변수를 설정하고 Timer 내부 time--로 감소 및이를 인쇄 할 수 있습니다.

int time = 10; 

    System.out.println(String.format("time: %,.2f", time)); 

    if(!tOn) { 
      tOn = true; 
      Timer.schedule(new Task() { 

       @Override 
       public void run() { 
        time--; 
        if(time == 0){ 
         currentState = GameState.GAMEOVER; 
        } 
       } 
      }, 10); 
     } 
관련 문제