Follow me on twitter @wovencharlie to be notified when Comb Over Charlie is available for download.
Coming soon to an iPad, iPhone, Android Tablet, Android Phone, Blackberry Playbook, and Google Chrome Store near you.
Over the past few weeks I’ve had the privilege to work with the AIR 2.6 pre-release; I have to say I was completely shocked. The first time I used the AIR to iOS compiler that shipped with CS5, the frame-rates were poor enough that I disregarded it and never planned on using it again. About two months ago I decided to give it another go. I was shocked to say the least.
My application went from about 10 to 15 fps to a solid 40 fps. While I started off with the goal to create something with AIR for the sake of calling it an AIR app, I was able to forget about the technology and just focus on the game. Now, I spend more time creating new characters, backgrounds, and other game features instead of working around limitations.
The result is a smooth 40 fps game “Comb Over Charlie”:
Here are a few things I learned while creating Comb Over Charlie:
- Object Pool – Object Pool – Object Pool!
- Use JPGs where you can instead of PNGs
- Use CacheAsBitmap wherever possible
- At least for iOS – set stage.stageQuality to StageQuality.LOW during heavy animations
- With games similar these, make sure you enable GPU mode for iOS
- Limit the number of cacheAsBitmapMatrix objects
- Object Pool some more
- Create images as small as possible and scale them up x 2. So instead of a 1200 x 600 image have use 600 x 300 image
- Don’t have too many very large transparent layers overlapping
- If you have vectors and can convert them to bitmaps, do it!
- Profile your app to to catch memory leaks early
- Did I mention Object Pooling?
There are a few reasons why object pooling is so important:
1) Object pooling allows you to keep the amount of objects created to a minimum.
2) When objects are created and destroyed this tends to cause bumps or hiccups in the visuals (very bad for a smooth side scrolling game) – with object pooling you’re not creating something new on the fly, you’re only re-using what you’ve already created.
3) The less objects you have, the less memory you use. Re-use of objects contributes to less memory consumed, better battery life, and better performance.
Whenever I run into performance issues, it’s usually because I am forgetting to destroy something properly. So, consistently profile your application to spot memory leaks as early as possible.
Check back in the coming weeks to see more in depth tutorials on how Comb Over Charlie was made.
For now check out these great sites for more info and resources:
Elad Elrom’s optimization classes – great BitmapCaching class!:
Awesome site with object pooling tutorials and classes:
FriendsOfEd Flash Games : Great game book with loads of techniques / code:
Jesse Freeman on Advanced Blitting:
Come and learn more about AIR 2.6 iOS development at FATC June 9 – 12th – Flash And The City
Special thanks to Christian Croft for helping code the Score / Leader / Achievements board. – http://www.ecosquid.com