了解applicationSignificantTimeChange: [英] Understanding applicationSignificantTimeChange:

查看:645
本文介绍了了解applicationSignificantTimeChange:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有时候我的应用程序(Cocos2d游戏)在一个显着的时间变化后,以错误的方式痛苦。例如:

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


  • 情况1:当应用程序进入后台,几分钟后, ,我可以看到加载图片,然后应用程序/游戏恢复。

  • 情况2:在显着的时间改变之后,应用程序有时重新启动,有时不会重新启动。仍然不清楚为什么。

  • 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.

查看 AppDelegate 方法:

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

我想知道因为这影响了导演和导演的影响动画,此调用与情况1和情况2之间是否有链接?

推荐答案

关于cocos2D或 applicationSignificantTimeChange:

This is nothing to do with cocos2D or applicationSignificantTimeChange:

值得注意的是 applicationSignificantTimeChange:


此方法在日期变更时调用,或者设备的时间在后台因任何原因更改为时区)。

[来源]

我假设你提到的重大时间变化只是当你离开游戏一段时间长于几分钟)。在这种情况下,最有可能的是,您正在观察以下事实:操作系统多任务处理程序在设备内存不足时停止后台进程,导致您的应用程序按照第2种情况重新启动。

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.

这篇关于了解applicationSignificantTimeChange:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆