3

I find that sometimes my application (Cocos2d game) beheaves in a "buggy" way after a significant time change. For example:

  • case 1: when the application enters the background and, after several minutes, I restart it, I can see the loading image and then the application/game resumes.
  • case 2: when the application enters the background and after a significant time change the application sometimes restarts, sometimes not. It is still unclear to me why.

Looking at the AppDelegate methods I found:

// next delta time will be zero
-(void) applicationSignificantTimeChange:(UIApplication *)application
{
    [[CCDirector sharedDirector] setNextDeltaTimeZero:YES];
}

I was wondering, as this affects the director and the director affects the animations, is there a link for between this call and case 1 and case 2?

James Webster
  • 31,873
  • 11
  • 70
  • 114
mm24
  • 9,280
  • 12
  • 75
  • 170

1 Answers1

5

This is nothing to do with cocos2D or applicationSignificantTimeChange:

Notably for applicationSignificantTimeChange:

This method is called when the day changes, or if the device's time has been changed in the background for whatever reason (such as changes to time zone).
[Source]

I am assuming the "significant time change" you mention is just when you leave the game for a while (i.e. longer than a few minutes). In this case, it's most likely that you are observing the fact that the OS multitasking handler kills off background processes when the device is running low on memory, causing your app to restart as you describe in case 2.

In the cases where the app hasn't restarted, it's just the case that the OS hasn't killed your process.

Community
  • 1
  • 1
James Webster
  • 31,873
  • 11
  • 70
  • 114
  • thanks for your answer. I thought that the OS could have killed my app but what is confusing me is that this happens also when my App was the only one running (so there are no other apps that may ask for more memory). Can this still be the case? In other words, can the OS still do "routine" cleaning and kill off my only active app as it "sucks" 50 MB of real memory usage? – mm24 Dec 02 '13 at 11:51
  • `Can the OS still do "routine" cleaning..` I'd say probably yes, but I don't have any evidence to back this up. – James Webster Dec 02 '13 at 11:59
  • Ok thanks a lot for your answer and edit, I will accept it unless someone comes up with a more detailed explanation. – mm24 Dec 02 '13 at 12:00