画面滚动不流畅问题,诸位请进??万分感谢了先。。。
大家好,问题是,在真机上测试,滚屏不流畅。
现贴出源代码,
有高手指点一下,不胜感谢!!
装入图片资源
public TestCanvas()
{
try
{
layerManager = new LayerManager();
Image mapTitle = Image.createImage("/m.png");
terrain = new TiledLayer(2,80,mapTitle,64,64);
terrain.setCell(0,0,1);
for (int row=0; row<80; row++)
for (int col=0; col<2; col++)
terrain.setCell(col,row,1);
layerManager.append(terrain);
terrainScroll = - (terrain.getCellHeight() * terrain.getRows()) + getHeight();
}
catch(Exception _ex)
{
System.err.println(_ex.getMessage());
}
}
线程
public void run()
{
long l = 0l;
while(threadRun)
{
if(isShown()&&(System.currentTimeMillis() - l >= 40l))
{
l = System.currentTimeMillis();
terrainScroll += 1;
terrain.setPosition(0,terrainScroll);
repaint();
}
}
}
画
protected void paint(Graphics g)
{
layerManager.paint(g,0,0);
}
感觉在真机上测试,还是不流畅,看了一些资料,说,需要
设置屏幕Buffer,难道说只能这么做吗?