Game Development Reference
In-Depth Information
SDK version of the game code and the Flash IDE game code, because the two technologies
handle embedding assets in slightly different ways. For example, when you embed a PNG bitmap
file in the Flash IDE library, the base class it is given is BitmapData . But when you embed the
same asset in a Flex project, the base class is an instance of BitmapAsset (which is a child of
Bitmap ). So, we will need the code base for the two different applications to be slightly different.
Let's start there.
Organizing your code
If you are using the Flex SDK, you will want to make sure that you are placing all the raw assets
(only the tank_sheet.png file so far) are in the /assets folder. We have not created this folder yet.
So let's do it now. Let's revisit those locations in the package structure:
[source]
[projects]
[notanks]
[flexSDK]
[assets]
tank_sheet.png
[bin]
[obj]
[lib]
[src]
[com]
[efg]
[games]
[notanks]
GameDemo.as
Notice that we have created a new folder inside the /source/projects/flexSDK folder called assets .
This folder is at the same level as the /bin/ , /obj/ , /lib/ , and /src/ folders for our Flex SDK
project. We have also placed the tank_sheet.png file in the assets folder. The code for our game
will need to find this folder to embed the image during compilation so the location is very important.
If you are using the Flash IDE we will simply embed the tank_sheet.png file in the FLA library.
We will do this in the next section.
Adding the Library.as class for Flex projects only
The Flash IDE project will not need the Library.as class. The standard method for embedding
assets in the Flash IDE (up until Flash CS4) was to embed them in the FLA library at design time.
In Flex SDK projects, there is no library to embed assets at design time. For this reason, we will
need to embed our assets at compile time for Flex SDK projects. This is also possible with Flash
CS4 (and beyond) so if you are using a Flash IDE version more modern than CS3, you can also
make use of the Libray.as class, we will create for our Flex SDK projects.
The theory behind the Library.as class is this: we want to mimic as closely as possible the Flash
IDE style library with only Flex style embeds. Our library will be made up of static constant
variable values that represent the embedded assets. You should create and save the Library.as
class code in the same project folder as the GameDemo.as class.
Here's how the Libray.as file fits into the No Tanks! package structure:
/source/projects/notanks/flexSDK/src/com/efg/games/notanks/Library.as
Search WWH ::




Custom Search