I’m want to make a countdown timer that return value(seconds left) when a touch performed in android. Problem is I use andengine so that the touch event cannot be used inside the method(correct me if I’m wrong).
scene.setOnSceneTouchListener(new IOnSceneTouchListener() {
public boolean onSceneTouchEvent(Scene scene, TouchEvent arg1) {
int counterInt = 60;
Timer timer = new Timer();
counterText.setText(""+counterInt);
timer.wait(1000);
counterText.setText(""+(counterInt-1));
timer.wait(1000);
counterText.setText(""+(counterInt-1));
timer.wait(1000);
counterText.setText(""+(counterInt-1));
}
}
let say default number of counterInt is 60 and its decrease by seconds. When it shows 50 user touch the screen which means activate the touchevent arg1, how I can get the value of counterInt that has ’50’? Thank you…
If you are looking for something like that you want the remaining seconds than its better to use
CountDownTimer. ItsonTick()gives you the exact time left in the timer started and also you can do any stuff when the countdown finishes inside theonFinish().