如何提高“流畅度”? 2D 横向卷轴 iPhone 游戏?

发布于 2024-09-13 07:57:27 字数 510 浏览 3 评论 0原文

我正在开发一款相对简单的 2D 横向卷轴 iPhone 游戏。控件是基于倾斜的。我使用 OpenGL ES 1.1 进行图形处理。游戏状态以 30 Hz 的速率更新...绘图以 30 fps 的速率更新(通过 NSTimer)。绘图的流畅度还可以……但不如iFighter这样的游戏流畅。怎样才能提高游戏的流畅度?

以下是我简要考虑过的潜在问题:

  • 我一次改变最多 15 个“小”(20x20 像素)纹理的不透明度...显然,以这种方式改变不透明度会降低绘图性能< /p>

  • 我仅以 30 fps 进行渲染(通过 NSTimer)...也许像 iFighter 这样的 2D 游戏会以更高的帧速率渲染?

  • 也许游戏状态可以以更快的速度更新?请注意,加速度值以 100 Hz 更新...因此我可能会以 100 Hz 更新部分游戏状态

  • 我的所有纹理均为 PNG24...也许 PNG8 会有所帮助(由于尺寸较小等)

I'm working on a relatively simple 2D side-scrolling iPhone game. The controls are tilt-based. I use OpenGL ES 1.1 for the graphics. The game state is updated at a rate of 30 Hz... And the drawing is updated at a rate of 30 fps (via NSTimer). The smoothness of the drawing is ok... But not quite as smooth as a game like iFighter. What can I do to improve the smoothness of the game?

Here are the potential issues I've briefly considered:

  • I'm varying the opacity of up to 15 "small" (20x20 pixels) textures at a time... Apparently varying the opacity in this manner can degrade drawing performance

  • I'm rendering at only 30 fps (via NSTimer)... Perhaps 2D games like iFighter are rendered at a higher frame rate?

  • Perhaps the game state could be updated at a faster rate? Note the acceleration vales are updated at 100 Hz... So I could potentially update part of the game state at 100 hz

  • All of my textures are PNG24... Perhaps PNG8 would help (due to smaller size etc)

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

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

发布评论

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

评论(2

池予 2024-09-20 07:57:28

用它来调试图形问题确实很困难。尝试使用 openGL ES 工具来查找瓶颈所在。非常方便。另外,请观看有关 openGL 的 WWDC 视频。他们真的很好。

我注意到的一件事是你说“我只以 30 fps 渲染”。这是否意味着您正在手动设置计时器或其他什么?这不是一个好方法,您应该使用 CADisplayLink 在屏幕想要更新时收到通知。它可以提高你的流畅度。

It's really hard to debug graphics problems with this. Try using the openGL ES instruments to find where are the bottlenecks. It's quite handy. Also, look at the WWDC videos on openGL. They're really good.

One thing I noticed is that you said "I'm rendering at only 30 fps". Does it mean you're manually setting up a timer or something? This is not a good way, instead you should use CADisplayLink to get notified when the screen wants to update. It could improve your smoothness.

|煩躁 2024-09-20 07:57:28

为了完成 Mo 对 30fps 的回答...

您请求以 30fps 进行更新的事实并不意味着您会得到它。我不是 iPhone 程序员,但我可以告诉您,如果您的帧渲染需要 100 毫秒,那么您保证更新速度永远不会超过 10fps。如果您实际上以 10 fps 进行渲染,那么平滑度就会消失。

因此,测量渲染所需的时间以了解您获得的实际帧速率。至于如何专门针对 iPhone 优化渲染,我将把它留给比我在该主题上更专业的人。

To complete Mo's answer on the 30fps...

The fact that you request the update at 30fps does not mean you're going to get it. I'm not an iphone programmer, but I can tell you that if your frame rendering takes 100ms, you're guaranteed to never update faster than 10fps. And if you're actually rendering at 10fps, then smoothness is gone.

So, measure the time you take to render to get an idea of what actual frame rate you get. As to how to optimize the rendering specifically for iphone, I'll leave that to people more expert than me on the subject.

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