Android游戏编程之从零开始、p173
自定义动画
动态位图
private void T1set() {
btax = bitmapB.getWidth() - this.getWidth();
btay = -bitmapB.getHeight() + this.getHeight();
}
private void T1(Canvas canvas) {
btax -= 10;
canvas.drawColor(Color.RED);
canvas.drawBitmap(bitmapB, -btax, btay, paint);
}
private void mDraw() {
try {
canvas = surfaceHolder.lockCanvas();
if (canvas != null) {
T1(canvas);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (canvas != null) {
surfaceHolder.unlockCanvasAndPost(canvas);
}
}
}
@Override
public void run() {
while (thflag) {
long s = System.currentTimeMillis();
mDraw();
long e = System.currentTimeMillis();
if (e - s < 50) {
try {
Thread.sleep(50 - (e - s));
} catch (InterruptedException e1) {
e1.printStackTrace();
}
}
}
}
0 件のコメント:
コメントを投稿