I have got a Timer Task, which updates all player positions:
public void run(){
{updateWatcher = new TimerTask() {
public void run() {
update(0.1);
}
};
t.scheduleAtFixedRate(updateWatcher, 5, 5);}
And I also have another TimerTask right under that one, which updates all projectile positions:
UpdateWatcher = new TimerTask() { //Different variable. Note the capital U.
public void run() {
for (Bullet b : bullets){
b.update();
}
}
};
t.scheduleAtFixedRate(UpdateWatcher, 5, 5);
}
However, the second TimerTask is slowing down the first one. If I delete the iteration, like this:
UpdateWatcher = new TimerTask() {
public void run() {
}
};
t.scheduleAtFixedRate(UpdateWatcher, 5, 5);
}
The player moves at the correct speed. However, as soon as I re-add the code (using Eclipse de-bugging to add it live), the delayed task executes a lot less often, causing players to be moving more than 10 times slower than usual.
What could be causing this, and how could I fix it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire