mc 动画位图缓存

源: http://blog.touchmypixel.com/2008/11/caching-animation-frames-vs-spritesheets/

想自己写个贴上来,没想打有现成的,贴上来,看看就能懂,改改就能用,多好啊.

作者实现了两种位图缓存,一种是将动作渲染成图片后放置在一个数组呢,另一个方法是将动作全部渲染在一张大图里(flash 中 bitmapdata 大小的限制,我以往日志中已经提过了),在用的时候再 copy 出来,如下式性能测试,缓存后比直接渲染矢量图性能高很多,而两种缓存方式在性能上差不多,从这里看用大图缓存好像稍微逊色点。

The results are as follows:

uncached:  ~16fps
cached as frames: ~120fps
cached on spritesheet: ~70fps

memory usage:

frames: 249 856
spritesheet: 270 336

demo:http://www.touchmypixel.com/blog_examples/081128%20Cached%20Animations%20SpriteSheets/

source: 源代码