iPhone - 我应该在运行时合成两个图像,还是以内存为代价预渲染它们

发布于 2024-10-08 18:53:49 字数 381 浏览 0 评论 0原文

我正在构建一个 cocos2d iPhone 游戏。

将会有 6 个仅颜色不同的“敌方太空飞船精灵”。即所有的精灵都具有相同的形状,只有内部的某些部分具有不同的颜色。

我的两个选择是:

1)

  • 创建一个内部透明的模板形状。
  • 在运行时,在一小块颜色 X 的顶部绘制此形状。
  • 精灵的内部将为颜色 X。

2)

  • 预渲染 6 个不同的精灵
  • 在运行时,只需绘制给定颜色的精灵。

每种方法的优点和缺点是什么?有最佳实践吗?

如果我后来想要为精灵设置动画,或者动态改变它们的颜色,这会影响我选择的方法吗?

谢谢!

I am building a cocos2d iPhone game.

There will be 6 'enemy spaceship sprites' that vary only by colour. I.e. all the sprites will have the same shape only some parts of the interior will have different colours.

My two options are:

1)

  • Create a template shape with a transparent interior.
  • At runtime, draw this shape on top of a small block of colour X.
  • The interior of the sprite will be colour X.

2)

  • Pre-render 6 different sprites
  • At run time, simply draw the sprite of a given colour.

What is the advantages and disadvantages of each method? Is there a best practice?

If I later wanted to animate the sprites, or dynamically change their colours, would this effect my choice of method?

Thanks!

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

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

发布评论

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

评论(1

超可爱的懒熊 2024-10-15 18:53:49

我认为首先你需要弄清楚你想要做什么......动画或大量的颜色组合使得预渲染变得不可行。另一方面,如果屏幕上同时显示大量船只,则预渲染是有意义的,因为您可以使用此技术将绘制操作的数量减少一半。

I think first you need to figure out what it is that you're trying to do... Animation or a large number of color combinations make pre-rendering unfeasible. On the other hand, pre-rendering makes sense if you have a large number of ships on-screen at the same time, because you can use this technique to cut the number of drawing operations in half.

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