Sunday, 30 January 2011

Coding For my game

I have used many different event listeners and functions for my game I will be putting the code here with a description beside it. I had to create loads of variables as well for different objects. The character's have instance names within them to get the objects moving and doing the items you want to do.

This is the first part of my script:

The first line stops the frames from playing, then the (var snd line) creates a variable for a new sound.
The (snd.load line) adds the sound to Flash all you have to do is keep the sound file in the same folder as your Flash file.  (Var channel) adds a sound channel for the game to see if it is playing and capture the sound. (Then channel = snd.play()) this tells flash to play the sound in the file, and mine is a radio mp3 so i called it radio.mp3


The next part highlighted in blue is how to add a button to the game.
so...... the first line adds and event listener to check for a mouse, click and we give the event listener the name of startClicked.
 The startClicked adds a name for the event listener, in the next line we create a function for the start button and it is an event. And then the gotoAndPlay(2) tells the script to go to the next frame.
So overall the bottom part of the script looks for when you press the button and then sends your game to the instruction page.

No comments:

Post a Comment