I have a game with which mostly consists of the following:
a)Timer every second for clock
b)Timer ever 0.02 for animating many objects (this is always running)
c)User interaction with objects
I'm new to using multiple threads so I'm wondering what is suggested usage here. I currently have everything on the main thread except timer 'b' mentioned above. I'm reading that UI stuff should be on the main thread but it seems like that could be both 'b' and 'c' above.
And just an FYI, I'm using this to start the timer 'b' above:
[NSThread detachNewThreadSelectorselector(startObjectsAnimation toTarget:animationHelper withObject:nil];
Then in animationHelper:
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selectorselector(doAnimation userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
[autoreleasepool release];
Curious what people's thoughts are about this.
Thanks in advance.
a)Timer every second for clock
b)Timer ever 0.02 for animating many objects (this is always running)
c)User interaction with objects
I'm new to using multiple threads so I'm wondering what is suggested usage here. I currently have everything on the main thread except timer 'b' mentioned above. I'm reading that UI stuff should be on the main thread but it seems like that could be both 'b' and 'c' above.
And just an FYI, I'm using this to start the timer 'b' above:
[NSThread detachNewThreadSelectorselector(startObjectsAnimation toTarget:animationHelper withObject:nil];
Then in animationHelper:
NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init];
animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.02 target:self selectorselector(doAnimation userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:animationTimer forMode:NSDefaultRunLoopMode];
[[NSRunLoop currentRunLoop] run];
[autoreleasepool release];
Curious what people's thoughts are about this.
Thanks in advance.