试图在单个画布上每毫秒绘制一些东西。我的意思是只向画布添加细节,而不是每帧都重绘它。所以这段代码给了我三种不同的画布。第三,然后再第一。为什么?
public void run() {
this.run = true;
Canvas canvas = null;
while (run) {
try {
canvas = this.surfaceHolder.lockCanvas();
synchronized (this.surfaceHolder) {
Thread.sleep(delay);
draw(new Img(canvas, size));
}
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
if (canvas != null) {
this.surfaceHolder.unlockCanvasAndPost(canvas);
}
}
synchronized (this) {
if (wait) {
try {
wait();
} catch (Exception e) {}
}
}
}
}
如果它是 android 三重缓冲 - 如何关闭它,或者用它做些什么?安卓 4.2.1