2014-04-07 2 views
0

좋아, 게임을 만들었고 완벽하게 작동합니다. 단 한 번의 패배 이후에 플레이어가 이기고 싶지 않다는 것을 제외하고 나는 그를 10 명의 적을 잘 죽여야 만합니다. 방법과 나는 문제를 안다. 나는 그것을 고치는 법을 모른다. if 문에서 나는 죽을 때마다 그것을 한 번하고 싶을 때 (죽은 < 10) 내 물건을 다룬다. 당신은 내가 여기에서 의미하는 것은 내가 제대로 이해하면 내 방법 덕분에내 if 문장에 무엇을 넣어야합니까?

public void spawnMore(){ 
     int delay = 1000; 


     Timer time = new Timer(delay, new ActionListener(){ 

      public void actionPerformed(ActionEvent e){ 

       if(WizardCells[BadGuy.getx()][BadGuy.gety()].getIcon() != null){ 
        return; 
       } 


       if(WizardCells[BadGuy.getx()][BadGuy.gety()].getIcon() == null){ 
        dead += 1; 
       } 

       if(dead < 10){ 
        int where = (int)(10 + Math.random() *9); 
        BadGuy.spawnEnemy(where, where); 
        move(); 

       } 
      } 
     }); 
     time.start(); 


    } 

답변

1

의 얻을 경우, 당신은 단지 이전 if 문 안에 if 문을 움직일 수 :

public void spawnMore(){ 
    int delay = 1000; 


    Timer time = new Timer(delay, new ActionListener(){ 

     public void actionPerformed(ActionEvent e){ 

      if(WizardCells[BadGuy.getx()][BadGuy.gety()].getIcon() != null){ 
       return; 
      } 


      if(WizardCells[BadGuy.getx()][BadGuy.gety()].getIcon() == null){ 
       dead += 1; 

       if(dead < 10){ 
        int where = (int)(10 + Math.random() *9); 
        BadGuy.spawnEnemy(where, where); 
        move(); 
       } 
      } 

     } 
    }); 
    time.start(); 


} 
관련 문제