问题描述
依然在写连连看项目,由于考虑到需要各种机型的移植,所以只能使用midp1.0。基本上功能层都写完了,又出来事故了。。。。用缓冲画笔就会覆盖paint()画笔所画的内容!!!天哪,怎么解决这个问题!!
解决方案
解决方案二:
缓冲画笔是指什么?双缓冲么?学习一下
解决方案三:
ImageoffScreen;//缓冲GraphicsoffG;//画笔publicvoidpaint(Graphicsg){//绘制offG.....//把缓冲绘制到屏幕上g.drawImage(offScreen,0,0,...}
解决方案四:
voidsetClip(intx,inty,intwidth,intheight)
解决方案五:
就用GameCanvas嘛,那么方便
解决方案六:
为什么不直接双缓冲,类似2楼那样
解决方案七:
publicclassCanvasMainextendsCanvas{//离屏画布privateImageoffScreen;//离屏画笔privateGraphicsoffGra;publicCanvasMain(){this.setFullScreenMode(true);//创建与屏幕尺寸相同的离屏画布offScreen=Image.createImage(this.getWidth(),this.getHeight());//获取离屏画布画笔offGra=offScreen.getGraphics();this.drawUI();}privatevoiddrawUI(){offGra.setColor(0xccaaff);offGra.fillRect(0,0,this.getWidth(),this.getHeight());}protectedvoidpaint(Graphicsg){g.drawImage(offScreen,0,0,Graphics.LEFT|Graphics.TOP);}}