OGeek|极客世界-中国程序员成长平台

标题: ios - 需要大量的 SkSpriteNode 和 CPU 使用率已经达到 90% [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 09:38
标题: ios - 需要大量的 SkSpriteNode 和 CPU 使用率已经达到 90%

好的,我想在屏幕上放置大量的 skspritenode。在我正在开发的游戏中,甚至在示例旋转宇宙飞船游戏中,模拟器中的 CPU 使用率也很高。我不确定如何在实际设备上测试我的游戏(除非我提交给苹果),但我想知道屏幕上有 50-100 个节点是否会占用过多的 CPU 时间。

我已经测试了输出大量 skspritenodes 并且 cpu 使用率达到 90% 或更多。这是正常的吗?如果我基于这款游戏的 CPU 使用量极高(并且还在不断增长)而将这款游戏交给 Apple,我会被 mock 吗?

最后,有没有办法避免在游戏的不同阶段出现卡顿?拱形?预加载纹理? idk,类似的东西。



Best Answer-推荐答案


在模拟器中看到的性能结果完全不相关。如果您对真实结果感兴趣,那么您应该在不同的设备上进行测试。

来自文档:

Rendering performance of OpenGL ES in Simulator has no relation to the performance of OpenGL ES on an actual device. Simulator provides an optimized software rasterizer that takes advantage of the vector-processing capabilities of your Macintosh computer. As a result, your OpenGL ES code may run faster or slower in iOS simulator (depending on your computer and what you are drawing) than on an actual device. Always profile and optimize your drawing code on a real device, and never assume that Simulator reflects real-world performance.

另一方面,如果您使用纹理图集在单个绘制过程中绘制多个节点,SpriteKit 能够以 60fps 的速度渲染数百个 Sprite 。阅读更多 here .

关于将纹理预加载到内存中,您可以查看:

Preload Texture Atlas Data section

+ preloadTextureAtlases:withCompletionHandler:方法。

希望这会有所帮助。

关于ios - 需要大量的 SkSpriteNode 和 CPU 使用率已经达到 90%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31868298/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4