Click game part 2
This Flash tutorial is a continuation of the clicking game tutorial. This time I will add addition features to the game. The final score will be displayed in a separate scene with an appropriate message. An optional restart button will also be included.
Before you attempt this tutorial be sure to have completed the previous part. I have used an Action script 2.0 file for this tutorial.
Clicking game part 2
Step 1
On the timeline right click on the 1st frame of the actions layer and select Actions. And add the additional code below, most of it should look familiar.
ball._visible = false;
total = 0;
hits = 0;
end = 20;
ball.btn.onPress = function() {
_root.hits++;
ball._visible = true;
};
seeBall = function () {
if (total < end){
ball._x = Math.random()*300;
ball._y = Math.random()*300;
ball._visible = true;
total++;
} else {
ball._visible = false;
gotoAndStop("Scene 2", 1);
clearInterval(doball);
}
};
doball = setInterval(seeBall, 800);
Step 2
Select shift + F2 to open up the scene panel. And click the little black plus sign to add a new scene. You should notice a new scene appear on the scene panel and the stage should now be blank. 
Step 3
Now select the static text tool (T) and type your message on the stage. I type the following below, but you can type whatever you want. 
And then select the dynamic text tool and drag a small box below your text. This dynamic text box will display your final score.
Step 4
Using the selection tool (V) select the dynamic text box on the stage. And in the properties at the bottom of the screen, type “hits” for the variable. This allows you to link the hits acquired from the game to the dynamic text box.
Step 5 - Restart button
Now create your restart button on the stage. If you don’t know how to create a button, checkout the basic buttons tutorial. I made a simple circle text button, but you can create whatever kind of button you wish.
Now convert your button into a symbol by pressing F8. Choose an appropriate name, check button and click ok.
Right click on your button and select Actions and enter the following code:
on (release){
gotoAndStop("Scene 1" ,1);
}
Step 6
Test your movie clip Ctrl + enter.
You should now have a clicking game. I have also included a custom cursor.



19 comments:
nice game i love it
oh i love this game, but I want to do when I click the ball, it will burn or something like that before it becomes invisible. can you tell me how I do that ??? (sorry for my bad English :)
@Hai you create a new keyframe inside the ball movieclip and add your desired effect there.
hei i can't seem to play this game after i followed tutorial 2.. but i could play when i finished tutorial part 1..
i now see the scene 2 keeps poping up only..
what am i supposed to do.. ??
@Mr lazy boy
I think you need to put a "stop()" in scene 1.
hi where do i put "stop()" in scene 1
@yogi
The first frame on the timeline.
I got a final score of 53. Are you supposed to be able to click it multiple times each time the ball shows up?
@Anonymous
Yes, you can click as many times as you wish.
could u please also explain on how to make the "start" menu in the beginning?
aniway, do u know how to transfer this game into as3 automatically? because i wangt to know the different between those 2 scriptings...
thanks
@S3146458
Checkout the code for the Actionscript 3 version here
I too would like to know how to create the 'START' frame for this tutorial.
macytraine
@macytraine
You basically need to insert a new scene and place a stop() method in the timeline. Then create your button on the stage and add the gotoAndStop() method like below to your button.
on (release){
gotoAndStop("Scene 2" ,1);
}
Hi
I have followed the steps and after pt 1 the game wroked fine but after pt 2 when i press CTRL + ENTER the two screens flash up one after the other really fast over and over again. I have tried adding a stop() to the first one at the bottom of the actions but when i test it it just stops on that screen when the game has finished and doesn't go onto the "congratulations" page.
Please help!!
@Pedropan
You should add the stop() method before all the other Actionscript code. i.e at the top. And make sure when you insert a new scene, the name is called "Scene 2".
Can you tell me why on the second time round the ball moves faster?
@Jessica
It seems fine to me.
Please, could you be more specific in this second part of the tutorial?
@nico
What part are you having problems with?
Post a Comment