Alternative to NSTimer

Moderator
Posts: 3,570
Joined: 2003.06
Post: #76
warmi Wrote:The only posts worth deleting are the ones talking about bullshit and ignorance without contributing anything.

longjumper is a very long-time member here and has contributed way more than enough over the years to have earned the right to complain about whatever he pleases, and I happen to agree with him on this account. Wink

Also, guys, please refrain from swearing.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #77
mpatric Wrote:I've seen this happen a lot on the iPhone, especially when doing some rapid prototyping. Before optimising the drawing code, if it takes close to 16.6 ms (which is the period for 60fps), the timer regularly fires with 33.3 ms intervals (double 16ms, as one fire has been skipped).

This is why mainly people oversample (trigger the timer at a much higher rate than required for 60fps), perhaps without realising it.

Just to make this clear for the last time: it's not a fault with NSTimer. Whenever you do drawing on the iphone, it's essentially VBL synced to 60Hz. If your timer fires just a bit too late, or your code takes too long to execute, it'll block until the next refresh period.

And I really don't know how you expect NSTimer to fire on a given thread *before* your code is done.

All the discussions, here, and on the Apple forums, are not because this is such a controversial topic, but because a lot of new developers can't seem to read the manual, or at least don't understand how any two technologies interact.
Quote this message in a reply
Nibbie
Posts: 2
Joined: 2009.05
Post: #78
DoG Wrote:Just to make this clear for the last time: it's not a fault with NSTimer. Whenever you do drawing on the iphone, it's essentially VBL synced to 60Hz. If your timer fires just a bit too late, or your code takes too long to execute, it'll block until the next refresh period.

And I really don't know how you expect NSTimer to fire on a given thread *before* your code is done.

All the discussions, here, and on the Apple forums, are not because this is such a controversial topic, but because a lot of new developers can't seem to read the manual, or at least don't understand how any two technologies interact.

I just wanted to take a moment to update this thread and say that with OS 3.1 there is now the CADisplayLink (developer.apple.com) class which allows developers to synchronize their code with the refresh rate of the screen.

Cocos2d has adopted this, click here for an exerpt (gist)from CCDirector.m
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #79
reklis Wrote:I just wanted to take a moment to update this thread and say that with OS 3.1 there is now the CADisplayLink (developer.apple.com) class which allows developers to synchronize their code with the refresh rate of the screen.

Cocos2d has adopted this, click here for an exerpt (gist)from CCDirector.m

Doing that has a little problem: http://chitika.com/research/2009/iphone-...-worth-10/

BTW, What is the best way to manage game loop in 2.2 version? (without taking in account 3.0 or further) And does anyone know which method use successful games, let's say Rolando or Monkey Ball.

Thanks a lot for your ideas.
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,225 Aug 31, 2010 07:05 PM
Last Post: Skorche
  NSTimer hiccups/choppy/jerky jeonghyunhan 2 2,776 Sep 24, 2009 07:35 PM
Last Post: jeonghyunhan
  Using an NSTimer to progressively draw a view StevenD 4 4,220 May 14, 2009 07:57 AM
Last Post: StevenD
  OpenGL render loop - NSTimer vs rendering thread smallstepforman 27 22,671 Feb 2, 2009 10:22 AM
Last Post: ThemsAllTook
  Alternative Input/Control Ideas chrisco 8 4,270 Aug 6, 2008 03:21 PM
Last Post: bruss14