I declare these two doubles at class level.
private double interval = 2;
private double interval2 = 3;
These two intervals control a second based timer.
Now during the code I have a IUpdate method that updates every second. Each second I check the user’s score and if its a certain score I try to:
interval = interval - .5
interval = interval2 - .5;
I try to subtract .5 from the interval itself and supply the new double to my timer
timer.setInterval(interval);
timer.setInterval(interval2);
Now the only problem is im noticing that nothing gets subtracted from my variables. I log them when they are SUPPOSED to change but nothing happens. Is there something im missing here?
You have:
intervalshould beinterval2, thereforeinterval2isn’t being modified. The reason that the timer isn’t changing is becauseinterval2isn’t being assigned a new value, and because the timer is always set to an interval of valueinterval2:The second call to
timer.setInterval()cancels out the first one.