I have a doubt with the simpleUpdate, I need to do is control the # of times the simpleUpdate calls a function , what happens is that I am taking the time of the system to make the call to the function every 5s but that call occurs between 290 to 350 times but I just need to call 1 time.
public void simpleUpdate(float tpf)
seconds = calendario.get(Calendar.SECOND);
tpf means “time per frame”. And if you want to control how many times the update() is called you do something substantially wrong. Read our tutorials, they explain how you can move stuff etc. without tying to a fixed framerate.
I’m confused… do you want to call it just one time or one time every 5 seconds?
The issue with your code is that it will be (seconds % 5 == 0) for a full second. update() could be called lots of times during that one second. Probably better to just accumulate tpf in a counter and check for seconds > 5 and then clear the counter.
I’m assuming you don’t need real accuracy or a) this is entirely the wrong approach anyway, and b) if this is what’s tripping you up then hard-accuracy may be too complicated.