我正在开发一款安卓游戏。我把FPS设置为30.一切正常。有"加速"在路上的物体。当精灵遇到精灵时,会增加精灵速度。
我增加了FPS,但没有效果。我需要首先显示一个特定的精灵动画。
public void run()
{
while(running)
{
Canvas canvas=null;
try
{
canvas=view.getHolder().lockCanvas();
synchronized (view.getHolder())
{
beginTime=System.currentTimeMillis();
view.update();
view.onDraw(canvas);
timediff=System.currentTimeMillis()-beginTime;
sleepTime=(int) (FRAME_PERIOD-timediff);
Log.i(TAG, "sleepTime"+sleepTime);
if(sleepTime>0)
{
try
{
Thread.sleep(sleepTime);
}
catch(InterruptedException e)
{
Log.i(TAG, "Thread sleep"+e.getMessage());
}
}
}
}
catch(Exception e)
{
Log.i(TAG, ""+e.getMessage());
}
finally
{
if(canvas!=null)
{
view.getHolder().unlockCanvasAndPost(canvas);
}
}
}
}