Tap the power of Flash’s ActionScript capabilities to build a simple game with animated characters. In the last edition of Digital Arts (February 2009), we created a character in Illustrator and animated it in Flash.
This month, we’re going to take our animation one stage further, and create a simple game using the character. Flash’s ActionScript language allows us to program MovieClips to have specific behaviours, events and properties.
By leveraging the flexibility of external classes, we’ll create a reusable set of code that can be applied to any number of MovieClips, allowing for swarms of independent gameplay objects that each report back to the main timeline and allow for straightforward game-status management.
This approach will also let you add extra elements to the game easily, and the technique can be applied to a variety of different game types: the principles are largely the same whether you’re creating a driving game or a shoot-‘em-up. If that all sounds a bit scary, don’t worry – it will start to make sense as we work through the steps.
01. Open your FLA from last month (or open start.fla from the cover disc). First, we need to allow the player to control our character, Madame Octopus (MO). We need to control her using ActionScript, so open your library (Cmd/Ctrl + L) then locate your Madame Octopus MovieClip. Right-click (Ctrl + click) on the MovieClip, choose Properties and then under Advanced, tick the Export for ActionScript checkbox. Give it an Identifier of ‘MO’ and a class of ‘MO’.