0
votes

Flash Pro CC, AS3, Air for Android (v17), rendering mode GPU, stage quality.LOW, FPS: 60, testing device: an old Nexus One smartphone (Android 2.3.3).

The guides say that GPU makes rendering the bitmaps cheap, somehow i can't grasp how exactly it works.

So i have 49 separate bitmap squares covering the stage and one MovieClip in the middle with a bitmap inside tweened to move up and down (jumping ball). Pretty simple, right?

This is the view: http://i.stack.imgur.com/EKcJ6.png

  1. All graphics are bitmaps (not vectors). Yet i get 55 fps (it varies arround 53-57).

  2. Then i select all 49 squares and put them inside a symbol (MovieClip). Visually nothing changes. It seems to increase the FPS a tiny bit, the average fps is now ~57 (55-59).

  3. Then i take the MovieClip (with all the squares inside it) and set cacheAsBitmap=true. Voila, now i have 60 fps!

What is happening in all 3 different cases? Why i need to put bitmaps into one MC and cache this MC as bitmap - aren't the squares already bitmaps?

I have also tried to make each square a MovieClip and cache it as bitmap, but i still got 55 fps.

Is it possible to keep squares separate at 60 fps?

In my real project i have many MovieClips on the stage (~100) but in most cases only one of them is animated at a time. Yet somehow it seems that the mere presence of other movieclips reduce the performance (fps). Obviously, i cannot put them all into one MC and cache it as bitmap as in the simplified example above.

How can i solve this, what should i do?

Thanks!

1
Why do you need 60 fps for a Color Lines game? :)Andrei Nikolaenko
Good catch ;) Why not 60 fps? Looks much better than 30 fps. And i know 60 fps should be possible even with more animations than i have. Just need to find a way to optimize it.DBC
Animations look good at 30 fps already, to have a visual difference at 60 fps you need at least 60 pixel distance that ball must go vertically, so each frame it will move at least 1 pixel. Also at 60 fps the battery will drain faster so when designing a game for mobile device you should also care about battery life. Considering the performance, try blitting all movieclips into single bitmap. (Not caching as bitmap but blitting each of them into real bitmap)Andrei Nikolaenko
I agree that sometimes slow animations don't need more than 30 fps, but in my case i can see with my own eyes that 60 fps look way smoother and i feel it should be possible to achieve without draining battery much, because, as i mentioned, my animations are simple and there are very few objects being animated at the same time.DBC
It's not because of the animation. A Flash project has a default frame rate as its property and it will try to run at that frame rate no matter what and how many animations you use. This is what Adobe says: "An application’s frame rate determines how much time is available for each “application code and rendering” cycle, as described in Runtime code execution fundamentals. [...] A higher frame rate expends more CPU cycles and energy from the battery than a lower rate." More here: help.adobe.com/en_US/as3/mobile/…Andrei Nikolaenko

1 Answers

0
votes

I think it relates to this best practice recommendation:

Limit the numbers of items visible on stage. Each item takes some time to render and composite with the other items around it. When you no longer want to display a display object, set its visible property to false. Do not simply move it off stage, hide it behind another object, or set its alpha property to 0. If the display object is no longer needed at all, remove it from the stage with removeChild().

By putting all the bitmaps in a single container and setting cacheAsBitmap=true you are essentially turning them into a single bitmap as far as the compositor is concerned. This tends to be faster to composite than multiple individual bitmaps. Setting a bitmap to cacheAsBitmap=true (or in a single container with cacheAsBitmap=true) has no effect because it's already a bitmap.

Also note that GPU mode isn't recommended anymore, it was Adobe's first attempt at GPU accelerating the display and they basically gave up on that path in favor of the new Stage3D rendering pipeline. While GPU render mode can work really well when used just right, it can be somewhat unpredictable and confusing, so I would highly recommend you check out Stage3D.

Hope that helps.