How do you control time on the iPhone?

Member
Posts: 249
Joined: 2008.10
Post: #1
Hi friends!

How do you control time on the iPhone?
Is there any like SDL_GetTicks() to get miliseconds since app was launched?

I need something like that to control my animations and movements.
Any suggestion?

BTW: Better if I can use it through CPP.

Thanks a lot, I appreciate a lot your help and time.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #2
Skorche and I accidentally posted some mach timing code in this other thread recently: http://www.idevgames.com/forum/showthread.php?t=16298
Quote this message in a reply
Moderator
Posts: 452
Joined: 2008.04
Post: #3
The iPhone can control time? Finally I can go back and stop myself from dating that one girl.

Sorry... couldn't help it Rasp

Howling Moon Software - CrayonBall for Mac and iPhone, Contract Game Dev Work
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #4
AnotherJake Wrote:Skorche and I accidentally posted some mach timing code in this other thread recently: http://www.idevgames.com/forum/showthread.php?t=16298

I already saw that post. Perhaps nanoseconds is too much accurate, I only need miliseconds.

Did you use that method on a game? Do you think it is suitable for games? I mean, does that method add overhead? (I have no idea about this).

Thanks a lot for your help.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #5
Accuracy being in nanoseconds vs. milliseconds has little to do with performance or overhead. We modify it so it returns time in seconds as a double precision float. Yes it works great for games, which is why we use it.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
Yeah, the extra precision certainly isn't going to break anything, and it's not going to be slower really.

As Jake said, it returns the time as a double in seconds, so it's easy to work with.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 249
Joined: 2008.10
Post: #7
Thanks a lot for replies.

As I just need miliseconds, What do you think (AnotherJake) if I modify your code with this?

miliseconds = (double)nanos*1.0e-6;
return miliseconds;

Thanks.
Quote this message in a reply
Moderator
Posts: 3,572
Joined: 2003.06
Post: #8
Yes, seems like that should do the trick. Need to reduce nanos by three orders of magnitude less than you would for seconds to get milliseconds. Accordingly, microseconds would be nanos * 1.0e-3
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  iPhone app remote control tool DoG 7 3,411 Nov 24, 2009 05:27 AM
Last Post: DoG
  Is there any iphone app to control presentations? (as powerpoint) riruilo 3 2,793 Oct 13, 2009 03:37 AM
Last Post: riruilo