Java - Paint 与 Image 的性能对比?
假设我必须在我正在制作的游戏中画一辆卡车。哪个性能更好?
- 用线条、填充和颜色变化绘制卡车
- 找到图像/制作卡车的图像并将其绘制在游戏上并移动图像。
感谢您的任何意见
Lets say I have to draw a truck on a game I am making. Which would be better performance wise?
- Drawing the truck with lines and filling and color changes
- Finding an image/making an image of the truck and drawing it on the game and moving the image around.
Thanks for any input
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我怀疑该图像会更容易编码。
您必须测试您的两个示例才能看到,但如果存在可测量的差异,我会感到惊讶。无论您选择哪种方法,屏幕上的所有像素都必须重新绘制。
I suspect that the image would be easier to code.
You'd have to test your two examples to see, but I'd be surprised if there was a measurable difference. All of the pixels on the screen have to be redrawn, no matter which method you choose.
图像会更快,因为它所要做的就是将像素复制到缓冲区并显示它们。
给卡车喷漆将为您的用途提供更大的灵活性。最终,差异非常小,特别是如果您绘制的只是一些形状。
几个月前我做了类似的东西,基本上是一个用java编写的轰炸机游戏。使用 Java 内置的 Image 类要容易得多。尽管加载了几百张图片并一次显示约 40 张左右(并重新绘制它们,包括地理信息系统),但游戏非常流畅且无延迟
The image would be faster, as all it has to do is copy the pixels over to the buffer, and display them.
Painting the truck would provide greater flexibility over what you can do with it. Ultimately, there will be VERY LITTLE difference, especially if all you're drawing is a few shapes.
I've made something similar a few months ago, basically a bomber man game in java. It was so much easier to just use Java's built in Image class. There game was very smooth and lag free, despite loading a few hundred pictures, and displaying ~40 or so at once (and repainting them, including gis)
我敢打赌性能或多或少是相同的,除非填充算法很慢。
I'll bet the performance will be more or less the same, unless the filling algorithm is slow.