Tuesday, November 24, 2009

Case 09

I'll sum up this case in one post since it is a pretty simple one. And the idea here is to add sound to the game.

This is a pretty straightforward process. You just find the music and sounds you want and import it to your flash file library. Then you prep the sounds to get exported to ActionScript. Coding-wise you just add media at the top like this import flash.meda.Sound; and import.media.SoundChannel; and finally import flash.media.SoundTransform; (for cleaness sake I just added import flash.media.*; the star just means that you import everything from media).
Now, I'll first tell you what these three thing do. Basically it makes it possible to use sounds. The first one enables the soundfiles you want to use, the second one is used to layer the sounds. For instance, you want to have a soundchannel for the themesong and other ingame effects. Then you can use a second channel for the soundeffects you character make. And thid for you enemies.
The last thing you imported was the transform functions wich makes it possible to transform the sounds, like turning the volume up and down. This especially practical when you have soundchannels. Let's say that you really can't hear the soundeffects you'r character makes while ingame due to the theme music. Then you can simply increase the volume on the character soundchannel. And voilá, you fixed the problem, nice and easy.

Let's get back to the code. After importing the media, I added variables for each sound, channel and transform.
Then you just add the variable where you want the sound to appear. Like adding the jump sound in the function that makes you character jump. The themesong at the beginning of the constructor so it starts playing when the scene is created.

This was in my opinion a pretty simple case, and was solved fast without any major problems. I would add a preview, but since I'm revamping the game, things don't quite work as they're supposed to. You'll have wait for the final game to be finished. I wouln't hold my breath though. Even though I'm pretty sure I'm going to have it finished by a week.

Thanks for reading! :)

No comments:

Post a Comment