iDevGames Forums
NSTimer hiccups/choppy/jerky - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: NSTimer hiccups/choppy/jerky (/thread-729.html)



NSTimer hiccups/choppy/jerky - jeonghyunhan - Sep 24, 2009 06:11 PM

Well, I'm using an NSTimer for my gameLoop and for a while now I've been thinking it was a problem with my gameLoop for the random hiccups I get.
I've tried frame dependent AND independent game loops and still I cannot figure out why I get these hiccups.
It may be something ELSE causing the issue, like my tile engine which constantly builds AND renders or my scrolling implementation.

Just some pseudo code:
Code:
- (void)init {
lastTime = 0.0f;
}

- (void)startLoop {
timer = [NSTimer scheduledTimerWith...selector:@selector(gameLoop)...];
}

// Frame dependent loop
- (void)gameLoop {
CFTimeInterval time = CFAbsoluteGetTimeCurrent();
float delta = (time - lastTime);
[self updateLogic:delta];
[self drawView];
lastTime = time;
}

- (void)stopLoop {
[timer invalidate];
}

// How i scroll my map (camera) which I use gluLookAt
- (void)updateLogic:(float)delta {
if (mapX < X + 0.1) {
mapX += 0.1 * delta;
}
}

I build 2 layers of around 900 quads each and can run 60 FPS no problem so its not the drop in FPS from what I can tell.

Any help would be much appreciated Grin


NSTimer hiccups/choppy/jerky - arekkusu - Sep 24, 2009 06:41 PM

Use CADisplayLink instead.


NSTimer hiccups/choppy/jerky - jeonghyunhan - Sep 24, 2009 07:35 PM

I have already been down that route and there is no difference.