1

我在 iphone 上使用 cocos2d,在我的游戏中我使用精灵作为静态背景图像。

我注意到,在删除添加精灵的代码时,帧速率从 ~30fps 变为超过 40fps。有没有其他方法可以显示更便宜的静态背景?我根本没有移动背景精灵。

立即编码:

background = [Sprite spriteWithFile:@"t1_5.jpg"];
[self addChild:background z:0];
background.position = ccp(240, 160);
4

2 回答 2

1

Not an easy question, like every question that concerns Cocos2D performance. Large images always take CPU to render. You can only reduce it to make performance acceptable (stable 30 fps is a good result)

There are pretty good advices given by original developer.

From my own experience I prefer to use color filled background with small sprites over using solid image background. Repeating elements should also use single texture with different sprites.

Reducing texture quality to 16 bit can also help.

[Texture2D setDefaultAlphaPixelFormat:kTexture2DPixelFormat_RGBA4444]; // add this line at the very beginning

I can be more specific on topic if you provide more info like attaching the background itself.

于 2009-07-26T19:11:28.197 回答
0

我建议将所有 Sprite 转换为 AtlasSprite。这样你就有了一个 AtlasSpriteManager 加载背景文件一次,当你需要精灵本身时,它只是剪切图像。AtlasSprite 通常比传统的 Sprite 快。

于 2009-09-23T12:10:22.190 回答