I'am trying to make an easy java program/game.
In this game an user have an math problem to solve (something like 4*8 = X)
The X is the number that a user have to "hit".
I created a grid layout and when the game start: the math problem is showed and on the grid layout appears 3 solutions which have a timer. Let's say that I have a grid
layout 6*6, then the solution start in the positions let's say 6*0 ,6*3 ,6*5 , and every random seconds the number 6 (in this case) decrease for -1.
To win the user have to hit the button with solution till the solution get in to the position 0*3 (for example).
For every solution I have a timer which looks like this:
public void start_first() {
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
grid[p][P].setText(solution);
grid[p + 1][P].setText("");
grid[p + 1][P].setBorder(null);
p--;
when user == click solution // PSEUDOCODE
timer.cancel();
// HERE I WOULD LIKE TO STOP ALL THE TIMERS NOT ONLY THIS ONE
So I have 3 same timers.. for example this is a timer for the second wrong solution:
public void start_error() {
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
grid[v][V].setText(err);
grid[v + 1][V].setText("");
grid[v + 1][V].setBorder(null);
v--;
when user == click wrong solution // PSEUDOCODE
timer.cancel();
// HERE I WOULD LIKE TO STOP ALL THE TIMERS NOT ONLY THIS ONE
What I would like to do, is when a user hit the right (or wrong) solution that all the timers stop not only one..
Is this possible? Is there something that I can do to make what I want?
Guys thank you in advance for your answers.
Have a nice day!


Sign In
Create Account


Back to top









