Android : Android what is the best way to make mini(fast) animations

on Sunday, March 8, 2015


let's say I have 10 frames(images) of a character



from 1-5 - eyes are open

from 6-8 - eyes are closed

from 9-10 - eyes are open again


so here I can use an ArrayList of this frames(images) and in the View.onDraw() method can draw it on the screen while they change, but the problem is that I need to make many frames(images), lets say 40-50, to increase the time with open eyes, and the closed eyes are just a 3-6 frames, now what I think to do is use Timer to close the eyes(thus change the frame with open eyes to closed eyes) every 5-10 seconds, so then I don't need many frames and I can easily change the time with open/closed eyes, but I don't know which of these options will be more efficiently in speed(thus creating an individual timer thread for this) what do you thing to make this the best way? maybe there are other options to accomplish this, thanks.


ps: also using the Timer I will have to create a class for each animation, is there a way to avoid this? let's say execute the timer in the same class that extends View? and implements the interface Runnable, but the run() method of interface Runnable is already used by postDelayed(this, 1000)


any toughts?


0 comments:

Post a Comment