dimanche 29 novembre 2015

Randomly Create Enemies In Android Studio

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() * (6))) { 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