Goodbye 2011

I’ve probably worked harder over the last 12 months than I’ve ever done before, and that’s including my two year stint in the games industry. In fact, I’m not entirely sure where I’ve managed to find the time to update this blog at all, but I’m glad I have. And although some amazing opportunities have come my way, I can’t help but feel a tad deflated by many of the things that have happened to the Flash platform in that time. I’m not gonna dwell too much on the negatives though. On the whole it’s been a fantastic year for me personally, and I’ve got many exciting projects I’d like to undertake this year.

I’ll talk about my plans for 2012 in another post, but for now here’s a recap of what I managed in 2011:

Flash iOS Apps Cookbook

I’m excited to say that my book, Flash iOS Apps Cookbook, went off to the printers last week and will soon be available. It’s been quite an amazing experience and an opportunity I never thought I’d be given. The book’s been 13 months in the making and focuses on iOS development using Flash Professional CS5 & CS5.5.

In an attempt to make it as accessible to as many newcomers as possible I spent considerable time covering Apple’s dreaded provisioning process and explaining the fundamental steps for setting-up Flash to publish native iOS applications. By the end of the third chapter you’ll have made your first app and have it running on your iPhone. For those already familiar with these steps, there’s plenty on offer, including hardware accelerated rendering, utilizing native iOS text controls, and working with H.264 video. There’s also a whole chapter dedicated to tips and tricks for optimizing and converting desktop projects to mobile.

I’ll cover my book in more detail soon and plan to post frequently to support it over the coming twelve months.

WeeWorld

I’ve enjoyed a very good year at work too. I was lucky enough to work on some exciting things, including a complete re-write of our WeeMee Avatar Builder, which is something I’ve been itching to do for almost five years now. The old version was bursting at the seams as it had to pre-load every single asset, which given our growing catalogue, was causing some pretty bad load times. That’s all resolved now, and thanks to the new architecture, everything loads in a jiffy. Yay!

Although we have a dedicated department of Objective-C programmers beavering away on cool iPhone games, we took the opportunity to try porting one of our web games to iPad using Flash. To be honest, so many negative things have been said about Flash’s performance on mobile that I don’t think anyone actually expected me to pull it off. However, after chipping away at it over the space of a fortnight, Doppelganger for iPad was born. Flash’s vector renderer really did prove to be invaluable for this project and the outcome was a game that ran silky smooth on both iPad 1 and 2.

I also documented many of the performance optimizations for those who are interested.

Starling

Bitmap graphics and sprite sheets are in. While it might seem like a backwards step for many used to Flash’s traditional display list and vector tools, there’s no denying that pushing textures to the GPU can produce some terrific results. Although writing my book left me with almost no spare time, I did manage to spend a week or so experimenting with the Starling framework. It was a lot of fun, particularly messing around with particles, and is something I hope to return to this year. I’m praying that Adobe’s Stage 3D support for iOS hits the mark and that Starling gets to a position where it’s optimized for mobile. In fact, Adobe really need to make sure this happens.

HTML5

I’ve been desperate to spend some time with HTML5 but again, finding the time has been difficult. I did manage to conjure up five days near the end of November to write my first mobile app using JavaScript and was decently impressed with the results. It was a port of a speedometer application I wrote for Android a while back. It still needs some tweaks in places before I blog some more about it. Also I’m not sure if this blog is the appropriate place for it. Let me know your thoughts and if there’s enough demand I’ll keep you guys updated on its progress.

My X-wing Targeting Computer App

I swear this one could have made me rich. After years of trying, I finally come up with a good idea for a mobile app, only for George bloody Lucas of all people to put a stop to it. Typical. Well to be honest, it wasn’t George himself, but his licensing department.

Anyway, after trying to get permission to release my X-wing Targeting Computer app, I finally had to admit defeat and shelve the project. I’d originally tried some games companies with little luck before being given contact details for Lucas Licensing. Unfortunately they weren’t interested, leaving me with no option but to finish pursuing it. It was all a bit of a shame because the response regarding the app was so overwhelmingly positive that I was convinced I’d have no trouble getting it released.

Nevertheless, it was a great little project to work on and being famous on the web for 5 minutes was a lot of fun.

Adobe Dropping Flash Player for Mobile

If Adobe’s intentions were to drive as many people away from the Flash platform as possible then their decision to drop Flash player for mobile was a raging success. In fact, they’ve probably done a better job of it than Apple ever managed to do. To be honest, with Flash player indefinitely banned from iOS, it’s hard to argue against their decision. However, the way they communicated things was simply disastrous and has left a bitter taste with many Flash developers (or should that be ex-Flash developers).

While Flash player’s use on mobile phones was limited, I always thought it had promise on tablets. Some of the more recent tablets were managing some good playback performance and I felt things were heading in the right direction. Unfortunately, while the hardware will definitely be there in a year or two, HTML5’s rise to domination has meant that Adobe (and Flash mobile Player) have simply run out of time.

Unreal Engine

Finally, I took my first steps into the world of 3D graphics. I had been planning on spending some time with one of the many 3D engines built on top of Stage 3D, but my brother recommended I look at Unreal Development Kit (UDK) instead. I thought it was an odd suggestion at first but it has helped me to get to grips with many 3D concepts without getting bogged down in code – you can quite easily build 3D worlds entirely with drag and drop. Plus my brother has two years professional experience with Unreal Engine, making him a great help when I get stuck.

It’s early days for me, and I had to stop sooner than I’d like due to my book commitments, but I’m looking forward to picking up where I left off. I’m also quite excited about the Flash export options that will be making their way into UDK at some point.

Native iOS and Android Apps

We saw some nice apps released on mobile. A few of the stand-out ones included
Age of Defenders, Machinarium, Red Bull Illume HD, Rossignol Experience, and Tweet Hunt. It’ll be interesting to see what’s possible when Stage 3D eventually makes it to AIR for iOS and Android.

It’s Been a Good Year

So all in all, I’m happy with my achievements and feel that I’ve had a very successful and enjoyable year. Hopefully the next twelve months will be just as busy, and I promise I’ll try and update my blog more frequently.

Merry Christmas

This little trinket has been in my family for as long as I have. As a kid I used to love winding it up and listening to it playing Silent Night as I sat by the Christmas tree. It always felt like a magical time.

As you can tell, the years haven’t been kind to it. The little angels look like they’ve been to hell and back, and the candles that used to sit on either side of the hymn sheet have long gone. Now it has caught my one year-old nephew’s eye and I fear it won’t survive much longer – another angel lost an arm yesterday.

So I decided to make this post. Not just in an attempt to digitally preserve it but also in hope that you too will feel its Christmas magic.

Have a great Christmas and New Year everyone!

Overlaying AIR 3.1 for Flash Professional CS5.5

I finally got round to updating my AIR Overlay tutorial for those who would like to take advantage of the AIR 3.1 SDK from Flash Professional CS5.5.

Check it out and let me know if you find it useful: Overlaying AIR 3.1 SDK for Flash Professional CS5.5.

Fun with Unreal Engine

With all the excitement over Unreal Engine 3’s upcoming support for Flash Player 11, I thought I’d spend some time looking at the Unreal Development Kit (UDK). After all, it would be pretty sweet to be able to bash out an Unreal-powered game that could be delivered via the browser.

Believe it or not, but this was done by myself and not a team from Epic Games.

Given its depth, UDK is surprisingly easy to work with. After only a week of tinkering I’ve already managed to create my first 3D level complete with crazed bots hell-bent on killing me. Take a look at the screen shots if you don’t believe me!

That's right, I can do underwater too! I know, I rock!

I’ll keep you dudes posted on my progress. Anyway, I guess I better get back to work on Gears of War 4. It’s not gonna code itself you know.

Free Books in Exchange for Honest Opinion

One of the perks of writing a book is that my publisher is always happy to send along titles that they think might interest me. So I was delighted when these three books landed on my doorstep recently.

The good news is that you don’t actually need to be writing a book or be a member of some secret cult to get your hands on some free stuff. The kind folk at Packt Publishing are always on the lookout for individuals who’d like to read some of their latest publications and give their honest opinion via their blog, Amazon, Slashdot etc.

They just recently released the following three titles:

So if you think you’re up to the task and can turn-around a review within a week or so, then send me an email or catch me on Twitter and I’ll put you in touch with one of my secret contacts at Packt.

AIR for iOS Optimizations

I thought I’d follow-up my original post about Doppelgänger, and take some time to detail its implementation from a rendering perspective. There’s a lot that can be done to ensure your AIR for iOS apps hit their target frame rate, but these optimizations aren’t always obvious. I’ll also mention a few common pitfalls that leave many Flash developers scratching their head.

I hope you find the following useful for your own projects.

Test on the lowest common denominator

Test frequently on a physical device and use the lowest common denominator. For example, if you’re targeting both iPad’s then get your hands on an iPad 1. Don’t exclusively test on the iPad 2 and assume everything will be fine and dandy for those using previous generation hardware. You’ll be asking for trouble if you do.

Profile your app using Instruments

I know Flash Professional and ADT allow you to develop iOS apps using a PC, but if you’re at all serious then you really should get yourself a Mac. Why? Well you’ll be able to install the Instruments application, which allows you to analyse the performance of your app as it runs on a device.

Profiling tools are essential. Profile and optimize as you go.

Instruments was invaluable during the development of Doppelgänger. It allowed me to examine the app’s memory consumption, CPU usage and frame rate, making it very easy to spot areas in my code that were causing CPU spikes very early in the development process. My personal goal was to keep CPU usage at around 20%. It was easy to spot any spikes above this and quickly address these by optimizing either my code or graphics.

Don’t ignore spikes in CPU usage. Endeavour to fix all bottlenecks as early as possible.

Focus on rendering bottlenecks from the outset

Graphics rendering is often the single biggest bottleneck when porting Flash apps to iOS. Be prepared to flatten your display lists, simplify complex vector shapes, reduce the number of layers, and use bitmaps where appropriate. Also, perform incremental tests of your graphics assets and use Instruments to measure performance.

The original FLA for Doppelgänger was quite bloated. There was an insane amount of vector detail in many of the assets and an unnecessarily deep display list. I converted much of what was there to bitmaps to maximize render performance. I also tested many of the graphics assets in isolation by simply publishing individual test apps and profiling with Instruments. Once happy with the performance I’d layer more animations together and test again. This allowed me to quickly find any graphical assets that were going to hurt performance.

GPU rendering

AIR for iOS provides two choices of rendering engine – CPU mode and GPU mode. The CPU renderer is the same software renderer used by the desktop Flash Player. However, on iOS devices we can instruct Flash to offload much of this work to the GPU, which when used correctly, can accelerate rendering. Doppelgänger took advantage of GPU rendering to help maximise its frame rate.

Bitmap caching is your friend

When a display object changes in any way, or intersects the bounding area of some other display object that has changed, then it will need to be redrawn. Unfortunately redrawing complex vector shapes, text, or clips containing deeply nested display lists can be expensive.

Thankfully help is at hand in the form of bitmap caching. Put simply, bitmap caching stores a bitmap representation of a display object and uses the bitmap version whenever the object needs to be re-drawn. In many situations, drawing the bitmap representation to the screen is typically much faster than redrawing the original. Bitmap caching is particularly useful for objects that have translation (movement along the x- or y-axis) or transformation (scaling or rotation) applied to them.

Doppelgänger makes heavy use of bitmap caching to minimise the render time of each frame.

Bitmap caching is your enemy

Hold on! Didn’t I just say that Bitmap Caching was good? Yes I did. But only if it’s used correctly.

Many developers seem to think that activating GPU rendering and bitmap caching everything, will somehow guarantee a blindingly fast frame rate. This couldn’t be further from the truth. Misuse of bitmap caching will cripple your application. Even if you fully understand the ins-and-outs of bitmap caching, it’s all too easy to make a simple mistake that can undo much of your previous optimizations.

To benefit from bitmap caching you need to ensure that the cached bitmap does not frequently become invalidated. If invalid, the bitmap will need to be recreated by rendering its source display object and copying a bitmap representation to an off-screen buffer. To prevent this, don’t cache movie clips that contain timeline animations or container clips that have children that move relative to it.

I must admit that I slipped up here. Some of my initial tests on Doppelgänger performed poorly on iPad 1. I eventually tracked it down to the shutters that open and close between levels. I’d accidentally cached the container, which held both halves of the shutter. Essentially, as they opened and closed, every frame of animation was invalidating the cached version and forcing a re-cache. With the shutters consuming almost twice the height of the screen when fully open, re-caching was killing performance. This was fixed by simply caching each of the shutters’ child clips rather than the container.

To see the shutters in action, take a look at the gameplay video of Doppelgänger.

Bitmaps Vs. Vectors

Use bitmaps or vectors based on their strengths. It’s easy to get into the mindset of using bitmaps for everything because they tend to render faster. However bitmaps can consume significantly more memory and can quickly exhaust GPU memory when GPU Rendering is being used.


Content with a large bounding box and/or many animation frames might be better as vectors.

Doppelgänger uses a combination of both vector and bitmap assets. The timer’s ticking clock, for example, is a vector timeline animation. With a bounding area of 173×161 pixels and running for 90 frames, a series of bitmaps would simply have been too expensive (almost 10Mb of uncompressed data). The same was also true of the tick and cross animations, which both cover a fairly large area of the screen come the end of their animation cycles. And of course the WeeMee’s themselves are constructed from vector shapes, helping to reduce the app’s footprint and ensuring the WeeMee’s maintain their image fidelity when scaled.

Swap render quality where appropriate

Consider using a lower render quality setting. Bitmaps are relatively unaffected by this and it really can be hard to spot any differences for vector content that moves.

Doppelgänger constantly switches between low and high rendering quality during the lifetime of each game. This gives a massive performance boost, especially on the iPad 1. The drop in render quality is noticeable on the timer’s clock but I felt it was worth doing in order to maximize the frame rate. Each of the WeeMees are rendered into pixel buffers using the highest render quality setting just before each level begins. The bitmap representations of each WeeMee is then used during the level, which by this point has switched to the lowest render setting.

Conclusion

It can very much feel like smoke and mirrors some times, but it’s the final result that counts. These challenges aren’t specific to Flash and ActionScript either. Targeting mobile requires a little more effort than developing for the desktop. However, with some careful planning and an understanding of the constraints you’re working within, you should be able to make the necessary compromises to ensure a fun and engaging experience.

Packt Book Giveaway

It’s always good to learn new things, and to help you do just that, I’m putting three really great books by Packt Publishing up for grabs in my latest competition: Unreal Development Kit 3 Beginner’s Guide by Richard J Moore, Xcode 4 iOS Development Beginner’s Guide by Steven F Daniel, and Android 3.0 Animations Beginner’s Guide by Alex Shaw.

Here’s a little more information about each book.

Xcode 4 iOS Development Beginner’s Guide

  • Learn how to use Xcode 4 to build simple, yet powerful applications with ease.
  • Each chapter builds on what you have learned already.
  • Learn to add audio and video playback to your applications.
  • Plentiful step-by-step examples, images, and diagrams to get you up to speed in no time.
  • A practical guide to building your own fun and exciting iOS applications rapidly using Xcode 4.

Android 3.0 Animations Beginner’s Guide

  • The first and only book dedicated to creating animations for Android apps.
  • Covers all of the commonly used animation techniques for Android 3.0 and lower versions.
  • Create stunning animations to give your Android apps a fun and intuitive user experience.
  • A step-by-step guide for learning animation by building fun example applications and games.

Unreal Development Kit 3 Beginner’s Guide

  • Full of illustrations, diagrams, and tips for creating your first level and game environment.
  • Clear step-by-step instructions and fun practical examples.
  • Master the essentials of level design and environment creation.

So how do you go about winning one of these books? Well the rules are simple:

  1. First, decide which book you’d like then head over to its official page (links are at the top of this post) on the Packt Publishing website.
  2. Read over the book’s details then pop back here and add a comment to this page stating the book you’d like and one feature of it that makes you want to own a copy.
  3. Tweet a link to this page on Twitter. To make your life easier, here’s a tweet I made earlier.

Each winner will receive an eBook version of their chosen title. Feel free to submit an entry for more than one book.

The contest will close on December 4th at 11.59pm GMT. Winners will be contacted by email, so please remember to use your real email address when you add your comment.

Good luck!

The competition is now closed and comments have been disabled. The winners will be contacted.

Doppelgänger iPad Experiment

While we primarily develop our iOS apps at WeeWorld using Objective-C, we are open to alternative technologies. Here’s a little iPad game we put together as part of our evaluation of Adobe AIR. Doppelgänger is a port of a Flash-based browser game we released on WeeWorld last year and seemed like a natural fit for the iPad’s spacious touch-screen. It’s a simple game concept; the player has to race against the clock to spot the matching WeeMee from the crowd.

One of the major advantages of using AIR for this was that we got the full benefit of Flash’s vector rendering engine. With each WeeMee being randomly generated from a pool of 150 assets, it was essential we keep the final size of the app down. Using vector-based assets let us do that and also ensure we could scale the WeeMee’s without a loss of fidelity.

Everything went fairly smoothly but one feature missing from AIR that we found we really need is the ability to use native UI components and elements – it’s simply too much work to fake these things up in Flash. We got lucky with Doppelgänger but there are so many other similar mobile projects at WeeWorld that we simply can’t consider using AIR for because of this omission. Would be great to hear from Adobe if this is likely to change any time soon as it could really extend AIR’s reach.

So there you have it. A nice little prototype app that was put together in a very short space of time. The video shows Doppelgänger running on iPad 2, but it runs just as well on iPad 1 too.

Age of Defenders

Here’s a really nice browser-based Flash game that has just been ported to iOS and Android. Age of Defenders is a real-time multi-player tower defence game built with Flash and Adobe AIR. One of the really nice features of its online play mode is that you can do battle with other players across multiple platforms. I think you’ll agree that Age of Defenders looks gorgeous and it will also be available soon for Blackberry Playbook, which demonstrates the cross-platform strengths of AIR.

One thing that does concern me slightly, and it’s also the case with the excellent Machinarium, is that lower-end devices such as iPad 1 seem to be excluded from the party. This is a real shame as the iPad 1 is certainly no slouch and it does show that perhaps AIR isn’t quite there performance-wise yet. I’m personally hoping that Stage3D and the Starling framework will help in this regard when they eventually make it to AIR for mobile. However, for those with the right hardware, it’s a really nice gaming experience.

For an interview with the Age of Defenders lead developer, head over to Adobe Gaming Evangelist, Tom Krcha’s blog.

Life after Flash Mobile Player

I can’t say I was surprised by Adobe’s decision to kill the Flash Player for mobile, and I’m not entirely sure what all the fuss is about from the Flash community. After all, how many Flash developers out there were actively developing Flash content for mobile delivery? I bet it was a tiny percentage.

So why did Adobe’s mobile strategy for Flash Player fail so badly? Well to be honest. Apple’s decision not to support Flash on iOS pretty much killed Adobe’s plans from the outset. But it’s also clear that there wasn’t much enthusiasm for Flash on Android either. Performance across devices was variable and even Flash on high-end tablets seemed to struggle. So why was this the case?

Well, I think Flash was pretty much a victim of its own success in this regard. It’s clear Adobe spent considerable time and energy optimizing the Flash runtime for mobile but unfortunately that was just half the battle. There really isn’t much that can be done if the content being run by the player is bloated and not optimized for mobile, which unfortunately is the case for almost all SWFs out there.

Developers had simply become accustomed to creating content for desktop with almost no consideration for memory and CPU usage. What we ended up with was a web chock-full of SWFs that strangled the life out of every mobile device they ran on. A decade, or so, of not having to care about optimization had essentially set Flash up for a very bad fall.

But ultimately it wasn’t the performance that was the real killer. It was a simple issue of usability. Even content that ran well was almost impossible to use. With the tightly packed pixel density of mobile screens it was difficult to interact with buttons and links that were designed for pixel-perfect mouse clicks rather than fairly inaccurate finger taps. Of course, this isn’t a technology issue and certainly isn’t exclusive to Flash, however with so many Flash sites out there the problem was quickly associated with the platform.

By excluding Flash from iOS, Apple has effectively cleaned-up the web. Companies who wanted a mobile web presence were forced to ditch Flash and redesign their site. In the process this allowed them to create simpler, cleaner and ultimately more usable experiences. The success of the App Store did the rest. Games and applications that were once delivered via the browser had found a new home and another reason for having the Flash plugin had eroded away.

So while many will feel aggrieved, disappointed, and angry at Adobe’s decision to stop developing Flash Player for mobile, I think it’s hard to argue against it.

You’ll still be able to develop for mobile using Flash, but it won’t be for the browser – you’ll be targeting the Android Marketplace and Apple’s App Store instead. This makes perfect sense as this is the expected location for the sort of rich content that can be created using Flash. And let’s not forget that the Flash Player will continue on desktop where it has had so much success over the years. Many of the recent announcements, such as Stage3D, create exciting new possibilities and will hopefully be making their way to mobile soon too.

But for rich, interactive web-sites, it’s HTML 5 all the way! Right now, we have a clean slate. It would be easy to let the new JavaScript APIs provided by HTML 5 and the many great JavaScript libraries out there go to our heads. However, the last thing we need is all the same mistakes that were made with Flash being made with HTML 5. Experiment by all means, but when it comes to sites for customers and clients, let’s keep the web usable folks. Happy coding!