Understanding applicationSignificantTimeChange:

拜拜、爱过 提交于 2019-12-12 14:08:08

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/20327348/understanding-applicationsignificanttimechange

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!