0

i've developed an cross-platform AIR application, which seriously under performs on mobile devices caused by animating/using vector graphics instead of bitmap assets. employing cacheAsBitmapMatrix / cacheAsBitmap is better, when and where assigned appropriately, but still not as fast as using bitmap assets.

i've attempted to bitmapData.draw() the vector graphics to a Bitmap object at runtime and animate the bitmap object instead, but this performs only about as well as (or maybe even exactly the same as) simply caching the vector graphic as a bitmap.

Flash Professional 5.5 UI now has the ability to convert a vector graphic into a bitmap assets, but is it possible to do this at runtime? is it possible to have an actual Rasterize() routine to convert programatically drawn vector graphics and maybe even editable text into bitmaps at runtime for optimal animated performance, especially on mobile devices?

Chunky Chunk
  • 16,553
  • 15
  • 84
  • 162

1 Answers1

0

When you say that you tried animating the bitmap, I hope you didn't mean that you were rotating/resizing the bitmap - as that's a slow process.

Maybe have an engine that while your game is loading, creates a sprite sheet for you based on the frames in a MovieClip (if there's animation). Then these could be referenced by BitmapData.copyPixels().

This would simply:

  1. Create a BitmapData object.
  2. Draw each frame of the MovieClips timeline onto the BitmapData as you would manually with a sprite sheet.
  3. Store the BitmapData into an associative array for easy access later on, eg sheets["zombie1"]

You could even rotate your object in a for loop and draw the rotated object onto the sheet.

Then your SheetObject would just have methods for loading a portion of a previously defined sheet and displaying it.

Is this all on the right track..?

Marty
  • 39,033
  • 19
  • 93
  • 162
  • If you have them all stored in an array, you really don't need to put them in sprite sheet. You can just access them from the array ie animations["zombie_walk"] = zombieWalkFrames --your array of frames for that animation. I usually only use sprite sheets if that's the way the content was created. If it's vector movieclips as the source, best to just stick with arrays and manage it that way. – prototypical May 20 '11 at 00:13
  • i'm not doing any frame scripting. it's all programatically created vector graphics (drawing API) and Tweener for animation. yes, i'm rotating and scaling the graphics - for example, there's a square on the screen. touching the square makes it float above the stage, scaling it up slightly and displacing it's drop shadow. i understand that adding filters to vector graphics automatically caches the graphic as a bitmap. is scaling/rotating vector graphics (without filters) suppose to be faster than scaling/rotating bitmaps? additionally, i'm publishing to AIR 2.5 and have yet to try AIR 2.6 – Chunky Chunk May 20 '11 at 00:55
  • Multiple objects with filters applied that move around, change shape, rotate or really do anything other than be static will be a very hard hit on performance - no matter what type of object they are (bitmap/vector). – Marty May 20 '11 at 01:03
  • 1
    You can basically pre-render rotation/scaling if you are looking for speed. CopyPixels is the route you want to go in blitting, it's faster than draw. As Marty is saying, there's no way around the performance hit if you are doing scaling/rotation on the fly. Keep in mind that bitmapCaching actually slows you down if your are scaling/rotating vectors. You'll be better off with no bitmapCaching in that case. Because it's going to be caching the new scale/rotate every frame. Also keep in mind that if you want to rotate/scale a bitmap on the fly, it's going to be a bit jaggy compared to a vector. – prototypical May 20 '11 at 03:29