In this article I’m going to give you a quick overview of how I set up Pushbutton Engine (PBE) for game development. Don’t worry if you’ve not done anything with PBE before as I’ll be guiding you through the main features over the coming articles.
NOTE: Those of you who have already had a look at PBE will note that the initial articles in this series are similar to the introduction and initial examples within the PBE documentation. For brevity and completeness I’ve opted to start at the very beginning for those who haven’t used PBE before and it made sense to create my own versions instead of bouncing readers off to alternative resources before they get going.
First up let’s talk IDEs
Personally I use Flash Builder, but you can use Flash Professional CS5 – both of which I’ll be looking at today. If you use an alternative IDE like Flash Develop or FDT setting up PBE shouldn’t be too hard to sort out. Given the slant towards ActionScript in game development you are more than likely going to be spending the majority of your time in a text editor of some description – which is fine if you are a Flash Builder user as it has a great ActionScript editor. Flash Professional users, depending on which version you are using, you may want to stick with the built in ActionScript editor or if you are using Flash Professional CS5 take advantage of the new integration with Flash Builder – the choice is yours.
As we move forward in these articles I will be talking more about the actual construction and development of games using PBE as opposed to IDE specific nuances. One thing I will highlight right now though, is that we will be looking at ActionScript 3.0 code. If you’re not up to speed with AS3 yet there are numerous resource on Adobe.com to help you make the switch. Game development is a perfect opportunity to jump on-board the AS3 train.
However, we all had to learn to walk before we tried to run, so with this in mind let’s look at how to set up our environment so we can create games using Pushbutton Engine.
With Flash Builder you have two options. You can choose either a Flex based project or a pure ActionScript one – It’s up to you which one you decide to go with (the majority of the set up is identical). One thing I will recommend is that if you are looking to develop for multi screen deployment then I’d suggest opting for a pure ActionScript approach – or if you do want to use Flex for your web and desktop versions, split the project in to core functionality (used across all variants) and then specific projects for each target platform.
Before we get to tied up with development best practices let’s look at how you set up both, starting with a Flex project.
Setting up a pure ActionScript 3.0 project in Flash Builder is identical to the steps above except you will need to create a libs folder in your project root and add that to your project as a linked SWC folder. To do this right click on the project entry and select Properties from the context menu
In the steps above I recommended that you copy the PBEngine.swc in to the libs folder in your project. Some prefer to just link it from wherever it was unzipped on their machine but I would raise that as a potential issue.
Take this scenario: You are working on a large scale game using PBE and as part of a team you need to make sure that the content is put under version control. By simply linking to the SWC location on your machine not only does this present a problem as the path isn’t likely to be identical on everyones machines (think about how Mac OS X paths everything by user). It also means that anyone who is new to the project needs to then go and find the correct PBE SWC. This in itself could lead to different versions being used on the same game by different developers. So for ease of ramping up and making sure the project is self contained I always copy the relevant SWCs in to the libs folder to avoid these types of issues.
Once you’ve added the PBE SWC to your project you now need to update the compiler arguments so that certain metadata tags used by Pushbutton Engine are included when you compile your game.
Flash Professional CS5
Flash Professional is just as easy to set up. Like Flash Builder, you have two options on how you develop your games using Flash Professional. You can either do all of your coding etc directly in Flash Professional or if you are using Flash Professional CS5, you can take advantage of the built in integration with Flash Builder and use that to write your code in. Like everything in life the choice is your which one you opt for – I’m happy using either.
To set up Flash Professional (I’m using Flash Professional CS5 here, but the steps are almost identical for CS4 and CS3 – although the dialogs may look slightly different), to use PBE you need to create a new FLA file and save it in to a directory somewhere on your machine (you know where you want to save it so far be it for me to dictate where it should be).
As I used a stepped procedure for Flash Builder I’m going to use the same process for Flash Professional. First up let’s set it up so you are using just Flash Professional.
Now you have the libs folder and the PBE SWC added to the directory you just need to associate the SWC with your FLA file. Switch back to Flash Professional and with the newly saved FLA file still open select the ActionScript Settings entry from the File menu (File > ActionScript Settings…). You’re going to need to add a couple of bits of information here. Firstly you need to add the libs folder. Once that is done you can then associate the main ActionScript document class to the FLA. Luckily for us you can do both from within this dialog. First up the libs folder
Before you click OK to apply these settings there is the matter of the document class to resolve. Pushbutton Engine is very ActionScript orientated so most of your development will take place in external classes. To kick this all off you need to provide the FLA with a base document class. If you look at the top of the ActionScript Settings dialog you will see the document class entry field. In here you need to put the fully qualified package name of the class you wish to use as the document class for this FLA. Bear in mind that the package path is relative to the FLA itself. To make it simpler we’ll just place our ActionScript class in the folder as the FLA.
So that’s pretty much all you need to know to get Flash Builder or Flash Professional CS5 ready to start using Pushbutton Engine for game development. In the next article we’ll be looking at how you create objects and add them to the game.