Game Development Reference
In-Depth Information
I used SFXR to create the sounds in Table 4-1 for Flak Cannon. It took me roughly 10 minutes to
make all of these. Even if you are working in a professional studio environment, this can still be
an invaluable tool for prototyping a game with placeholder sound effects.
Table 4-1. Flak Cannon Sounds and Their Flash Library Class Names
Library Class Name
Play Sound When
SoundBonus
The player shoots down a bonus plane and earns extra shots.
SoundBonusShip
The player earns an extra ship.
SoundExplodePlane
An enemy plane is shot down.
SoundExplodeFlak
A flak shell explodes.
SoundExplodeShip
A ship is destroyed.
SoundNoShots
The player has run out of shots.
SoundShoot
The player shoots the flak cannon.
Library differences in Flash and Flash
Develop/Flex
Now that we have created graphics and sound files and put them into the library, you will need to
reference them properly depending on what you are using to make our game: Flash or Flash
Develop/Flex. Luckily, the library assets remain the same for both programming methods, but
accessing them in the game classes is different. When you are working with sounds and graphics
embedded in a game project, there are some minor differences between the Flash IDE and Flex
framework methods of instantiating these assets.
For this game, we have started with the Flash IDE version with all of the necessary sounds and
graphic elements embedded in the FLA library. To use those in the Flex version, we have to
simply publish the SWF (with a new name, flackassets.swf ) and place it an assets folder in the
src directory of our Flash Develop/Flex project ( src/com/efg/games/flakcannon/assets ). This
way, we can make use of the existing library of assets and not have to create a folder full of the
originals. This concept is especially important for sounds other than MP3 files, as you cannot
embed them directly. For instance, you cannot add WAV files into a Flex application unless they
are part of a SWF file library.
You might now ask us, “Why is the /assets folder is inside the package class source location in
Flex?” The reason is simple. If we had in the root /assets folder of the Flex projects, the
references would look like this ../../../../assets/flackassets.swf because of how deep the
code is inside the package directory. By storing the assets locally, the references will look much
cleaner. If this bothers you, you can move the assets and adjust your code accordingly.
Search WWH ::




Custom Search