Currently in my Android Game there is a simple thread that runs, decreasing a horizontal progressbar by 1 every X milliseconds. I'm trying to implement a method so when the progressbar hits 0, a TextView changes to "Game Over". The app crashes whenever this function is called in this way. I have also initialized the variable correctly so the method should have no trouble seeing this TextView.
public class MyThread extends Thread{
@Override
public void run(){
while (counter > 0 && keepRunning){
counter = counter - 1;
android.os.SystemClock.sleep(calculateSleepTick());
mHandler.post(new Runnable() {
@Override
public void run() {
progressTest.setProgress(counter);
}
});
}
isGameOver();
}
}
public void isGameOver(){
scoreText.setText("Game Over");
}