It's usually a little more complicated than that because you need to
have it handled by your loop and then there is variable timing, etc so
I wrote this to get people started:

http://www.rbgrn.net/content/253-main-loop-suitable-stable-animations

It has some code that you may want to use.  Just load up all of your
frames into an array of bitmaps and then have your draw code draw the
appropriate bitmap into the correct spot, which is as easy as
canvas.draw(bitmap, x, y, paint).

If you need to scale or rotate it, you may want to use a matrix to
draw and have it position (translate) scale and rotate.

I just helped someone else doing the same thing.  It's not that hard
after you've implemented it once.  There is some good discussion in
the top comments on this post as well -
http://www.rbgrn.net/content/54-getting-started-android-game-development

Good luck!

On May 25, 1:08 pm, Alekh <[email protected]> wrote:
> How do I add animated sprites to a custom view?
>
> I have used AnimationDrawable object to execute the animation. The
> animation works if I add the xml resource to the background of my
> custom view. But I want to know how to draw the animationdrawable
> directly on a canvas. Please help me with examples..
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to