How to call update() every 5 seconds

can i do it or the correct way should be setting a custom scheduler(?)

Doesn’t update() get called once per frame? at 60 frames per second, 5 seconds would be 300. What about a conditional inside update() that gets triggered every 300 frames?

i guess ur onupdate will be something like void onupdate(float dt)
add the dt parameter each frame, in the onupdate function. if it exceeds 5.f it exceeds 5 seconds

Do you really want the engine/director update function be ticked every 5 seconds or just one of your functions?
5 secs would be 0.2fps.

You would achieve that with director->setAnimationInterval(5.0f);

If you want to call just another function use a custom scheduler.

@IQD - good idea. The only thing I would see from this is that it changes globally. I’m not sure if the OP wants it global or just for specific instances they need to implement update(). Using a custom scheduler is probably the best way to do this.

Yes, but it makes no sense to implement update() for that reason. It will be called with standard 60fps and you have to use a conditional to react on the dt every 5 seconds.
So instead of wasting CPU cycles on that conditional it’s an ideal thing to use a custom scheduler.

I agree with you.

Thank you guys. Im actually using a conditional inside update(). I’ll see how can change to a custom scheduler. Thanks again.