【发布时间】:2014-05-19 02:21:27
【问题描述】:
好的,所以我创建了一个游戏,它运行良好,除了我不希望玩家在一次失败后获胜我希望他必须杀死 10 个敌人我创建了我的 spawnmore 方法,我知道我的问题只是不知道如何解决它,在我的 if 语句中,我有它说 if(dead
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();
}
【问题讨论】:
标签: java swing if-statement time timer