Is there a way to schedule a function to be called without using a node?


#1

I need to call a callback after 30 seconds, and I really don’t want to tie it to a node in the scene graph - we’re regularly swapping out scenes, which causes the node to exit and pause its scheduled updates.

I can see that both CCScheduler and CCTimer have “initWithScriptHandler” bound, but I can only find examples of those being used for lua.

I’m about at the point of manually binding some basic timer functions to mimic winow.setTimout(), but I’m hoping there’s an already built in solution to this.

Thanks,
Mark H


#2

@Mark,
I agree, I think we should refactor director.getScheduler.scheduleCallbackForTarget. The target should not depend on CCNode or its subclass.
Thanks for your feedback.