I have made a "Hello World" animation (colorful circles bouncing around the screen) in order for learning and starting to get used with the Android ways.
I am a braziliam system analyst, Java certified, experienced, but a complete newbie in what concerns Android.
So, I would like comments about this approach for 2D annimation / games in Android, keeping a leach over an app Thread of my own.
A run loop (in the View) that controls the animation, with a synchronized block that invokes a postInvalidate() and waits. So, when the
device triggers the onDraw event, it makes the drawing and, in other synchronized block, notifies the waiting Thread to proceed.
This way I keep a synchronization involving my Thread and the devide screen refreshes, and by testing this app in an actual device
(Android 2.2 API level 8) I reached about 85 to 90 frames per second, wich I think is framerate enough for my initial game developing purposes.
The other detail is an "init()" method, invoked when the onDraw first occurs. Then I know my app may initialize resources that depends on
device data (like screen width, height and so on), making it more device independent (by sizing initiated images according to the dimensions, for example).
Well, this is my trial of using a tradicional animation/game paradigm implementing a run loop (update / paint / sleep) with Android, but I don't know if this is the
best approach, or even if it is recommended at all.
Comments and info very appreciated here, thank you all very much.
ps. I know the code is rough, and that it may receive many improvements, but as I said, is just an "animation Hello World" to play around with Android
capabilities, feel the environment and put this approach into test.