Using scheduler in a different class


#1

Hi I am having issues when trying to have a function called over and over again because if I use a while loop the application freezes up while its looping through. Using the scheduler would be great as it would only be called every frame freeing the game up to move sprites and stuff. The problem is that the function that needs to be called is in a different class to the scene that is running and needs to use variables that are private to that class. So my question is what do I need to do so that I can use the scheduler in a class that is not the active scene?
Sorry if its a bit hard to make sense of.
All help is greatly appreciated!


#2

Just use inherit CCObject class.
And call CCDirector::sharedDirector()->getScheduler()->scheduleUpdateForTarget(this, 0, true);
It update(float dt) function called ever frame.


#3

thanks that worked perfectally