Added 2 second flash notifications.

These notifications are used to notifiy they user of 1ups or level
changes

Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
2012-04-05 12:34:22 -04:00
parent 817e8b4d9f
commit 2bc83e4802
2 changed files with 28 additions and 1 deletions

View File

@@ -126,6 +126,8 @@ public class AsteroidGame extends Thread {
*/
for(int i = 0; i < mGameFrame.getStatusBar().getLevel(); i ++)
addElement(new Asteroid(gen.nextInt(mGameFrame.getDisplayWidth()), gen.nextInt(mGameFrame.getDispalyHeight()), 1, 10, 50, 3, 3, this));
notification("Level "+ mGameFrame.getStatusBar().getLevel());
}
/**
@@ -157,6 +159,30 @@ public class AsteroidGame extends Thread {
initLevel();
startGame();
notification("Level "+ mGameFrame.getStatusBar().getLevel());
}
/**
* Displays a nofication to the user for 2 seconds
* @param string
* @author ricky barrette
*/
private void notification(final String string) {
mGameFrame.setDisplayText(string);
new Thread(new Runnable(){
@Override
public void run(){
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(isStarted)
mGameFrame.setDisplayText(null);
}
}).start();
}
/**
@@ -238,6 +264,8 @@ public class AsteroidGame extends Thread {
if(!hasOneUped){
mGameFrame.getStatusBar().incrementShipCount();
hasOneUped = true;
notification("1up!");
}
} else
hasOneUped = false;

View File

@@ -35,7 +35,6 @@ public class Main {
public Main() {
AsteroidGame game = new AsteroidGame();
game.newGame();
game.startGame();
}
/**