This week I turned in my first major flash game. It was tough, but very fun and rewarding upon completion. I had plenty of “fiero” moments!
I named my game “Finding Bonga,” and the objective was to help Binky (Bonga’s Friend) find Bonga by completing to simple task. The first was a simple egg catching game; the second was a shooting game. Naturally I ran into some problems trying to create this game, but I learn a ton of new things, one being the implementation of music and sound effects.
In previous projects, I entered music directly on the timeline. This was not efficient because there was no way to control the music. I couldn’t get it to start when I wanted it to, or stop when I needed it to. It just played automatically after exporting the file as an swf file. So, on this project, I wanted to have more control over the sounds and music.
In the first scene, Binky has to collect eggs in a basket falling from chickens. Every time the egg hit the basket, I wanted to play a coin sound effect. Similarly, a buzz sound effect when the activation of the sound effect was included in the hit test.
First I imported the individual sounds into my library as an mp3 file; the background music, the buzz sound, and the coin sound. In the library, I double-clicked the sound icon next time the file that directed me to the sound properties window. On the ActionScript tab I checked the “Export for ActionScript tab.” Under ”class” I need the file what I wanted it to be…for example, I named the buzz sound “wrong.”
The next part involved my ActionScript. I had to declare a variable for each sound. I did it at the start of my ActionScript. It looked like this:
var mySound: Sound = new ding();
var mySound2: Sound = new backgroundmusic();
var mySound3: Sound = new wrong();
var mySound5: Sound = new congrats();
Each sound had it’s own variable name (mySound), and each sound was commanded to activate at specific moments. For example, when the user clicks the startgame2 button, mySound2, the background music, starts playing:
For the sound effects, they were activated in the hit test:
score= score + 1;
score_text.text = String(score);
Everytime the hit test occurred and the egg hit the circle (which symbolized Bonga catching a good or bad egg) the sound effect plays.
This is just one of the new things I learned while doing this project. In my next post I talk about something else I learned, looping character movement.