Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / getmilliseconds function and ios home button question

Author
Message
Lavaflyer
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location: Wisconsin, U.S.
Posted: 2nd Jul 2012 18:04
I've been working on a simple arcade game for ios but I've run into a problem. Pressing the home button effectively pauses my game except for one thing, the getmilliseconds() function. In my game your score, the speed of enemies, etc. are all controlled by how many milliseconds have gone by and when a user presses the home button the milliseconds continue to tick by. So say they start up the game 10 minutes later, they'll have a unrealistic score but be able to continue where they left off.

So, my question is are there any functions I'm missing that could easily handle the 'home button issue' in T1 or is there something I'm missing? Thanks
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 2nd Jul 2012 19:03
getmilliseconds() returns the time since the app was started, which will continue to increase even if the game is paused.

A better approach would be to use your own counter. That way, when your app is paused, the counter does not get updated.

There are a number of ways to do this, one way would be to add getFrameTime() - which indicates the amount of time the last loop took.
Lavaflyer
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location: Wisconsin, U.S.
Posted: 4th Jul 2012 19:23
Oh, ok thanks this helps alot the getframetime() function is just what i needed for my app.

Login to post a reply

Server time is: 2024-05-04 14:11:32
Your offset time is: 2024-05-04 14:11:32