Hi,
I am experimenting with tweaking the CFRunLoopRunInMode calls in the FastDirector preMainLoop function (game must be responsive to many touches). It is not clear to me why CFRunLoopRunInMode is called twice, i.e. before and after executing the main loop. Can somebody shed some light on this? I noticed that our game runs smoother on a 3GS when commenting out the second CFRunLoopRunInMode call.
The code passage is pasted below.
-(void) preMainLoop
{
while (isRunning) {
NSAutoreleasePool *loopPool = [NSAutoreleasePool new];
#if CC_DIRECTOR_DISPATCH_FAST_EVENTS
while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.004f, FALSE) == kCFRunLoopRunHandledSource);
#else
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
#endif
if (isPaused_) {
usleep(250000); // Sleep for a quarter of a second (250,000 microseconds) so that the framerate is 4 fps.
}
[self mainLoop];
#if CC_DIRECTOR_DISPATCH_FAST_EVENTS
while( CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.004f, FALSE) == kCFRunLoopRunHandledSource);
#else
while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource);
#endif
[loopPool release];
}
}