关键字: J2ME
双缓冲技术的应用很广泛,设计游戏的时候更是需要它, 在midp1.0中,api中并没有game这个包,看到网上很多人在讨论设计游戏的时候会出现图片断裂,屏幕闪烁等问题。 我经过这几天的学习整理下自己的学习心得,用来抛砖,希望对此有研究高手们相互讨论。让我也学习学习。 双缓冲的原理可以这样形象的理解:把电脑屏幕看作一块黑板。首先我们在内存环境中建立一个“虚拟“的黑板,然后在这块黑板上绘制复杂的图形,等图形全部绘制完毕的时候,再一次性的把内存中绘制好的图形“拷贝”到另一块黑板(屏幕)上。采取这种方法可以提高绘图速度,极大的改善绘图效果。 对于手机来说。具体的过程就是通过extends Canvas。然后获取bufferImage。再然后就getGraphics。最后就是在这个graphics中绘制图片等,再最后就是把这个绘制好的bufferImage绘制的屏幕上。 说归说。具体还是要看代码的。里面的代码参照了一些开源的代码。
java 代码
|