我正在使用 cocos2d 为图形制作 iPhone 应用程序,我在我的项目中添加了 4 张图片,我想将它们叠加起来用作背景。然后我通过像这样制作 CCSprite 将它们添加到应用程序中......
background.sun = [CCSprite spriteWithFile:@"SunLayer.png"];
[self addChild:background.sun z:-1];
background.mountain = [CCSprite spriteWithFile:@"MountainLayer.png"];
[self addChild:background.mountain z:-1];
background.tree = [CCSprite spriteWithFile:@"TreeLayer.png"];
[self addChild:background.tree z:-1];
background.hill = [CCSprite spriteWithFile:@"HillLayer.png"];
[self addChild:background.hill z:-1];
background.hill.position = ccp(s.width/2, s.height/2);
background.sun.position = ccp(s.width/2, s.height/2);
background.mountain.position = ccp(s.width/2, s.height/2);
background.tree.position = ccp(s.width/2, s.height/2);
这使我的帧速率降至 30!从 60!!我怎样才能保持良好的帧率但添加这些 Sprite !谢谢
最佳答案
既然你们都在同一个 z 添加它们,为什么不在 photoshop 或等效软件中添加一个纹理呢?您是否需要单独淡化或以其他方式处理这些纹理中的任何一个?
此外,我经常发现模拟器上的 FPS 与我将在设备上获得的 FPS 不相似。当您怀疑性能问题时,我会建议您快速在设备上进行快速测试以评估问题是否真实。
关于iphone - CCSprite 降低性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9557519/