the timer is set in a period of 800 milliseconds, so always RandomPositions() will execute the inner code every 800 milliseconds (the period). Now, what I want is to decrease this number by 50 every 20 seconds or 20,000 milliseconds until it gets the period to 200 milliseconds.
GOAL - IN THE GAME THIS MUST BE INCREASING THE SPEED GRADUALLY EVERY 20 SECONDS.
example: first execution - 800 milliseconds, second execution - 750 milliseconds, third execution - 700 milliseconds, and so on...
What I think is that I could insert a function of type Integer (instead of 800), that can make this job of decreasing from 800 to 200 miliseconds.
How can I make this function? or is there any other solution?
public void RandomPositions() {
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask()
{
public void run() {
getWindowManager().getDefaultDisplay().getMetrics(displaymatrics);
float dx = r.nextFloat() * displaymatrics.widthPixels/1.2f;
float dy = r.nextFloat() * displaymatrics.heightPixels/1.2f;
button.animate().x(dx).y(dy).setDuration(0);
}
}, 0, 800); // first value = Delay , Second value = Period(what I need to change)