I want to move a bitmap image along consecutive coordinates in SurfaceView
. I have a bitmap myBall
drawn in the coordinate (x1, y1)
on a SurfaceView
as follows (partial code)(
public class MainSurfaceView extends SurfaceView implements Runnable {...
...
@Override
public void run() {
while (isRunning) {
if (!myHolder.getSurface().isValid())
continue;
Canvas canvas;// Define canvas to paint on it
canvas = myHolder.lockCanvas();
//Draw full screen rectangle to hold the floor map.
Rect dest = new Rect(0, 0, getWidth(), getHeight());
Paint paint = new Paint();
paint.setFilterBitmap(true);
canvas.drawBitmap(bgImage, null, dest, paint);
//This is the ball I want to move
canvas.drawBitmap(myBall, x1, y1, null);
myHolder.unlockCanvasAndPost(canvas);
}
}
Now I want to move it to (x2, y2)
then (x3, y3)
and ... as many as needed and one after the other. I have tried to use TranslateAnimation
but couldn't do it.