Java - Paint 与 Image 的性能对比?

发布于 2024-10-25 11:21:03 字数 126 浏览 1 评论 0原文

假设我必须在我正在制作的游戏中画一辆卡车。哪个性能更好?

  • 用线条、填充和颜色变化绘制卡车
  • 找到图像/制作卡车的图像并将其绘制在游戏上并移动图像。

感谢您的任何意见

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 技术交流群。

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

发布评论

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

评论(3

在梵高的星空下 2024-11-01 11:21:03

我怀疑该图像会更容易编码。

您必须测试您的两个示例才能看到,但如果存在可测量的差异,我会感到惊讶。无论您选择哪种方法,屏幕上的所有像素都必须重新绘制。

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.

青柠芒果 2024-11-01 11:21:03

图像会更快,因为它所要做的就是将像素复制到缓冲区并显示它们。

给卡车喷漆将为您的用途提供更大的灵活性。最终,差异非常小,特别是如果您绘制的只是一些形状。

几个月前我做了类似的东西,基本上是一个用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)

丢了幸福的猪 2024-11-01 11:21:03

我敢打赌性能或多或少是相同的,除非填充算法很慢。

I'll bet the performance will be more or less the same, unless the filling algorithm is slow.

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