AnimationDrawables are designed to put animations as backgrounds of
views.  AnimationDrawables are not meant for games.  They have more
overhead than you want and will still need essentially the same amount
of code.  I don't recommend trying to use them if you want a game that
can perform well.  Even if you don't care about performance, it would
seem like a hack to create this resource just to get frames out of it,
since you can't use its looping thread because there is no method to
pull the current image or frame index from it.

On May 26, 4:36 am, Alekh <[email protected]> wrote:
> Hi Robert,
>
> Thanks for the quick reply. I understand the way it is done in other
> java games. But given an AnimationDrawable class to show animated
> drawables, I wanted to know how to use that class to render frames on
> a canvas. If that is possible, then it will reduce the number of lines
> of code. So can u please tell me how to render the animation drawable
> on a canvas? I am looking forward to a quick reply.
>
> On May 26, 1:11 am, Robert Green <[email protected]> wrote:
>
> > 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 animatedspritesto 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