本文介绍了画圆VS drawBitmap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算在我的游戏实施了一系列新的人物:普通圆。绘制精灵(在这种情况下圆圈)的数量始于2-3,并且可以无休止地上去(可能)。最大的可能是60左右,但。总共有将必须是5种类型的社交圈的,每一个不同的颜色和可能大小过。现在看到的,因为我不会实现它,直到周一我想我会问它的计算器。

I'm planning on implementing a new set of figures in my game: plain circles. The number of drawn sprites (in this case circles) starts with 2-3, and can go up endlessly (potentially). The maximum will probably be around 60 though. In total there will have to be 5 types of circles, each with a different color and probably size too. Now seeing as I won't implement it until monday I thought I'd ask it at stackoverflow.

是否有人已经知道哪种方法比较快?

Does anybody already know which method is faster?

推荐答案

位图几乎总是比任何一种平局的速度更快。与右preparation绘制的位图被简单地倾倒存储器到屏幕上。绘制圆涉及显著数计算,包括抗锯齿。我presented纸涵盖这在2009年JavaOne大会上,但纸老似乎已经从网站上移除。

Bitmaps are almost always faster than any kind of draw. With the right preparation drawing a bitmap is simply dumping memory to the screen. Drawing a circle involves a significant number of calculations, including anti-aliasing. I presented a paper which covered this at JavaOne 2009, but papers that old seem to have been removed from the site.

它取决于你的位图将有多大必须的,但对于低于10像素的大小的位图精灵比就像画十字架和线条,甚至简单的图形操作的速度要快得多。您还需要确保你的精灵不会要求任何形式的变换,当它一抽,它与屏幕内存兼容的形式。

It does depend on how big your bitmap would need to be, but for sizes under 10 pixels bitmap sprites are much faster than even simple graphic operations like drawing crosses and lines. You also need to make sure that your sprite won't require any kind of transform when it is drawn, and that it is a form compatible with the screen memory.

如果每个圈子是不同的颜色或厚度,还是差了不同的大小,则是另一回事。创建每个位将超过节省的成本。

If every circle is to be a different color or thickness, or worse a different size, then that's another matter. The cost of creating each bitmap would outweigh the savings.

您应该还记得优化的第一条规则:不要做,除非你有

You should also remember the first rule of optimization: don't do it unless you have to.

这篇关于画圆VS drawBitmap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 20:00