Game Development Reference
In-Depth Information
will likely be the best antidote available to bottlenecks on iOS
devices (and even Android ones as well).
Not Without Its Limits
Before you close this topic and think bitmap caching has solved all of
the performance challenges, let
s examine its limitations. The
resources on the GPU are also limited, so you shouldn
'
texceeda
total of roughly four million pixels of cached data, which is roughly 26
full, third-generation iPhone screens worth of data. This should be
more than enough space for your average single-screen puzzle or
strategy game, but it can definitely become an issue if you
'
ve got
scrolling backgrounds or many animated Sprites. Adobe also recom-
mends limiting the size of any individually cached element to 1020
'
×
1020 pixels or less
of the total
cache. This is due to actual hardware limitations on iOS devices.
The memory limitation means you
alittleoveronemillionpixelsor
¼
ll have to be shrewd about
those elements you choose to cache, but your approach should either
make extensive use of the feature or not at all. When exporting your
application, you will have to select whether it will use CPU or GPU
compositing of display objects. Using the GPU option and caching
only an image or two in your entire application will actually slow
down the performance. This is because the CPU has to send all of the
noncached objects up to the GPU to be rendered every frame
'
lots of
data. If your game is very simple and it only makes sense to cache a
handful of elements, you very well might be better off letting the CPU
do all the works. As always, once you are done with a DisplayObject,
be sure it is properly set for garbage collection so that memory will
get freed up for something else. This means deleting all references to
it and purging it from the Stage. We
ll look in depth at a practical
example of caching data to the GPU shortly.
'
Code Matters, Too
In desktop/web-targeted Flash development, the overhead gener-
ated by ActionScript code is not typically a concern. Graphical con-
siderations (size of elements on Stage, rendering performance, etc.)
will almost always be the key bottlenecks to overcome or circum-
vent. This is largely due to the very fast virtual machine that inter-
prets and compiles AS3 at runtime and the substantial processors
in most modern computers. Although there are certainly optimiza-
tions all programmers can make to get extra performance out of
their code, it is not a high priority except in extremely complex
applications.
The same cannot be said for ActionScript running on iOS
devices. This is because the code is not compiled or interpreted at
Search Nedrilad ::




Custom Search