Designing the structure of a Flash game
One of the most interesting things about internet publishing is that you can receive feedback almost in real time.
For this reason, it's very important to read every comment and above all negative comments.
When I released Tileball, I received some negative comments about the title screen. That's right: I focused on the game and I did not care about a title screen, or a proper "congratulations" screen if a player manages to beat all levels.
When I was a kid, the "end screen" was very important. I remember myself playing some "not so good" games just to see how will they thank me for playing in their congratulations screen.
Too bad I forgot old times and released a game with such a lame intro and end screen.
I think it happened because I coded a lot of actionscript and did not want to nest more code to manage different game status such as info screen, welcome screen, and so on.
So I decided to make a Flash movie with the very basic structure every game should have.
This structure is made of:
* A "title" movieclip
* An "info" movieclip
* The game itself
* A "game over" movieclip
* A "congratulations" movieclip
Let's see how do they work:
Title movieclip: it's the first thing the player sees when the movie has loaded. It should have some appeal, just to tell players "hey, I'm a good game, give me a try"
Info movieclip: here you will put all instructions to play the game, or more information about the game.
The game itself: the most important thing, don't forget it...
Game over movieclip: The screen the player will see once he dies and runs out of all lives, or runs out of time, or simply does not beat all levels. Here you can show highscores.
Congratulations movieclip: This is the screen the player will see should he ever complete the game. Congratulations, blah blah blah, show the highscores and play again
It's very important that you include at least these sections, or your game will have an "home made" feeling. Now, we all know your game is home made, but we don't want our game to seem "home made when sit in the bathroom".
Come on, and let's see how did I arrange actionscript and movieclips to have a game with the above features.
First, the actionscript:
-
current_status = "title";
-
play_game(current_status);
-
function play_game(game_status) {
-
switch (game_status) {
-
case "title" :
-
_root.attachMovie("title_screen", "title_screen", 1);
-
title_screen.instructions_button.onRelease = function() {
-
play_game("instructions");
-
};
-
title_screen.play_button.onRelease = function() {
-
play_game("play");
-
};
-
break;
-
case "instructions" :
-
_root.attachMovie("game_info", "game_info", 1);
-
game_info.back_button.onRelease = function() {
-
play_game("title");
-
};
-
game_info.play_button.onRelease = function() {
-
play_game("play");
-
};
-
break;
-
case "play" :
-
_root.attachMovie("game_itself", "game_itself", 1);
-
game_itself.game_over_button.onRelease = function() {
-
play_game("game_over");
-
};
-
game_itself.win_button.onRelease = function() {
-
play_game("game_won");
-
};
-
break;
-
case "game_over" :
-
_root.attachMovie("game_over", "game_over", 1);
-
game_over.back_button.onRelease = function() {
-
play_game("title");
-
};
-
game_over.play_button.onRelease = function() {
-
play_game("play");
-
};
-
break;
-
case "game_won" :
-
_root.attachMovie("end_game", "end_game", 1);
-
end_game.back_button.onRelease = function() {
-
play_game("title");
-
};
-
end_game.play_button.onRelease = function() {
-
play_game("play");
-
};
-
break;
-
}
-
}
Line 1: Defining a variable containing the current status of the game. It's set to title because when you start playing, the game must show the title screen
Line 2: Calling the main function, play_game, passing the current game status
Line 3: Beginning of the main function
Line 4: Performing a switch to the game_status variable: for each game status, I'll execute proper actionscript
Line 5: Beginning of the actions to perform if the game status is set to title
Line 6: Attaching the movie with the title screen
Lines 7-9: Triggering a button that will lead to the instructions screen. Notice that when I release the button, I call the same play_game function with the game_status variable set to instructions
Lines 10-12: Same thing with the play button... this time the game_status takes the play value
Line 14: Beginning of the actions to perform if the game status is set to instructions
Line 15: Attaching the movie with the instructions
Lines 16-18: Triggering a back button that will take us to the title screen again
Lines 19-21: Triggering the play button as seen in lines 10-12
As you can see on further lines, the script remains almost the same for all game screens. Obviously the game itself is very lame (you win pressing a button and lose pressing the other button) and the whole presentation sucks, but this is the skeleton of the game and you should add your own gamescript (or more game screens) easily.
Look at the "game"...
... a very simple one but it has all the navigation options required.
Now you have no excuses to refuse making a good title screen.
And talking about title screens...

Tell me what do you think about this post. I'll write better and better entries.
They can be easily customized to meet the unique requirements of your project.
25 Responses to “Designing the structure of a Flash game”
Leave a Reply

Wow, the Tileball 2 title is really good!
I liked your description
“home made when sit in the bathroom”
;)
Yeah. Nice tutorial :)
nice
Where did you downloaded the font from? Dafont?
very nice title screen =) im looking forward to seeing tileball 2 now it is getting a good and proper looking game structure :).
i think tileball set itself apart from other games that were made with your engine through your good level design.
people who took the engine and built levels with it, only made places not wider then 1 block, making everything very linear. you on the other hand have made a level design with a lot more posibilities.
i think tileball 2 could be a huge game if you do everything (including sound and music) right and im looking forward to seeing it
greets,
styxtwo
I usually use scenes to manage load/game/end part of the game. This save a lot of time working with the actionscript.
This is a simple explanation of how I do it.
load scene: put all stuff that happen/appear before the actual game, such as mochibot, mochiads, sponsor logo, my logo, game title screen, instructions.
game scene: the game
end scene: all stuff that happen after the game.
The advantage of using this method is, you don’t have to worry about removing the game objects from the screen because you just jump away from that scene to another.
Hope this helps!
Yeah, these are very important. Especially a good menu. Most people close a game within 10 seconds if the intro is bad.
Though you still made a mountain out of a mole hill on your code. Couldn’t you just have a few buttons and more than 1 frame?
when you can make a whole game in 1 frame, you know you are a good programmer ;)
I disagree. I could make my games in one frame, but I see no need to. Plus all this can make the game slower, and it makes it very messy and hard to work with.
having one frame means people can’t cheat!
thanks for the tutorial, i was stuck on making a menu.
Merry christmas emanuele ( i won’t be able to visit anytime soon, so i’ll just say it now!)
Or to stop people cheating you could do your whole game in a movieclip. if you want help with design you should read this. http://mochiland.com/articles/ui-design-for-game-menus
Slick! :D
I’ll now try and make a mint menu for my games!
David, you do realise you can change the right click menu anyways?
Sorry if I seem all negative guys. I’ll try and comment on good stuff in the future. :(
Shiv: yes, it’s the Space Age font you can find on dafont
http://www.dafont.com/space-age.font
I tried using a button to go to the next frame.
Code:
on (release){
gotoAndPlay(2);
}
but it doesn’t work.
CAn somebody help me?
For the discussion:
When I code games, I start coding the engine in the first frame. When it’s done, I put it into another frame and make the menu, and so on.
I agree with styxtwo: You need to make the game in one frame, for secure, but, therefore you can still split the menu, and the “congratulations board” apart. So it don’t get messed up. So you both are right and wrong! - My oppinion.
Corey:
The code is alright, but are you sure that you converted the button correctly, and not to a movie clip? If - then click on the button, and insert the actionscript. Don’t put it in the frame!
David, you can lock the right-click menu in flash to prevent people cheating
Corey, I think you should use _root.gotoAndPlay(2) instead?
Anyway, I still prefer using scenes to separate the game from other menus.
Here I want to share with you my new game: Colorz
http://www.hallpass.com/media/colorz.html
yea kevin is right i only found this yesterday:
put this code in _root. of the first frame of your game:
function doSomething() {
}
MENU = new ContextMenu();
MENU.hideBuiltInItems();
MENU.customItems.push(Functioned);
_root.menu = MENU;
it works for my games =)
ps: i didn’t make this code, i got it off the web somewhere (don’t remember the site sorry:()
That sounds good :-) - Problem solved!
Kevin,
Go 2 this site:
http://www.developertutorials.com/tutorials/flash/flash-customized-right-click-050321/page1.html
Its a tut on how to make right click menus
Also, Emanuele, why dont you build levels on different frames, and use this to prevent ppl from cheating.
Id like to make a fake Menu Item that says Forward, but actually takes them to the first level, or game over.
Srry, not kevin, Frederick
I am making the entire game on one frame for tutorial pourposes… it would be harder to explain a script frame/scene by frame/scene.
The fake “Forward” button is really evil…
Oh yeah! :-) I like to see that rightclick menu in use!!..
Do you have to add the button objects inside the movie clip, then do you export them for actionscript with the linkage thing ?
There is one problem with the above code: All lines attach a new movieclip to the _root variable. But it doesn’t remove them. So for each time you play the game, it will hog more memory, possibly making your great game unplayable suddenly