I've set global variables x,y in the Activity class.
I start a thread "t0" that continually update globals x and y.
I have onDraw pseudocode as follows (all on the UI thread):-
View.onDraw(){
if (x,y changed value) {
x0=x;
y0=y;
loop (x0-- until x0==0){
canvas.drawBitmap(bmp, x0, y0, bitmapPaint);
invalidate();
}
}
}
I was hoping that I'd see an animation of the bitmap moving across the screen on the x-axis, with each invalidate() re-drawing the new position. Instead I see it 'jump' to the last x position 0 (no intermediate stages).
I'm making the assumption that although x and y are updating via t0, I'm not too concerned since the loop is busy with the original x,y values (assigned to x0,y0).
I observe x,y updating and code is executed inside the 'if loop' (I see this via debug).
I tried adding a delay, but it didn't seem to make any difference. I can get it to re-draw directly to a new x,y position, but I need a smooth 'transition' via the loop to happen from one-x0-coord to another.
Any hints or tips would be appreciated.
Thanks in advance.
Steve