Cocos2d在应用程序启动时提供随机fps下降? [英] Cocos2d on application start gives random fps drop?

查看:347
本文介绍了Cocos2d在应用程序启动时提供随机fps下降?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款使用cocos2d的iphone游戏,并将其设置为显示FPS。现在大多数时候,应用程序将以60 fps开始和运行。然而,显然随机有时应用程序将以40 fps的速度启动并运行。



这不会经常发生,似乎只有当你退出应用程序并尽快重新启动它,尽管这不会触发大多数时间的效果。但在几个快速退出重新启动序列后,游戏最终开始,只有40 fps,而不是正常60.如果我退出应用程序在这一点,等待约3秒,它将再次开始与正常的60 fps。 p>

我假设这与应用程序不能在重新启动之前释放所有内存有关系,这个问题似乎与iPhone操作系统有关。



重要的是要注意,如果我退出应用程序等待5秒钟并且重新启动,这从不会发生。以前有人有这样的问题吗?任何想法为什么会发生这种情况。

解决方案

如果有人想知道这是因为以前模拟时OPEN GL 2.0在iPhone 3GS / iPod Touch 3G,这已经被固定为OS 3.1。所有你需要做的是以下:

  //尝试使用CADisplayLink director 
//如果失败(SDK< 3.1)使用Threaded director
if(![Director setDirectorType:CCDirectorTypeDisplayLink])
[Director setDirectorType:CCDirectorTypeThreadMainLoop];


I am developing an iphone game using cocos2d and have it set to to show the FPS. Now most of the time the application will start and run at 60 fps, However apparently randomly sometimes the application will start and top at only 40 fps.

This does not happen often and seems to happen only when you quit the application and restart it as soon as possible, allthough this does not trigger the effect most of the time. But after a few quick quit-restart sequences the game eventually starts and has only 40 fps instead of the normal 60. If I quit the application at this point and wait for about 3 seconds it will again start with the normal 60 fps.

I am assuming this has something to do with the application not being able to free all of its memory before starting again?, this problem seems to be related to the iPhone OS.

It is important to note that this never happens if I quit the application wait 5 seconds and restart. Has anyone had this sort of problem before?. Any ideas of why this might be happening?.

解决方案

If anyone is wondering this is because there used to be a bug when emulating the OPEN GL 2.0 in the iPhone 3GS/iPod Touch 3G, this has been fixed for OS 3.1. And all you have to do is the following:

// Try to use CADisplayLink director
// if it fails (SDK < 3.1) use Threaded director
if( ! [Director setDirectorType:CCDirectorTypeDisplayLink] )
    [Director setDirectorType:CCDirectorTypeThreadMainLoop];

这篇关于Cocos2d在应用程序启动时提供随机fps下降?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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