Depending on UI event handling to produce smooth
and accurately timed animations is usually bad idea
In your code, if you remove delay you are just trashing
event pipeline, so UI will (and certainly does) become irresponsive.
And if you keep it in, your delays are unpredictable
(let me Guess, you are sending messages because you can not
affect UI from non UI thread? )
I recommend to look into LunarLander sample. Basic idea for smooth
animation is:
1. Use Surface to draw ( any SurfaceHolder subclass ), you can access
it from any thread
2. You animation loop looks OK
3. I would recommend to create something like finite automate / state
engine
to provide smooth and controlled transition between game states
You drawing method would look like:
redraw() {
// field is prepared
Canvas canvas = holder.lockCanvas();
// draw background
canvas.drawBitmap(field, 0, 0, null);
... draw whatever you like
// push it to the screen
holder.unlockCanvasAndPost(canvas);
}
have fun
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en