iPhone - 我应该在运行时合成两个图像,还是以内存为代价预渲染它们
我正在构建一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为首先你需要弄清楚你想要做什么......动画或大量的颜色组合使得预渲染变得不可行。另一方面,如果屏幕上同时显示大量船只,则预渲染是有意义的,因为您可以使用此技术将绘制操作的数量减少一半。
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.