开发者

How to dynamically create an AnimationDrawable from a tiled image

开发者 https://www.devze.com 2023-03-22 21:01 出处:网络
In the game I am currently programming, I have a tiled image with different animation frames in a 4x3 matrix. I would like to create an AnimationDrawable consisting of each of these frames in sequence

In the game I am currently programming, I have a tiled image with different animation frames in a 4x3 matrix. I would like to create an AnimationDrawable consisting of each of these frames in sequence. However, I am only aware of making animations with entire images being frames. Can someone help me as to how 开发者_运维技巧to do this? If this could be done in XML, that's even better.

Thanks!


You can use Bitmap.createBitmap to create the clipped bitmaps from the big bitmap, and use AnimationDrawable.addFrame to add the bitmap to the AnimationDrawable.

0

精彩评论

暂无评论...
验证码 换一张
取 消