Game Development Reference
In-Depth Information
Figure 3-6 . Activating the build setting to warn about undeclared selectors
What's left is to show how to stop these scheduled methods from being called. You can
do so by unscheduling them:
▪ You can stop all scheduled selectors of the node:
[self unscheduleAllSelectors];
▪ You can unscheduled the default update method:
[self unscheduleUpdate];
▪ You can stop a particular selector, in this case the up-
dateTenTimesPerSecond method:
[self
unsched-
ule:@selector(updateTenTimesPerSecond:)];
There's also a useful trick for scheduling and unscheduling selectors. Quite often you'll
find that in the scheduled method, you want a particular method to no longer be called,
without having to replicate the exact name and number of parameters, because they can
change. Here's how you'd run a scheduled selector and stop it on the first call:
[self scheduleOnce:@selector(tenMinutesElapsed:) delay:600];
This is identical to scheduling the selector as usual:
[self schedule:@selector(tenMinutesElapsed:) interval:600];
And then unscheduling the selector inside the scheduled method by using the _cmd
variable as the selector:
-(void) tenMinutesElapsed:(ccTime)delta
{
 
Search Nedrilad ::




Custom Search