Flex

Developing games with PushButton Engine – Part 1 – Using Flex and Flash Builder

2

So I know I haven’t posted in quite some time. Between work, BugQuash, MAX, contributing to PushButton Engine, my country’s 500th anniversary to plan, my wedding to arrange, my wife to murder and Guilder to frame for it, I’ve been swamped.

But tonight… I break my blog silence. As I just mentioned, I’ve been contributing to the PushButton Flash Game Engine. I’m now going to show you how to set up Flex Builder 3 or Flash Builder 4 in a way that allows you to develop games on PushButton Engine, as well as how to work on the core engine itself. I’m breaking this down into very small pieces so that everyone can follow along. So it’s going to be a long post with lots of pretty pictures.

After writing this post, it ended up being longer than I hoped. So I’m going to write a series of posts about developing games using PushButton Engine. This post will focus only getting set up inside Flash and Flex Builder. The plan is to add other IDEs in as well, for example FlashDevelop, FDT, etc…

Step 1 : Download the PushButton Engine source code.

[note]
If you are not familiar with Subversion or you need a primer to the basics of contributing to or working with open source projects please check out my “Getting Dirty with the Flex SDK” post, more specifically the TechWed Presentation.
[/note]

WARNING!! For these steps to work, you must use at least revision 602 of the PushButton Engine.

Download the PushButton Engine core from Google Code. Since I am a developer in the engine, I have checked out trunk and all of the branches. My working copy is located in /pbe (or C:/pbe on Windows). I will use that location throughout the rest of this post. Make sure that if you choose a different location that you sub it in wherever I use “/pbe”.

So on OS X, to checkout the source code, open up Terminal and type in the following lines:

cd /
svn checkout http://pushbuttonengine.googlecode.com/svn/ pbe

Step 2 : Import the PBEngine Library project within Flex/Flash Builder.

Open up Flex Builder (or Flash Builder), right click in the Flex Navigator and choose Import. (You can also use File > Import > Other).
Import Project

Open up the “General” folder and choose “Existing Projects into Workspace” and click “Next”.
002_existing

Click the “Browse” button next to “Select root directory”.
003_rootDir

In revision 600 of the PushButton Engine I added “FB3″ and “FB4″ directories underneath “trunk/development”. These directories have a Flex Library project skeleton within them that can be imported directly into Flex Builder.

If you are using Flex Builder 3, use the FB3 directory, and if you’re using Flash Builder 4, use the FB4 directory.
004_selectFB3

Click Finish.
005_selectedPBEngine

You will see a Flex Library project in the Flex Navigator now. You will also have an error, don’t worry, we’ll fix that in the next step.

Step 3 : Setup the a Linked Resource for PBE

So here is the error that you will see:
configuration variable ‘compiler.source-path’ value contains unknown token ‘PBE’
006_error

The project skeleton uses something called a “Linked Resource”, so that it can find the PushButton Engine source files. To set this Linked Resource, you do the following:

Open up Flex Builder’s preferences.
007_preferences

Under General > Workspace > Linked Resources… Click “New…”
008_linkedResources

Click on the “Folder…” button and navigate to the PushButton Engine “trunk” folder, “/pbe/trunk” (C:/pbe/trunk on Windows).
009_selectFolder

Hit “OK” and you should see PBE listed in the Linked Resources now.
010_PBEResource

Clean the project to incorporate and rebuild all of the changes.
011_cleanProject

If you see PBEngine.swc underneath the bin folder, you are good to go! Nice work!
012_projectWSource

:: UPDATE ::

There have been file renames and other changes in the PushButton engine since this post. If your SWC is failing to build do the following.

In the Flex Navigator, right click on the PBEngine Flex Library project. Click Properties. Go to “Flex Build Library Path”, under “Classes” uncheck [source path] src and recheck it. If you are using Flash Builder 4, you can simply select “Include all classes from all source paths”. Any other questions… post a comment and I’ll answer them.

Step 4 : Create your game!

For this example I’m going to create a VERY simple Hello World game to show that we have everything working correctly.

Right-click in Flex Navigator and choose “New” > “ActionScript Project”.

Give it a name of “HelloGame”, and click Finish.
013_createASOnly

Now, to use the PBEngine Library within our HelloGame project, we need to create a link between the two.

To do this, right click on the “HelloGame” project and choose “Properties”.
014_helloProperties

Choose “ActionScript Build Path” from the list, and then click on “Add Project…”
015_AddProject

You should see “PBEngine” in the list.

If you don’t see PBEngine, or you get a message that tells you, “There are no Flex Library projects in your workspace”, make sure that a) you have created a PBEngine Library by following the previous steps and b) the project is not closed.
016_PBEngine

Select “PBEngine” and click “OK”. You will now see PBEngine listed in the Build path libraries box.
017_withLibrary

Now that the two projects are linked, you can start using classes right out of the PushButton Engine. Code completion works, and everything compiles. Woot!
018_Intellisense

Great, now let’s write our impressive Hello World game.

Here is the source:

package {
	import com.pblabs.engine.PBE;
	import com.pblabs.engine.debug.Logger;
 
	import flash.display.Sprite;
 
	public class HelloGame extends Sprite
	{
		public function HelloGame()
		{
			PBE.startup(this);
			Logger.print(this, "Hello Nate!");
		}
	}
}

Run or Debug the game. At first you will see a blank screen, that is expected… Press the ~ (tilde or `) key, and the PushButton Console should come up.

The console has some commands by default: help, version, showFps and verbose (1 || 2)
020_console

You can add your own custom commands to the console to assist you while developing your games… but that is a post for another time.

Any questions, be sure to hit us up over on the PushButton Engine Forums or in the freenode IRC channel: #pbengine.

Getting Dirty with the Flex SDK – Slides and Recording

5

I’d like to thank everyone who attended my TechWed presentation yesterday. We had around 85 people in attendance! Thanks to Stacy Sison for convincing me that I should present.

I will be giving this presentation again tonight at the Seattle Flex User Group, so if you are in Seattle… show up. We’ll have a bit more time for questions at tonight’s presentation.

:: PRESENTATION MATERIALS ::

Slides
TechWed Presentation
FlexMeetup.com Presentation

Punking Doug McCune

4

[Disclaimer]
Identites have been protected in this blog post by means of Doug’s Safe Sexting application. Any resemblance to persons living or dead should be obvious to them. (You know who you are)
[/Disclaimer]

So a fortnight (I wait two weeks to tell anyone anything… so I can use the word fortnight) ago, I had the opportunity, nay the privilege, to attend Doug McCune’s “Cool Shit” session at 360|Flex. As many of you may heard, read or watched, there was an… incident that occurred during Doug’s session.

Apparently, I have been thrown under the bus as the co-conspirator of said incident.

So let us take a journey… starting two nights prior to Doug’s session.

Monday Night

A couple friends and I were hanging around the hotel after partying at the Rock Bottom. We weren’t ready to call it a night. So we decided to see what else Indianapolis could offer us and we hit the streets. We quickly found ourselves at Monument Circle. That’s when one of my colleagues remembered that there was some sort of crazy bowling in Indy.

We had no idea where to go until we ran into Tanner (a horse) and Sky (a man… I think). He gave us directions to duckpin bowling. However, It was too far to walk, so we went back to the hotel where we ran into some other “accomplices”. After a few minutes of trying to figure out what time the duckpin bowling alley closed, one of the Crowne Plaza employees informed us that Jillians had bowling.

We headed over there with the crew. Unfortunately, the bowling alley was full. Undeterred, we went down to the video arcade. We enjoyed Hyper Bowling, Super Shot Deluxe Basketball and Ski Ball. The party came crashing down when a Jillians employee informed us that they will be closing in 30 minutes. With thousands of credits still left on our cards, we decided to see how many tickets we could win before they kicked us to the curb.

So I went to the game that gave us the greatest chance of winning loads of tickets… I’m not sure what it’s called. It’s the dome game with the circle of lights… Well wouldn’t you know it… the first time I hit the button… I hit the jackpot of 375 tickets! I have ninja-like reflexes.

Here is a picture of one of my accomplices with a handful of tickets.

We were able to accrue around 645 tickets in less than 30 minutes, but what do you do with all of those tickets? Well, we decided to cash them out in bouncy balls… all bouncy balls (with the exception of one paratrooper).

Tuesday Night

After a great day at 360|Flex Indy. A group of us decided to try our luck at the bowling alley.

While bowling, we discussed the countless applications of 42 multi-colored, rubber bouncy balls.

Someone mentioned that Doug McCune had tweeted about shaving his chest for his session, and the ideas started flowing. Now as much as I’d love to claim that the brilliant idea of throwing bouncy balls at Doug during his session was all mine… it was truly a group effort.

Wednesday Morning

Wednesday morning rolled around, and I loaded the cup of bouncy balls into my backpack and made my way to the final keynote. We knew Doug’s session would be crowded, so we were sure to sit near the stairs that led up to the room where his session would be held.

After the keynote was finished, we rushed up the stairs to Doug’s room. It was already packed… people had camped out up there during the keynote.

Luckily, I was able to grab a seat in the front row. As soon as I sat down, I noticed that Doug had left the room, probably to refill his glass with water… or vodka. I quickly grabbed a handful of bouncy balls and went to work. Handing them out to the first few rows and giving them the simple instructions of.. “When Doug takes his shirt off, throw the ball at him”.

I wasn’t able to hand out all of the bouncy balls, as Doug re-entered the room and made his way to the front.

Then as the story goes… Doug took his shirt off…

There was a visual hesitation the moment Doug took off his shirt. Nobody was going to throw their ball… and it wasn’t me… but to whomever threw their ball first… bravo!

And finally… the video speaks for itself…

And there you have it… consider yourself in the know.

I also wanted to thank Doug for being such a great sport about the whole thing. You my friend are a rockstar… Keep up the great work!

The Flash Builder 4 and Flash Catalyst Betas Are Out!!

0

So I was going to write a great long blog post about how the Flash Catalyst and Flash Builder 4 betas are out… and resources you can use get started… But Ryan Stewart and Serge Jespers have both written amazing posts already. So all of you should do as I’m doing, and go download the betas and start finding bugs!!

I do give huge props to Adobe for releasing both of these betas in “June” as they said they would. To be quite honest, it’s still technically May here in Seattle. Great work Adobe, another job well done. *slow clap*

:: UPDATE ::

Also, major props to the Flex SDK team for getting the beta out even with all of the Fx prefix madness that has been going on.

:: UPDATE 2 ::

Adobe Developer Connection has posted a list of informational links about Flash Builder 4, Flex 4 SDK and Flash Catalyst. Check it out!

Tip of the Day – How to create a prompt field on your mx:ComboBox

2

For a long time I’ve been doing things like this within Flex.

[Bindable] private var _skills:Array = 
[
	{label: "---", id: -1},
	{label: "1 - Newbie", id: 1},
	{label: "2 - Some Experience", id: 2},
	{label: "3 - Expert", id: 3},
	{label: "4 - I'm a baller", id: 4}
];

And then binding this data provider to a ComboBox…

<mx:ComboBox id="skillsCB" dataProvider="{_skills}" />

Well it turns out there is a much easier way of doing this that I never knew of until today. ComboBox has a “prompt” attribute that you can set. It’s so easy…

<mx:ComboBox id="skillsCB" dataProvider="{_skills}" prompt="---" />

I told you it was easy. Can’t believe I never noticed it before.

Are you attending the Flex SDK BugQuash? You should be!

2

Between my full-time job, planning the Flex SDK BugQuash, and trying to install Flash Media Server on 64-bit Ubuntu Linux (a real nightmare I tell you), I’ve just been utterly swamped and ultimately have been neglecting my blog. However, I feel compelled to write this blog post letting you know what you are missing if you decide not to attend the open source Flex SDK BugQuash.

What is this BugQuash thing about?

In a nutshell, the Flex SDK BugQuash is a FREE event that is being hosted by Adobe on March 28th in Seattle, WA. Developers will be attending in-person as well as online using Adobe Connect. The goal of the event is to fix, or “quash”, as many bugs in the Flex SDK in 10 hours as humanly possible. There are currently over 200 people registered to attend this event!


Want this for your site?

What if I’m not good enough?

Quite a few people have asked this question.

This first BugQuash will have more of a focus on learning. The goal is for everyone in the community to know how to make changes to the Flex SDK, submit patches and ultimately make a better SDK for all of us to work with. Right now there are only a handful of people that are actually submitting patches, which is why we need to focus on getting everyone up to speed on HOW to fix the bugs in the Flex SDK.

You’re certainly not going to be the only one who feels like they have less than expert skills at the event. Much of this event is designed for you, to teach you these skills.

You’ll be able shadow teams working on problems and have your questions answered. If you don’t walk away from this event with a deeper knowledge of the Flex SDK (unless of course you’re already baller status), then I haven’t done my job properly.

So why attend this event in person?

  • Snacks – M&Ms, Mixed nuts, Goldfish, gummy fruit snacks (just to name a few).
  • Free Food – Lunch and Dinner (I’ve heard rumors of Jimmy Johns).
  • Free Drinks – Soda, water and yes… energy drinks!
  • Guitar Hero World Tour & Rock Band 2 – yes, including the microphone and drums.
  • Face to face time with other developers.
  • Music – from our very own DJ Natey Beck.

I can’t make it to Seattle, what’s this remote experience?

This is a world-wide event (shout-out to my friends in Ukraine: JabbyPanda & FlashRipper), with 3/4′s of the attendees being remote. We have put many hours in to making the remote experience a worthwhile experience. Some user groups in other cities are meeting up to attend remotely, check with your local user group for more details.

Trust me, you won’t want to miss it.

Free Stuff!

Attendees will be eligible to win prizes and Adobe software. Both remote and in-person attendees are eligible to win said prizes. Let me repeat that:

BOTH REMOTE AND IN-PERSON ATTENDEES ARE ELIGIBLE TO WIN!

Work together and make friends.

This event is meant to be social. Working together to complete a common task is an excellent way to get to know someone. We’re going to be breaking apart into teams (both remotely and in person) to tackle the bugs together.

We also have a system in place for everyone to communicate with each other. That way if you run into a problem with… let’s say, regular expressions… you can ask for help with it, and find someone who can help you.

The Adobe Flex SDK Team will be attending.

Members of the Adobe Flex SDK Team will be attending and presenting throughout the day. Which is really neat to learn from the people who actually wrote the SDK. We have a room dedicated to “Learning Sessions”, where the Flex SDK Team and other folks will be available online to answer particularly tough questions.

Okay, you’ve convinced me… where do I sign up?

Go to the BugQuash website and Register Now.

So now that I’ve registered, what can I do to get ready?

How can I help?

Go to Top