In order to cleanly port my game to the iPhone, I\'m trying to make a game loop that doesn\'t use NSTimer.
I noticed in some sample code that, if using NSTimer, you\'d s
If you don't wish to use NSTimer
you can try running the NSRunLoop manually:
static BOOL shouldContinueGameLoop;
static void RunGameLoop() {
NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop];
NSDate *destDate = [[NSDate alloc] init];
do {
// Create an autorelease pool
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
// Run the runloop to process OS events
[currentRunLoop runUntilDate:destDate];
// Your logic/draw code goes here
// Drain the pool
[pool drain];
// Calculate the new date
NSDate *newDate = [[NSDate alloc] initWithTimeInterval:1.0f/45 sinceDate:destDate];
[destDate release];
destDate = newDate;
} while(shouldContinueGameLoop);
[destDate release];
}