I'm making my first android game, and i want to create a random enemy every three seconds, i have six enemies but my code it's not working!!
I don't know what i'm missing or doing wrong, i have a red line under (rand == 0)
and (rand == 1)
.
Please help!
The code i'm using:
if (EnemyElapsed > (2000-alien.getScore()/4)){
switch ((int) (rand.nextDouble() * (2))) {
if(rand == 0){
enemy.add(new Enemy(BitmapFactory.decodeResource(getResources(), R.drawable.dog), WIDTH + 10,60, 250, 250, alien.getScore(), 2));
enemyStartTime = System.nanoTime();
}
else if(rand == 1){
enemy.add(new Enemy(BitmapFactory.decodeResource(getResources(), R.drawable.aalien), WIDTH + 10,60, 250, 250, alien.getScore(), 2));
enemyStartTime = System.nanoTime();
}
}
}
Aucun commentaire:
Enregistrer un commentaire