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.








9 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.
Post a Comment
Welcome to ilike2flash! If you like this post you can subscribe here to get updates via RSS or opt to have them sent directly to your inbox .
I appreciate your feedback, so please feel free to comment.