I need to create a second loop to run every entity’s update method.
I currently do this
=========================================
private Timer timeFPS = new Timer();
private TimerTask tt = new TimerTask(){
public void run(){
updateEntities();
}
};
@Override
public void simpleUpdate(float tpf){
try{
timeFPS.scheduleAtFixedRate(tt,500,500);//run every 0.5seconds
}catch (IllegalStateException e) {}
super.simpleUpdate(tpf);
}
=========================================
But for my surprise, the FPS increases if I directly call the updateEntities() method inside the simpleUpdate…
public void simpleUpdate(float tpf){
updateEntities();
super.simpleUpdate(tpf);
}
Is there a better way to do that?