日期:2014-05-20  浏览次数:20800 次

真机运行游戏为啥部分屏幕不刷新?
在模拟器上运行的很好的!但是在真机上(nokia 6120c s60 3rd)运行的时候屏幕不是全部刷新,底部有一部分不刷新。
第一次运行程序都挺好的,但是游戏又开始新一局时就出现这个问题了。。。
游戏画面类是mycanvas,开始新一局是让它init一下。屏幕大小已经固定死了是320×240。

代码我给大家看一下
public void run()
{
Graphics g = getGraphics();
while (playing)
{
try
{
 
long startTime = System.currentTimeMillis();
if (isShown())
{
// update the world if the player has moved
checkKeys();  
//long drawingTime = System.currentTimeMillis();
// draw the 3d part  
draw3D(g);
 
touchtool(locationx,locationz);
 
if(touched)
{
System.out.println("碰到了碰到了碰到了碰到了碰到了");
gettool();
}
touched = false;

// draw the 2d part
draw2D(g);
usetool=false;
setview();
if(ma.isApproachEnd(locationx, locationz, 5f)&&jilu<164)
{
stop();
midlet.gameWin();
if(operationScreen.soundon)
{
Sound.getInstance().stopBack();
}  
}
if(jilu>164&&!ma.isApproachEnd(locationx, locationz, 9f))
{
stop();
midlet.gameLose();
if(operationScreen.soundon)
{
Sound.getInstance().stopBack();
}
}
flushGraphics();
}
// wait for a little and give the other threads
// the chance to run
long timeTaken = System.currentTimeMillis() - startTime;
if (timeTaken < MILLIS_PER_TICK)
{
synchronized (this)
{
wait(MILLIS_PER_TICK - timeTaken);
}
}
else
{
Thread.currentThread().yield();
}
}
catch (Exception e)
{
// ignore. Not much to but we want to keep the loop running
}  
}
 
}

------解决方案--------------------
是不是内存问题导致的?重新开始一局游戏,一些图片资源没有加载上。
------解决方案--------------------
没刷新的部分是白色的吗?

看一下你的setFullScreenMode(true)是否是放在构造函数的开头部位
------解决方案--------------------
你先试试在构造中加入这个:
setFullScreenMode(true);

如果不行的话,在上句话后加这句
g.setClip(0, 0, 240, 320);
------解决方案--------------------
再指出你程序上的一点小问题
Graphics g = getGraphics(); 
应该放到构造中去,而不是run()里