游戏场景中帧率(cocos2d box2d)下降

发布于 2024-11-29 20:22:03 字数 2087 浏览 1 评论 0原文

具有多层蚂蚁大量精灵的游戏场景,几乎可以很好地工作(除了一些问题)。但如果我们将游戏暂停 5-10 分钟(大约),它的帧速率就会下降,并且当再次开始玩游戏时,游戏会开始出现不稳定的效果。

最初使用的默认帧速率在这里是默认的ccMacros.h

#define CC_DIRECTOR_INIT()                                                                      \
do{                                                                                         \
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];                   \
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )                             \
    [CCDirector setDirectorType:kCCDirectorTypeNSTimer];                                    \
CCDirector *__director = [CCDirector sharedDirector];                                       \
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];               \
viewController.wantsFullScreenLayout = YES;                                                 \
[__director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];                                \
[__director setDisplayFPS:NO];                                                              \
[__director setAnimationInterval:1.0/60];                                                   \
EAGLView *__glView = [EAGLView viewWithFrame:[window bounds]                                \
                                pixelFormat:kEAGLColorFormatRGB565                          \
                                depthFormat:0 /* GL_DEPTH_COMPONENT24_OES */                \
                         preserveBackbuffer:NO];                                            \
[__director setOpenGLView:__glView];                                                        \
[viewController setView:__glView];                                                          \
[window addSubview: viewController.view];                                                   \
[window makeKeyAndVisible];                                                                 \
} while(0)

编辑:情况是,当我玩它甚至超过五或十分钟但帧时,应用程序保持正常工作当我们在同一时间段内不碰应用程序时,费率会下降 那么有什么方法可以刷新时不时的申请?

A game scene with multiple layer ant numerous sprite, working almost nicely(except of some problems). But if we put the game on hold, for a long time of 5-10 minutes (approx), it's frame rate goes down and game start giving jerky effect when been start playing again.

the default frame rate is been used initially here is default ccMacros.h:

#define CC_DIRECTOR_INIT()                                                                      \
do{                                                                                         \
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];                   \
if( ! [CCDirector setDirectorType:kCCDirectorTypeDisplayLink] )                             \
    [CCDirector setDirectorType:kCCDirectorTypeNSTimer];                                    \
CCDirector *__director = [CCDirector sharedDirector];                                       \
viewController = [[RootViewController alloc] initWithNibName:nil bundle:nil];               \
viewController.wantsFullScreenLayout = YES;                                                 \
[__director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];                                \
[__director setDisplayFPS:NO];                                                              \
[__director setAnimationInterval:1.0/60];                                                   \
EAGLView *__glView = [EAGLView viewWithFrame:[window bounds]                                \
                                pixelFormat:kEAGLColorFormatRGB565                          \
                                depthFormat:0 /* GL_DEPTH_COMPONENT24_OES */                \
                         preserveBackbuffer:NO];                                            \
[__director setOpenGLView:__glView];                                                        \
[viewController setView:__glView];                                                          \
[window addSubview: viewController.view];                                                   \
[window makeKeyAndVisible];                                                                 \
} while(0)

Edit: The scenario is, APPLICATION KEEP WORKING PROPERLY WHILE I'M PLAYING IT EVEN FOR THAN FIVE OR TEN MINUTES BUT FRAME RATE GET DOWN WHEN WE LEFT THE APPLICATION UN TOUCHED FOR THE SAME TIME PERIOD SO is there any way to refresh the application time to time?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眉目亦如画i 2024-12-06 20:22:03

造成低帧的原因有很多,例如内存使用效率低下、使用 NSTimers、在计划选择器内绘制任何内容等等。确保释放正在分配的内存。
只需查看以下链接,它们可能会帮助您提高游戏中的帧速率:

Low frame is caused due to many reasons like inefficient memory usage, using NSTimers, drawing anything inside a scheduled selector, and many more. Make sure you are releasing the memory you are allocating.
Just have a look at below links which might help you increase the frame rate in your game:

ゝ偶尔ゞ 2024-12-06 20:22:03

当我尝试每件事时,@Nitish 建议,但是,在一场运动中,每件事都会失败。因为帧速率下降仍然是一个问题。通过谷歌搜索太多并试图找出原因和解决方案,我只能成功地只有理由,因为我无力承担解决方案。要检查我得到了什么,检查此链接

As I tried every thing, @Nitish suggested but, at a movement every thing got to be failed. As that degradading frame rate is still an issue. By googling too much and trying to find out the reason and solution, I have only been succeed to have reason only, as I was unable to afford solution. To check what I got, CHECK THIS LINK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文