![]() |
|
How do you control time on the iPhone? - 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: How do you control time on the iPhone? (/thread-1984.html) |
How do you control time on the iPhone? - riruilo - Dec 28, 2008 01:05 PM 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. How do you control time on the iPhone? - AnotherJake - Dec 28, 2008 03:04 PM Skorche and I accidentally posted some mach timing code in this other thread recently: http://www.idevgames.com/forum/showthread.php?t=16298 How do you control time on the iPhone? - AndyKorth - Dec 28, 2008 03:47 PM The iPhone can control time? Finally I can go back and stop myself from dating that one girl. Sorry... couldn't help it
How do you control time on the iPhone? - riruilo - Dec 28, 2008 03:58 PM 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. How do you control time on the iPhone? - AnotherJake - Dec 28, 2008 04:23 PM 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. How do you control time on the iPhone? - Skorche - Dec 28, 2008 08:14 PM 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. How do you control time on the iPhone? - riruilo - Dec 29, 2008 01:54 AM 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. How do you control time on the iPhone? - AnotherJake - Dec 29, 2008 08:13 AM 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 |