1
我試圖獲得高fps-約60
但只鎖定畫布已經使60 fps的最
這是我使用的代碼 -不能獲得高的FPS SurfaceView在我的遊戲線程的Android
public void run()
{
super.run();
int FPS = 60;
final long TPF = 1000/FPS;
long startTime;
long sleepTime;
while (m_run)
{
startTime = SystemClock.uptimeMillis();
m_canvas = m_surfaceHolder.lockCanvas();
if (m_canvas != null)
{
}
m_surfaceHolder.unlockCanvasAndPost(m_canvas);
sleepTime = TPF - (SystemClock.uptimeMillis() - startTime);
Log.d("sleep", String.valueOf((SystemClock.uptimeMillis() - startTime)));
}
但只有通過調用lockCanvas
和unlockCanvasAndPost
我得到60毫秒已經超過