Android游戏开发之SurfaceView动画
2010-09-10 01:09:00 来源:WEB开发网核心提示:int i = 0;while(run) {Log.v(tag, "GameThread");Canvas c = null;try {synchronized (surfaceHolder) {//我们在屏幕上显示一个计数器,每隔1秒钟刷新一次c = surfaceHolder.lockCanva
int i = 0;
while(run) {
Log.v(tag, "GameThread");
Canvas c = null;
try {
synchronized (surfaceHolder) {
//我们在屏幕上显示一个计数器,每隔1秒钟刷新一次
c = surfaceHolder.lockCanvas();
c.drawARGB(255, 255, 255, 255);
c.drawText("" + i++, 100, 100, new Paint());
Thread.sleep(1000);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (c != null) {
surfaceHolder.unlockCanvasAndPost(c);
}
}
}
}
}
}
更多精彩
赞助商链接