Is there a better way to move the bitmap inside a canvas without redrawingBitmap every time, for every single one?
public void onOffsetsChanged(float xOffset, float yOffset, float xStep, float yStep, int xPixels, int yPixels) {
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c != null) {
c.drawBitmap(this.ImageI, xPixels, 0, null);
c.drawBitmap(this.ImageII, xPixels, 0, paint);
}
} finally {
if (c != null) holder.unlockCanvasAndPost(c);
}
}
You are asking: is there a better way? The answer is: no. You need to redraw your whole scene, background and all, every frame. Also, generally speaking, you don't want to draw in onOffsetsChanged; just update variables that you're using in your runnable. Take a look at how the Cube example in the SDK works. Joey's example is correct, too. Hope this helps