NSTimer hiccups/choppy/jerky

Member
Posts: 75
Joined: 2009.01
Post: #1
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
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Use CADisplayLink instead.
Quote this message in a reply
Member
Posts: 75
Joined: 2009.01
Post: #3
I have already been down that route and there is no difference.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  NSTimer fine, CADisplayLink having some issues monteboyd 5 9,880 Aug 31, 2010 07:05 PM
Last Post: Skorche
  Alternative to NSTimer demonpants 78 44,373 Jan 11, 2010 01:52 PM
Last Post: riruilo
  Using an NSTimer to progressively draw a view StevenD 4 4,531 May 14, 2009 07:57 AM
Last Post: StevenD
  OpenGL render loop - NSTimer vs rendering thread smallstepforman 27 23,751 Feb 2, 2009 10:22 AM
Last Post: ThemsAllTook