Flash game creation tutorial – part 3

March 14th update: part 5.3 released.
March 3rd update: part 5.2 released.
February 9th update: part 5.1 released.
December 31st update: 5th part released.
December 23rd update: 4th part released.

Here we go with the 3rd step.

Remember to read 1st and 2nd part if you are new to this tutorial, and let’s go.

We left our hero colleting coins, so next step will be…

The score

Scoring system consist in a variable set to 0 (zero) when the game starts and some events that may increase/decrease the score.

In this case, you get 1 point when you collect a coin, and lose 2 points when you crash into a wall.

Hall I have to do is initializing a variable in the root with a single action

1
score = 0;

And then in the hero movieclip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
onClipEvent (load) {
	yspeed = 0;
	xspeed = 0;
	wind = 0.00;
	power = 0.65;
	gravity = 0.1;
	upconstant = 0.75;
	friction = 0.99;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.LEFT)) {
		xspeed = xspeed-power;
	}
	if (Key.isDown(Key.RIGHT)) {
		xspeed = xspeed+power;
	}
	if (Key.isDown(Key.UP)) {
		yspeed = yspeed-power*upconstant;
	}
	if (Key.isDown(Key.DOWN)) {
		yspeed = yspeed+power*upconstant;
	}
	xspeed = (xspeed+wind)*friction;
	yspeed = yspeed+gravity;
	_y = _y+yspeed;
	_x = _x+xspeed;
	_rotation = _rotation+xspeed;
	if (_root.wall.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 120;
		_y = 120;
		_root.score -=2;
	}
	if (_root.coin.hitTest(this.hero_hit)) {
		_root.coin._x = Math.random()*400+50;
		_root.score ++;
	}
}

Look at lines 33 and 37… as said, you get one point when you collect a coin and lose 2 points when you hit the wall.
A dynamic text in the main scene displays the score.

Sooooo easy… now let me introduce you the main event for this tutorial… the environment…

We can have different kinds of environment… let’s start with the easiest.

The killing fixed environment

The killing fixed environment is a deadly part of the stage that does not move, such as a spike.

So I created a new movieclip called environment and instanced as environment and placed in the stage.
You choose how to detect the collision, with the center of the hero or with the hero_hit shape (time to read part 2 if you do not understand what I am talking about).

Just remember you game does not have to be too easy or too hard.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
onClipEvent (load) {
	yspeed = 0;
	xspeed = 0;
	wind = 0.00;
	power = 0.65;
	gravity = 0.1;
	upconstant = 0.75;
	friction = 0.99;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.LEFT)) {
		xspeed = xspeed-power;
	}
	if (Key.isDown(Key.RIGHT)) {
		xspeed = xspeed+power;
	}
	if (Key.isDown(Key.UP)) {
		yspeed = yspeed-power*upconstant;
	}
	if (Key.isDown(Key.DOWN)) {
		yspeed = yspeed+power*upconstant;
	}
	xspeed = (xspeed+wind)*friction;
	yspeed = yspeed+gravity;
	_y = _y+yspeed;
	_x = _x+xspeed;
	_rotation = _rotation+xspeed;
	if (_root.wall.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 50;
		_y = 50;
	}
	if (_root.environment.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 50;
		_y = 50;
	}
}

Lines 34-39 do the routine that checks collision between the hero and the environment

This is useful if you want to place objects on the stage that may kill the hero.

Sometimes, the environment should move.

The killing tweened environment

I am calling “tweened environment” an object that always moves along a path… such as a sliding wall or something similar.

The actionscript, obviously, is the same as above, the only change is to the environment object, that now has a tweening motion. You’ll see it better when you will download the sources, at the end of this tutorial.

The only thing I want you to know is: for a better result, the number of pixels the environment moves at every frame should be an integer. I mean that if you want to move your environment by 150 pixels, be sure that dividing the pixels for the numbers of frames you have an integer number.
In my case, I move the environment by 150 pixels in 75 frames… 150/75 = 2 (integer) pixels/frame.
It’s not a mandatory rule, and in most cases you will experience it is impossible to achieve such integer numbers, while you can do it, well, do it.

Sometimes we want the hero to interact with environment, so I will explain howo to get…

The triggered environment

Let’s suppose to have a wall that moves very fast… making our life so hard… we should let the player decide to cross the wall, risking his life, or turn off the “engine” that moves the wall, for example pushing a button or pulling a lever.

In this new movie I created a new object named as trigger and instanced as trig, with the shape of a lever.

Then I added some actionscript to the environment, that is no longer tweened.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
onClipEvent (load) {
	dir = 4;
	moving = 1;
}
onClipEvent (enterFrame) {
	if (moving) {
		_y += dir;
		if (_y>300) {
			dir = -4;
		}
		if (_y<50) {
			dir = 4;
		}
	}
}

This is a very simple movement routine… I will explain more complex routines later in the tutorial, but at the moment I only want a wall to cross the stage up and down, and the hero to get the trigger to stop it.

The script is very simple, just take a look at the moving variable. You can see that the environment will move by 4 pixels (integer…) upwards or downwards as long as the moving variable is set to 1.

How can we stop it?

With lines 40-43 of the hero’s actionscript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
onClipEvent (load) {
	yspeed = 0;
	xspeed = 0;
	wind = 0.00;
	power = 0.65;
	gravity = 0.1;
	upconstant = 0.75;
	friction = 0.99;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.LEFT)) {
		xspeed = xspeed-power;
	}
	if (Key.isDown(Key.RIGHT)) {
		xspeed = xspeed+power;
	}
	if (Key.isDown(Key.UP)) {
		yspeed = yspeed-power*upconstant;
	}
	if (Key.isDown(Key.DOWN)) {
		yspeed = yspeed+power*upconstant;
	}
	xspeed = (xspeed+wind)*friction;
	yspeed = yspeed+gravity;
	_y = _y+yspeed;
	_x = _x+xspeed;
	_rotation = _rotation+xspeed;
	if (_root.wall.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 450;
		_y = 50;
	}
	if (_root.environment.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 450;
		_y = 50;
	}
	if (_root.trig.hitTest(_x, _y, true)) {
		_root.trig.gotoAndStop(2);
		_root.environment.moving = 0;
	}
}

If the hero hits the trigger (as explained before, you will decide the type of collision checking later when you will test the entire game), the trigger frame is moved to 2 displaying a pulled lever and the moving variable is set to 0.
In this case, the actionscript of the environment won’t enter in the if condition and the environment will stop.

Possibile applications of this routine are almost infinite: imagine buttons that stops dangerous object moving, levers that reveals hidden zones with treasures, and so on.

We will discover all those options when the game will be in progress… remember that at the moment I am just showing you the basics.

Talking about basics, let’s see a type of environment that as far as I know is not included in ball:revamped (of course we always have to try to improve existing concepts).

The undeadly environment

I want an environment that does not kill the hero, but that changes some behaviours… imagine a stage that is partially flooded.
You have water in the stage, and your hero underwater movements will be more difficult.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
onClipEvent (load) {
	yspeed = 0;
	xspeed = 0;
	wind = 0.00;
	power = 0.65;
	gravity = 0.1;
	upconstant = 0.75;
	friction = 0.99;
	sunken = 0;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.LEFT)) {
		xspeed = xspeed-power;
	}
	if (Key.isDown(Key.RIGHT)) {
		xspeed = xspeed+power;
	}
	if (Key.isDown(Key.UP)) {
		yspeed = yspeed-power*upconstant;
	}
	if (Key.isDown(Key.DOWN)) {
		yspeed = yspeed+power*upconstant;
	}
	xspeed = (xspeed+wind)*friction;
	yspeed = yspeed+gravity;
	if(sunken == 0){
		_y = _y+yspeed;
		_x = _x+xspeed;
	}
	else{
		_y = _y+(yspeed/5);
		_x = _x+(xspeed/3);
	}
	_rotation = _rotation+xspeed;
	if (_root.wall.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 50;
		_y = 50;
	}
	if (_root.environment.hitTest(_x, _y, true)) {
		sunken = 1;
	}
	else{
		sunken = 0;
	}
}

Line 9 has a new variable that determines if the hero is underwater or not.
Then, when it’s time to update hero’s position according to gravity, speed, and so on…
Lines 26-33 checks if the hero is underwater or not. If it’s underwater, movements are reduced by 5 vertically and by 3 horizontally.

Note: I said movements are reduced, not the speed! This means that when you will pop out of the water, you have to pay attention to your speed. I want the player to move carefully when underwater, not simply have slower (easier) movements.

Now let’s imagine to have some special object on the stage. If the hero collects such object will raise the score, but the entire environment will get harder.

The playing environment

A little game covering some of the thems we discussed until now.
You have to score as much as you can. As seen before, you get 1 point when you collect a coin, you lose 2 points when you hit the walls and 1 point when you hit the environment.
Easy? Not at all… I forgot to tell you the environment moves, and the higher your score, the faster the movement.

The actionscript on the first frame is

1
score = 0;

You may ask: can’t you put this line in the hero onCLipEvent(load)?

Yes, I could, but you will see why I put it there when we will learn how to move around levels.

Anyway, in the environment object we have the actionscript:

1
2
3
onClipEvent (enterFrame) {
	_rotation=_rotation+0.25+_root.score*0.25;
}

Do you see? the environment rotation speed increases as long as your score increases. So bad!

Finally, the hero actionscript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
onClipEvent (load) {
	yspeed = 0;
	xspeed = 0;
	wind = 0.00;
	power = 0.65;
	gravity = 0.1;
	upconstant = 0.75;
	friction = 0.99;
	_root.coin._x = Math.random()*400+50;
	_root.coin._y = Math.random()*250+50;
}
onClipEvent (enterFrame) {
	if (Key.isDown(Key.LEFT)) {
		xspeed = xspeed-power;
	}
	if (Key.isDown(Key.RIGHT)) {
		xspeed = xspeed+power;
	}
	if (Key.isDown(Key.UP)) {
		yspeed = yspeed-power*upconstant;
	}
	if (Key.isDown(Key.DOWN)) {
		yspeed = yspeed+power*upconstant;
	}
	xspeed = (xspeed+wind)*friction;
	yspeed = yspeed+gravity;
	_y = _y+yspeed;
	_x = _x+xspeed;
	_rotation = _rotation+xspeed;
	if (_root.wall.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 50;
		_y = 50;
		_root.score -= 2;
		if (_root.score<0) {
			_root.score = 0;
		}
	}
	if (_root.environment.hitTest(_x, _y, true)) {
		xspeed = 0;
		yspeed = 0;
		_x = 50;
		_y = 50;
		_root.score -= 1;
		if (_root.score<0) {
			_root.score = 0;
		}
	}
	if (_root.coin.hitTest(this.hero_hit)) {
		_root.coin._x = Math.random()*400+50;
		_root.coin._y = Math.random()*250+50;
		_root.score++;
	}
}

Nothing new, just a check to the score to prevent it to be less than zero.

If you want, drop a comment with the highest score you achieved. I bet you won’t easily score more than 15.

Remember to give me feedback and suggestions.

Download the examples source code and move to the 4th part

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (71 votes, average: 4.73 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 154 comments

  1. Flash game creation tutorial - part 1 at Emanuele Feronato

    on December 6, 2006 at 2:02 pm

    [...] December 6th update: 3rd part released. November 18th update: 2nd part released. [...]

  2. Vasheeth

    on December 6, 2006 at 10:12 pm

    Hmmm… I know this is a begginer’s question to ask, and I’ll admit to being one, but how do I get two instances to group together and stay together during the “game”? I’ve tried many different ways, but they never work, I always end up leaving the square behind.

  3. Random

    on December 6, 2006 at 10:39 pm

    This is a very good tutorial. I have one comment to make however. On your last tutorial (Part 2) you told somebody it would be hard to make a bounce effect. Its actually very easy. Start by making two separate movie clips/instances for the walls, wall1 (floor and ceiling) and wall2, the right and left walls.
    if (_root.wall.hitTest(_x, _y, true)) {
    yspeed = yspeed*-1;
    }
    if (_root.wall.hitTest(_x, _y, true)) {
    xspeed = xspeed*-1;
    }

  4. Random

    on December 7, 2006 at 5:48 pm

    Umm… woops. Redo.
    if (_root.wall1.hitTest(_x, _y, true)) {
    yspeed = yspeed*-1;
    }
    if (_root.wall2.hitTest(_x, _y, true)) {
    xspeed = xspeed*-1;
    }

  5. Me

    on December 7, 2006 at 10:44 pm

    Woho!
    I scored 21 :D

  6. Newbie

    on December 7, 2006 at 11:36 pm

    i’m quite a newbie regarding flash, though i’d followed the tutorial quite easily (that’s a compliment) and managed to accomplish all the first steps but i can’t make a funcitonal score count. i’ve put the code correctly in the hero but i dont know what to do with the “score = 0;”, where to place it. (i mean, i don’t know how to initialaze a variable in the root) again, i’m new in this. sorry, hope to get ur answer

  7. Newbie

    on December 7, 2006 at 11:51 pm

    score done.
    :)

  8. Newbie2

    on December 8, 2006 at 10:45 pm

    I have the same problem Newbie had, i can’t get the score to function correctly…
    I have “score = 0;” in the main frame, a dynamic text box in the main scene, and i have “_root.score ;” in the correct spot… still not sure why it isn’t responding.

  9. teh nub nub

    on December 8, 2006 at 11:39 pm

    great tutorial
    couldnt get past 17 on that last 1

  10. Tom

    on December 9, 2006 at 8:52 pm

    WOOHOO I SCORED 800 MILLION

  11. eblup

    on December 11, 2006 at 12:02 am

    hey can you make one with a guy gravity ground water and boxes to hop acros.

  12. i best the game

    on December 12, 2006 at 4:06 am

    i beat ball revamped blblblblblblblblz

  13. sam

    on December 22, 2006 at 6:23 pm

    i am making lives in my game it works the same way as the score but it minus lives instead of score when it hits the walls. When the lives equals 0 i tried to make a code so that it takes it to a frame which says game over

    but this code doesn’t work:

    if (_root.lives=0) {
    gotoAndStop(2);
    }
    can anyone help me???

  14. jonimator

    on December 23, 2006 at 4:45 am

    im having the same problem with the ‘score=0′ can anyone help me?? please where do i put it??? I cant use the scoring method! :(

  15. Flash game creation tutorial - part 4 at Emanuele Feronato

    on December 23, 2006 at 6:27 pm

    [...] Read steps 1, 2 and 3 if you’re new to this tutorial, then follow this one. [...]

  16. diamonddrake

    on December 24, 2006 at 12:00 pm

    in reply to sam:

    your code:
    if (_root.lives=0) {
    gotoAndStop(2);
    }

    correct code:
    if (_root.lives==0) {
    gotoAndStop(2);
    }

    you should be checking if lives is equal to zero,
    instead you had if, set lives set to zero.

    honest mistake, every time you use an if statement with variables use 2 quals signs. it means “is equal to”

    hope that cleared it up for you.

  17. diamonddrake

    on December 24, 2006 at 12:04 pm

    and as for the score newbies…
    first frame, on the frame. put score=0;
    then always refrence it with _root.score
    it will work. full proof. if you can’t get it to work with that said, then go get a new hobbie.

  18. Atilla

    on December 25, 2006 at 8:53 pm

    Hi , how can i put the ”The killing tweened environment” , but also the ”Water” ?

  19. Andrew

    on December 26, 2006 at 12:34 am

    Nice tutorial :) hope there will be more of thees, how to make a “mario style” platform game maybe? ^^

  20. calle

    on December 30, 2006 at 2:28 pm

    I’m not so good at this.. i could do everything exept for makeing the score board..
    so if someone could tell me how to do(from the begining please) thanks!!
    :)
    Great tutorial!!!

  21. Fiz

    on January 3, 2007 at 10:54 pm

    woah, totally easy to learn, and you actually explain the action script, you are gifted at tutorials, and the root files for examples are a stroke of genius

  22. Purple_Chikcen

    on January 6, 2007 at 12:59 am

    i made a dynamic text block and gave it the instance name of score and gave put score = 0; in the actions menu of the main frame. i typed zero in it and tried the game and when i collide with the coin and walls the score does not increase or decrease what am i doing wrong can anyone help me

  23. Purple_Chikcen

    on January 6, 2007 at 1:01 am

    “gave put” is a typo woops i didnt put the word “put” in the script lol

  24. Purple_Chikcen

    on January 9, 2007 at 2:02 am

    wow been a while since hes replied to anyone

  25. Purple_Chikcen

    on January 9, 2007 at 2:15 am

    yus i scored 20

  26. Ryan

    on January 20, 2007 at 2:57 am

    I got 16 on my first try!

  27. Nabeel Quazi

    on January 20, 2007 at 10:56 pm

    where exactly do i put the score variable thing? (the first actionscript on the page)

  28. Paul w

    on January 21, 2007 at 4:42 pm

    i dont even get how to do the dynamic text box!?!? help!!!!!

  29. NeedHelp

    on January 22, 2007 at 11:23 pm

    I am having torouble with the score please help me by telling me exactly what i have to do with the score

  30. trys everything

    on January 28, 2007 at 8:54 pm

    This is to everyone who needs help with the score box.

    Click the text tool in the tool panel and create a text box. In the properties area make sure the dropdown box is set to dynamic. In that same section you will see a text area labeled “var”. in there you type “score” because that is the name of the variable you want it to show. In the first frame of a layer (preferably the layer with the text box) enter the actionscript “score = 0;”.

    If that doesn’t work, give me some slack. Post your problems and I’ll try to help. I am only 14. :-P

  31. trys everything

    on January 28, 2007 at 8:57 pm

    Oh yeah forgot.

    Awesome tutorial!

    Covers all actionscript problems.

    Only thing is, I want to keep all my actionscript in the first frame of a layer called “action”.

    How do I get the frame to recognize the onClipEvent (enterFrame) line for the hero MC?

  32. Mick

    on January 30, 2007 at 7:30 am

    im having a pronlem with the scoreing, i can make the text box and everything, but i cant find the var box =(, can any1 help?

  33. confused pinguine

    on January 30, 2007 at 5:53 pm

    This Tutorial is really great!!
    Im 12 years old and I understand(most of) it!
    But…
    when I am Playing the game ive made, evrything goes in slomotion!!!
    WHY MAAN WHYYYY!!!

  34. K

    on January 30, 2007 at 7:28 pm

    To Mick. Mark your textbox and check the properties. Right under where you choose color and size of the letters, the “var” box is.

  35. Arne

    on January 30, 2007 at 10:05 pm

    Help with inserting more “environments”
    Been following this guide for a while. Been going well so far. Execpt one thing. How do i add more environments? If i copy the first one i had, it simply goes right through it.

    ;)

  36. Trys Everything

    on January 31, 2007 at 12:27 am

    @confused pinguine

    wat you have to do is increase the frames per second (fps) to 50

  37. Mick

    on February 1, 2007 at 4:01 am

    yeah i checked there but on my flash theres no var box there…maybe i’ll just upgrade to flash 8 ;).

  38. George

    on February 1, 2007 at 6:16 am

    i dont know if this was answered somewhere but alot of people were asking about the scoring. make a dynamic text box, give it a name then type this into action script.

    _root.(text box name).text = “score: ” (variable name for score);

    hope it helps

    =\

  39. helper monkey

    on February 2, 2007 at 6:21 pm

    – confused pengiun, just click on the stage, then open the properties bar at the bottom, there should be a box that says “FPS 12″, simply change the 12 to a higher number.
    im using flash mx 6.0, so sry if you’re using a different version and this doesnt work

  40. im the best

    on February 4, 2007 at 7:56 am

    emanuele i mastered that spinning game i got 17!

  41. im the best

    on February 4, 2007 at 8:02 am

    Lol vasheeth you spelt beginner wrong

  42. im the best

    on February 4, 2007 at 8:07 am

    and mick flash 8, it rocks i suggest going for it

  43. Flash game creation tutorial - part 5 at Emanuele Feronato

    on February 9, 2007 at 6:58 pm

    [...] Read steps 1,2,3 and 4 and you’re ready. [...]

  44. Flash game creation tutorial - part 2 at Emanuele Feronato

    on February 9, 2007 at 7:01 pm

    [...] February 9th update: part 5.1 released. December 31st update: 5th part released. December 23rd update: 4th part released. December 6th update: 3rd part released. [...]

  45. confused pinguine

    on February 9, 2007 at 10:30 pm

    thx 4 ur help Helper monkey and trys everything!
    I appriciate it man…
    /\
    (or however u spell it…)

  46. Anonymous

    on February 10, 2007 at 7:22 pm

    Great tutorial, bad for beginner because you don’t explain very much.

  47. Glucozade (Sonic fan #1)

    on February 14, 2007 at 12:07 am

    how would i put in a variable showing the number of lives left and ‘game over’ -ing the game when the lives reach zero?
    any help is appreciated

  48. -none-

    on February 16, 2007 at 7:47 pm

    23 point!!!!!!!!
    beat that!!!

  49. Bubbler

    on February 18, 2007 at 3:43 pm

    In response to diamond drake:

    your code:
    if (_root.lives==0) {
    gotoAndStop(2);
    }

    correct code:
    if (_root.lives==0) {
    _root.gotoAndStop(2);
    }

  50. Trevor

    on March 15, 2007 at 7:54 pm

    im creating a trigger similer to the one used in the tutorial but i want to be able to stop and start the moving block the trigger affects effects I’m a complete begginner with flash but learning fast, any help you can give me is greatly apreciated.

  51. Pit

    on March 17, 2007 at 3:12 am

    Man, i can’t figure out the score thing either…i know im doin somethin wrong. if only i knew what… I put the score code in the frame, i make a dynamic text box with variable of score, and i put in the code in the hero. NOT WORKIN! When i veiw the movie, the score box doesn’t even start out with a zero in it!

  52. Pit

    on March 17, 2007 at 3:13 am

    oops, i meant instance! lol not variable

  53. Chris

    on April 5, 2007 at 7:44 am

    Hey i’m currently making a game (not like yours, but similar. and i was wondering, if theres a code, so that when the “hereo” touches a movie clip, it goes to the next scene?

  54. Jonny

    on April 6, 2007 at 1:01 pm

    Hi im all new to this actionscript stuff and so im confused. this is probably a really obvious answer but on the last game when i try to make the environment rotate, it doesn’t rotate from the middle, it always rotates from the left. can anyone help with this please?

  55. ru8ikscu8er

    on May 9, 2007 at 6:50 am

    Yay, after about an hour of mindlessly playing this game like a moron, I have finally achieved the coveted rank of 30, thus becoming the world class mindless game player

    P.S. I can do the rubik’s cube in about 30 secs

  56. Chaos

    on May 10, 2007 at 5:14 am

    So, I’ve read through the tutorials and I think they are pretty awesome. I’ve been tweaking numbers within the games, and I’ve noticed that I’m unable to make a solid object. I’ve been trying to make a solid ground or block that doesn’t kill the player, the player just can’t go through it. Mostly, I’ve been trying this with the ground. I’ve change the settings so that it doesn’t kill the player (commented out the change x and y positions) and I’ve changed the part where it changes the players speed, so rather than setting it to 0, it sets it to -(some number)*xspeed. Is there a specific number that I have to use that counters gravity and the player’s downward force? Like, for example, should I stop the players motion, than give them a gentle push upward?

  57. Smokey

    on May 16, 2007 at 1:41 am

    im a little confused.

    The score

    Scoring system consist in a variable set to 0 (zero) when the game starts and some events that may increase/decrease the score.

    In this case, you get 1 point when you collect a coin, and lose 2 points when you crash into a wall.

    Hall I have to do is initializing a variable in the root with a single action
    ACTIONSCRIPT:

    1.
    score = 0;

    Where do i write the “score=0;” ?

  58. shadowt

    on June 5, 2007 at 6:55 pm

    im a little confused.

    The score

    Scoring system consist in a variable set to 0 (zero) when the game starts and some events that may increase/decrease the score.

    In this case, you get 1 point when you collect a coin, and lose 2 points when you crash into a wall.

    Hall I have to do is initializing a variable in the root with a single action
    ACTIONSCRIPT:

    1.
    score = 0;

    Where do i write the “score=0;” ?

  59. MasterZ87

    on June 7, 2007 at 3:55 am

    Score 14 xD

    I know somethinks abouts programming (Div 2 xD), but flash (and any object oriented programming) is more complicated. Thanks for the tutorial, it’s very good ^_^.

  60. Aidin

    on June 12, 2007 at 3:57 am

    why when i generate the SWF file of these tutorials, it doesnt get keyboard input dont work but when i use flashplayer, they work and gets my keyboards?
    Emanuel, do u answer these questions?!

  61. Aidin

    on June 12, 2007 at 4:19 am

    i realized by Clicking once on the browser, it gets my keyboard input, but why and how can i solve this bug/problem/”something that i dont want” ?

  62. dffdfdfdfdf

    on August 14, 2007 at 3:47 pm

    good tutorial for people who are intersted in making platform-type games. i dont think that this tutorial is suitable for newbs, cuz they cant learn math and variables at the beginning

  63. Liz

    on August 18, 2007 at 4:30 am

    This tutorial is great. I am having one problem, though, that other people seem to be having but that hasn’t been answered.

    My hero cannot collect my coin. It passes right over it and the coin does not move. Does anyone know why that might be?

  64. Tom

    on August 20, 2007 at 7:23 am

    everybody listen!!!!!

    the reason why your game is in slow motion is because your frame rate is not high enough

    all you have to do is right click the screen
    go to document properties
    find frame rate(which is usually 12 for my PC ;D)

    then change it to as fast as you want it
    :O

    i know its amazing isn’t it
    o.O

  65. Temporal

    on August 23, 2007 at 9:59 pm

    For those having Trouble with the Score:

    Make a text box on it’s own layer and resize it how you’d like. Click on the text box and look at the properties tab, make sure this is set to Dynamic, and set it’s variable to “score” (Which is NOT the box below where you select Dynamic, it’s below where you set the size of the text You might need to hit a little triangle shaped button on the bottom right of the properties box to see it).

    THEN click on the first frame of that layer (in the frames above your work area, where you make new layers, click on the first dot under “1″). Now type the actionscript into that. “score = 0;”.

    The problem you guys are probably having is the same that I did, not actually realizing what the variable box was.

  66. Dragolux

    on September 14, 2007 at 11:14 pm

    Man, I only got 14. :( Oh well. Great tutorial, EF!!

  67. Azz

    on October 1, 2007 at 9:42 pm

    BOOYAH i got 16 points XD even took a screen shot =p

  68. peter

    on October 4, 2007 at 5:01 pm

    lots of people have problem with that score thing

    i have another “problem”

    _root.coin._x = Math.random()*400+50;
    _root.coin._y = Math.random()*250+50;

    i think the numbers are so that the coin doesn’t get out of the screen, but how do u get hold of those numbers, is it trial and error?
    because in part 2 only the _x is given and i tryed the same code only _x i changed in _y and sometimes my coin got out of the screen (not much)

    anyone can explain ?
    thanks already :)

  69. pallmall

    on October 15, 2007 at 8:56 am

    i tweeked it a bit and now my guy is invincible and bounces off the wall and aims for the coins, plus every coin i get is worth some candy from a strangers van….

    nah im playin, pretty good tutorial though

  70. Teal

    on October 16, 2007 at 10:31 pm

    Yay! I got a 31! I spent about an hour playing though… Anyways, great tutorial! I’m learning a lot.

  71. andy 60

    on November 11, 2007 at 11:58 pm

    yer me to sorry i’m probably missing something obvious its just the score i dont quite get :(

  72. Goinginsane

    on November 16, 2007 at 9:35 pm

    OK. I have followed everyones advice, step by step. I put “score” in the variable box. And I put “score = 0;” into the frame, and I have done it about 300 times and still NOTHING!!!
    I am literaly going insane. Help

  73. jitz

    on November 19, 2007 at 5:54 pm

    hey
    the tutorial was great and i got everything working and even the score goes up when the coin it touched BUT it doesnt stay after a split second the score goes back to 0 any idea??

  74. spartan 117

    on December 2, 2007 at 12:05 pm

    your site is the best action script site i have ever seen. i have given it to all my friends, we are making an rts, like age of empires, can you help?????

  75. Mr. Flashie

    on December 29, 2007 at 12:57 pm

    Cool. I love your site.

    Could you continue with your tutorial and help us making more interactive games, something like super-mario games?

  76. pioallergenic

    on January 21, 2008 at 7:16 am

    ive got a better idea, i can make custom lives but its more difficult that what you want…

  77. confused teenager

    on January 25, 2008 at 5:49 pm

    newb question but i cant pick up my coin and i have triple checked the code and its the same… any suggestions

  78. Lemony

    on February 3, 2008 at 11:51 am

    I have had quite a few errors, im the same as confused teenager.

    I think you need to be more spesific on where the code in question goes. Do all the codes go in the action script for the hero? Or do you put the coin code in the action script for the coiin itself,

    CoNfUzzLeD

  79. Flashtoo

    on February 6, 2008 at 9:10 pm

    Motherload.

    Make a treasure picture(not too big) and convert it to a MC, and give it the isntance of motherload,put in the following on the place where the “trigger”AS,

    if (_root.trig.hitTest(_x, _y, true)) {
    _root.trig.gotoAndStop(2);
    _root.motherload._x = 50
    _root.motherload._y = 50
    }
    if (_root.motherload.hitTest(this.hero_hit)) {
    _root.motherload._x = -1000
    _root.motherload._y = -1000
    _root.score += 700
    _root.motherload.gotoAndStop(2);
    }

    you get a motherload of points at 50 x and 50 y when you hit the trigger.
    Made by me.

  80. Flashtoo

    on February 6, 2008 at 9:11 pm

    And inside the treasure MC, add a stop script to the first frame, make a other empty frame in it, and put in same AS.

  81. Flashtoo

    on February 6, 2008 at 9:14 pm

    GOININSANE!!!!

    be sure to have a zero put int he text of ur dynamic text box,else it doesnt work.

    Sometimes Emanuale forgot the coin scripts and more.

  82. klap

    on February 8, 2008 at 2:31 am

    on the “water” example my charecter always seems to be “under water” or sunken, any help?

  83. Umer

    on February 22, 2008 at 5:07 pm

    THis is the best tutorial i have ever had ,I have advice instead of writting
    _y = _y + yspeed or yspeed = yspeed + gravity
    & every thing like that Can also be written as
    _y +=yspeed and yspeed+=gravity
    Need Help I am Trying to make the game like this one http://www.addictinggames.com/maxdirtbike.html
    But Problem Is this tutorial do not Explain Rotation And hittest do not work with curve objects So plsz Reply plzzzzzzzzzzzzzzzzz

  84. Malik

    on February 28, 2008 at 11:46 am

    your tutorials are very good but i cant seem to open the FLA files, says “The file format is not not recognized”, would you please be able to send me the originals for the first interactive box on this page. The one with the counter and the coin score board
    Please Thankyou

  85. bensta

    on March 7, 2008 at 10:53 am

    woooohoooo these tourtorials or whatever are great and so is this bong

  86. Bob

    on March 19, 2008 at 5:49 pm

    how exactly do u get the score to work because i cant get it to work.

  87. romario

    on March 26, 2008 at 4:13 am

    I have done everything as the tutorial but i can’t set the score . Plz help me

  88. Owen

    on March 26, 2008 at 9:51 am

    I’m making a game where you move to the next level when you get a score of 10, and you move to the game over frame when you lose all of your lives. At the moment I have this:

    if(_root.score = 10
    gotoAndStop (5);
    }

    and:

    if(_root.lives = 0
    gotoAndStop (6);
    }

    but these codes just set my score and my lives to 10 and 0 respectively. How can I fix this?

  89. Temporal

    on April 3, 2008 at 3:25 am

    Owen: You’re setting the score to 0, you need to use == rather than =.

    == is equal to

    = equals

  90. Keith

    on April 8, 2008 at 4:39 am

    Hey,

    I’m trying to add a moving environment (precisely like the rotating line) into my game. However, the ball keeps hitting imaginary objects. All other environment objects from the last level were deleted. Instead of adding the “score” to the rotation speed, I just have:

    onClipEvent (enterFrame) {
    _rotation = _rotation+0.5;
    }

    Is there a fix for this?

  91. The_erik

    on April 10, 2008 at 10:22 am

    scored 21 :D

  92. The_erik

    on April 10, 2008 at 10:42 am

    hey Emanuele, great tutorial :)

    i just have one issue though. I am trying to make a game, and i’m whenever i put more than 2 different hitTest’s in the actionscript of the hero, i get a bug.
    Whenever i trigger one of the hitTest’s that i added as the last ones, my hero gets set to the point where it was supposed to, but then it dissappears right after.

    What’s going on? :<

  93. The_erik

    on April 10, 2008 at 11:24 am

    romario, please tell me excactly what you’ve done, and then i can help you :)

  94. newbie

    on April 21, 2008 at 11:39 pm

    i dont know where to put the score = 0; in im new to this so plz explain

  95. Amy

    on May 5, 2008 at 7:09 pm

    I’ve got a problem!
    Ive made a game like this but When I have math random on my coin it goes onto one of the blocks in the enviroment making it impossible to get the coin! Please help!!!

    Instances:
    Player = “hero”
    coin = “coin”
    Blocks (all are in one movieclip) = “environment”

  96. Jesse

    on May 11, 2008 at 1:31 am

    I have a problem. I’m making a game, and I want to have walls to make my hero retreat, not kill him. However, these “walls” could be curved, such as a river. The script doesn’t work properly:

    onClipEvent (enterFrame) {
    if (this._parent._parent.House2.hitTest(_x,_y,true)) {
    speed*=-1 }
    }

    Could any one help me please? Thank you very much!

  97. Brettcr » Blog Archive » Programming Tutorials / Game Making Check Video Description download videos off you tube

    on May 12, 2008 at 11:43 pm

    [...] Flash Actionscript Game Making Tutorialshttp://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/… [...]

  98. Coisox

    on May 15, 2008 at 7:43 am

    Thank you so much. Very neat tutorial! Easy to understand.

  99. Elise » Programming Tutorials / Game Making Check Video Description convert youtube video to dvd

    on May 19, 2008 at 4:27 am

    [...] Flash Actionscript Game Making Tutorialshttp://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/… [...]

  100. hero

    on May 19, 2008 at 5:08 am

    I have a question about how to make it go to a diffrent frame when the coin is reached. I am making a game so that when a coin is hit another moving obstacle appears. But when i add an actionscript like
    if (_root.coin.hitTest(this.hero_hit)) {
    gotoAndPlay(55); }
    It does not collect the coin and i do not know why can some one please help me?

  101. Help me

    on May 25, 2008 at 1:54 pm

    hi
    nice tutorial.
    i need help with the score. i have done the text named it and everything i put the code in the first frame. but when i run the game it just stays at 0 and does not move. i have flash 7 do you need to do something different.

  102. apocalypsefu

    on May 29, 2008 at 1:01 am

    Very nice tutorial. Got 14 woo hoo!

  103. 90301

    on May 29, 2008 at 1:26 am

    you need to have
    _root.gotoAndPlay (number);

    this is because it thinks the character’s frames when it just says gotoandplay.
    ifyou say root.gotoandplay
    it means the scene.,
    if you say _root.wall.gotoandplay
    it means goto the wall frame 2.

  104. woot

    on May 29, 2008 at 12:17 pm

    woot 20 but then its way too fast….

  105. Samuel Benson

    on June 9, 2008 at 12:20 pm

    when the ball resets in my flash game the reset position keeps changing, for example if it touches the boundary it resets at _x 497 and _y 80 but when it collides with the wall a second time it resets further up and to the right of the original position. My version of Flash will not read the download version of the tutorials so I cannot view that and recitify the problem, can anyone help?

  106. Samuel Benson

    on June 9, 2008 at 2:00 pm

    Can any one answer Amy’s and Peter’s questions?! I would like the answer too!

    Also how do you set the rotation of the environment to the middle of the object? instead of the end

  107. bl00dsoul

    on June 28, 2008 at 4:32 pm

    18 lolz :P

    nice tut :)

  108. newby geek

    on July 6, 2008 at 11:49 pm

    Hello there, great tutorials indeed.

    though I have a simple question. Because all this code is AS1.0 I m trying to write all the code in the frame 1 of the timeline instead inside my movieclip. as adobe supports it is better and I want to write AS2.0 instead. so I ve changed a bit the code (created the functions actually) like this :

    stop();
    var score:Number = 0;
    var lives:Number = 2;
    // b is the instance name of my hero.
    b.onClipEvent(load) = function {

    var power:Number = 0.3;
    var xspeed:Number = 0;
    var yspeed:Number = 0;
    var friction:Number = 0.98;
    var gravity:Number = 0.1;
    var thrust:Number = 0.75;
    var wind:Number = 0.09

    }

    b.onClipEvent(enterFrame) = function {
    if (Key.isDown(Key.LEFT)) {
    xspeed -= power;
    }
    if (Key.isDown(Key.RIGHT)) {
    xspeed += power;
    }
    if (Key.isDown(Key.UP)) {
    yspeed -= power*thrust;
    }
    if (Key.isDown(Key.DOWN)) {
    yspeed += power*thrust;
    }

    xspeed += wind;
    xspeed *= friction;
    yspeed += gravity;
    _y += yspeed;
    _x += xspeed;

    if (_root.wall.hitTest(_x, _y, true)) {
    xspeed = 0;
    yspeed = 0;
    _x = 120;
    _y = 120;
    _root.lives –;
    }

    if (_root.apple.hitTest(this.hero)){
    _root.apple._x = Math.random()*320+30;
    _root.score ++;
    }
    if (_root.lives == 0) {
    _root.gotoAndStop(2);
    }

    }

    but I get errors about line 5, 17. the erros are :

    lines 5 & 17 : Expected a field name after ‘.’ operator.

  109. newby geek

    on July 6, 2008 at 11:51 pm

    typo :

    I have:

    b.onClipEvent(enterFrame) = function() {



    b.onClipEvent(enterFrame) = function() {

  110. bug

    on July 28, 2008 at 4:18 pm

    there is a small bug in that game, if you hold down right and down, you go through the line…, not that it helps that much :p
    and i got 13

  111. Jesse

    on August 5, 2008 at 5:15 pm

    33. if (_root.score <= 0){
    34. _root.score = 0;}
    35. else{
    36. _root.score -=2;}
    37. }

    40. if(_root.score <= -1){
    41. _root.score = 0;}
    42. else{
    43. _root.score ++;}

    That will get rid of Negative scores, but very great tutorial:D, I just didn’t like the negative scores so I fixed it.

  112. Jesse

    on August 5, 2008 at 5:16 pm

    Change that first If to <= 1 because that’ll fix the wall negative error :D

  113. Jesse

    on August 5, 2008 at 5:19 pm

    ps 16 was highest score

  114. tom

    on August 30, 2008 at 10:23 am

    i’m trying to make the movie skip to frame 2 when the player reaches the score 10.
    i’ve tried:

    if (_root.score==10) {
    _root.gotoAndStop(2);
    }

    and this is not working for me. what can i be doing wrong.

  115. flash noob

    on August 31, 2008 at 9:52 pm

    how do u do a hittest and that when u hit it, it uses gotoandStop to goto the next level?

    someone help because i’m confused

  116. Zakk

    on September 20, 2008 at 1:56 am

    Umm, im not haveing scripting problems so mabey i have a gift for that (im 13) but how do i make an object, like water, transparent?

  117. Zakk

    on September 20, 2008 at 1:59 am

    And i just managed to get 17 points!

  118. reducedoverlarge » Trailer for the upcoming Echo Wall climbing film

    on October 8, 2008 at 7:32 am

    [...] Flash Actionscript Game Making Tutorialshttp://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/… [...]

  119. forfreebigger » Diving with Sharks at the Chumphon Pinnacles, Koh Tao Thailand

    on October 9, 2008 at 2:19 pm

    [...] Flash Actionscript Game Making Tutorialshttp://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/… [...]

  120. score newbie

    on November 3, 2008 at 1:17 am

    how do you get the scoreboard thing up? this is my current code can someone please correct it?

    onClipEvent (load) {
    yspeed = 0;
    xspeed = 0;
    wind = 0.00;
    power = 0.65;
    gravity = 0.1;
    upconstant = 0.75;
    friction = 0.99;
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.LEFT)) {
    xspeed = xspeed-power;
    }
    if (Key.isDown(Key.RIGHT)) {
    xspeed = xspeed+power;
    }
    if (Key.isDown(Key.UP)) {
    yspeed = yspeed-power*upconstant;
    }
    if (Key.isDown(Key.DOWN)) {
    yspeed = yspeed+power*upconstant;
    }
    xspeed = (xspeed+wind)*friction;
    yspeed = yspeed+gravity;
    _y = _y+yspeed;
    _x = _x+xspeed;
    _rotation = _rotation+xspeed;
    if (_root.wall.hitTest(_x, _y, true)) {
    xspeed = 0;
    yspeed = 0;
    _x = 120;
    _y = 120;
    _root.score -=2;
    }
    if (_root.coin.hitTest(this.hero_hit)) {
    _root.coin._x = Math.random()*400+50;
    _root.score +=1;
    }
    }

  121. inotellmyname

    on November 4, 2008 at 4:17 am

    i know im going to look stupid for asking this because its going to be a simple answer but.
    how do i make something that is not moving move?
    i made it so your stuck and when you pull the lever i want the wall to move away then stop. and you can get thru…

  122. xZeRo

    on November 12, 2008 at 4:50 am

    Man this tutorial is great for newbs like me. I just want to know how you made the hero blend in with the water. It almost feels as if the hero is actually in the water.

  123. discountsize » 7 Tips for a Fun Filled Family Holiday Posted By : Johnn

    on November 12, 2008 at 11:32 am

    [...] Flash Actionscript Game Making Tutorialshttp://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/…http://www.emanueleferonato.com/2006/… [...]

  124. platformergameobsessed

    on November 14, 2008 at 1:21 am

    Hey everyone… I kept trying to use that code on the character and put a ground so my character would be able to fly and also be able to land on the ground. The problem is that my character falls right through the floor… can anyone tell what to change in the actionscript or if there is an entirely different way to make your character fly and land?

  125. xZeRo

    on November 15, 2008 at 7:29 pm

    Another question. How do u make the trigger go back to its original situation when the hero dies?

  126. Bumbanut

    on December 9, 2008 at 2:17 am

    I have a question:

    How do you make the coin not just appear on the same line in different places, but random places on the screen (except for the wall)?

  127. xZeRo

    on December 14, 2008 at 5:28 pm

    Bumbanut, you notice that the coin is only moving along the x – axis:
    _root.coin._x = Math.random()*400+50

    “_root.coin._x” is the code in which it tells the coin to move in the x – axis.

    The code “Math.random()*400+50″ is the area in which the coin is moving randomly.

    All you have to do is make it so that it can move in a random direction along the y – axis too.

    So the code will change the y – value of the coin.

    _root.coin._y = Math.random()*250+50;

    Make sure of how many pixels are the height of ur screen. I chose 250 pixels. This can vary in your stage.

  128. Anonymous

    on December 25, 2008 at 6:29 am

    Okay, Im quite a newb, and Im just trying to make a test game where its birds eye view and your a dot and you have to run away from other dots, through a maze. I have your code from the end of part 1, (thanx alot!), but I want it to turn you back, kinda like a bounce when you hit a wall, but just barely.

    I have this code:

    if (_root.wall1.hitTest(_x, _y, true)) {
    yspeed = yspeed*-1;
    }
    if (_root.wall2.hitTest(_x, _y, true)) {
    xspeed = xspeed*-1;
    }

    But (and this is the newbish part)

    Where would I put that in relation to the rest of the code? Is it at the beginning or the end? Someone plz help me!!

  129. rob bob bobert

    on January 8, 2009 at 7:20 pm

    very very good tutorial well done m8 well worth the effort you put in coz this was very helpful (written well) consider ego polished

    happy new year all

  130. BenneyBoy

    on April 21, 2009 at 10:25 pm

    Thanks to
    “28. trys everything on January 28th, 2007 8:54 pm”

    For helping me with the score box.

  131. austin was not on the computer

    on May 1, 2009 at 12:58 am

    Im designing a video game currently… You are a dragon flying threw a massive dungeon. I made it so the lava pits work, but i cant get the score board functional, also i need some script on how to creat solid flooring,i whish to make him able to walk on land..

    My current code
    }
    if (_root.gem.hitTest(this)) {
    _root.gem._x = Math.random()*400+50;
    _root.score ++;
    }
    }
    All of the other tutorial has benn really swell so far, thnx it was really helpfull…
    Wow i must sound like a winy nube, after all im only 13
    Sincerely
    Austin C.
    PS plz any one feel free to answer if possible

  132. ANSWER to half your questions. i think.

    on May 2, 2009 at 10:32 am

    Instead of
    score = 0;
    on the frame, do,
    var score = 0;

  133. IFG

    on May 6, 2009 at 5:26 pm

    Prolly the best tutorial ive ever read, ive seen tutorials that show u what to do, but this one is so much easier

  134. Lemony Emily killed a noob

    on May 28, 2009 at 2:49 pm

    Like Austin, I need to make a solid border/surface that is not deadly, so my ninja will not fall out of the playing area.

    ATM I have removed gravity because it was making my friends go “WTF” But I need gravity for my ninja to “jump”.

    Please feel free to email me.

    Lemony Emily :)

    Oh and btw Austin im only 12 ;P

  135. Yourothermind » Blog Archive » Not a Flash game - Brent Knowles' Blog and Writing Software

    on June 29, 2009 at 9:16 pm

    [...] Just doing some playing around with flash and am working my way through the solid tutorial by Emanuele Feronato. [...]

  136. Bumbanut

    on July 25, 2009 at 5:34 pm

    Yeah, hey. Thanks a lot for helping me! This game I made is really cool with your help. I added some things and removed the ones I didn’t want, added new character, a main menu, and now it’s great! Thanks!

  137. NEAR

    on September 14, 2009 at 12:50 am

    Dear, Emanuel feronato, Italian geek and PROgrammer, or any PROgramar who sees this and can help me out

    I love your tutorial, and have been making horribly difficult levels for my friends to attempt to beat, they love it! Unfortunately, I have a problem! On one of my levels, I have three coins with instances coin, coin_2, and coin_3, all of which are programmed to teleport randomly when touched by the character and certain tweened killing environments. Unfortunately, they occasionally teleport outside the wall program, this is a huge dilemma, as it makes it nearly impossible to get any higher than 5 points!

    I have a theoretical code that I think would probably solve the problem:

    onClipEvent(enterFrame){
    if (_root.coin.hitTest(outside stage)){
    _root.coin._y = Math.random()*400+50;
    }
    but, it is full of errors, can you help me?

    Also, can you make a tut for highscores? I want my friends to be able to compare highscores, and I didn’t see a section covering it when I skimmed ahead in the tutorial.

    Thanks for reading!
    Please post back!
    -NEAR

  138. NEAR

    on September 14, 2009 at 4:35 pm

    Woopsie, me again, I found the answer to my own question, the
    _root.coin._y = Math.random()*400+50;
    is basically setting up the area where your coin can pop to, so I changed the code to
    _root.coin._y = Math.random()*280+50;
    on my coin actions and it worked like a charm.By decreasing the numbers I decreased the coin teleport area.
    Also, expirement with X and Y coordinates if you want your coin to go all over the place!

    Thanks for the free tuts emanuel

  139. zard

    on January 24, 2010 at 1:03 am

    highest score = 1;
    i prefer to program with classes its more organized

  140. DannyDaNinja

    on January 26, 2010 at 6:56 am

    Highest score = 13

    i plan to make a game using these tutorials! i’ll say thanks to you in the credits!

  141. Helpmeplz

    on May 24, 2010 at 11:02 pm

    I wanna make another level so when i get 20 points i ll go to the next level and i dont know qhy these actions here doesnt work

    if (score=20) {
    gotoAndStop(706);
    }

  142. Helpmeplz

    on May 24, 2010 at 11:02 pm

    PS:and where put these actions

  143. Sam

    on June 2, 2010 at 2:31 am

    I am an absolute beginner and I’m wondering how do you even begin creating a game? Do I need any special software?

  144. Tips: Teaching yourself Game Development – Brent Knowles

    on July 31, 2010 at 7:05 pm

    [...] A year ago I messed around with Flash, not knowing anything about it and found a good tutorial that walked me through the basics. (The 3rd part of the series is here: Flash tutorial) [...]

  145. philzero

    on October 4, 2010 at 10:08 pm

    For those still having trouble getting the score to work after trying everything in the comments above:
    Go to text > Font Embedding
    then add the font you are using, and click ok.

    Now it should work.

  146. justin

    on October 24, 2010 at 2:47 pm

    im new, but i made a dynamic text box and labeled it “score” for the instance name, and nothing happens..no score changes..what do u think i did wrong

  147. justin

    on October 24, 2010 at 3:00 pm

    nevermind. i fixed it..i didnt realize that i needed to var name it and put 0 in the text box itself.

  148. zeeshan

    on February 28, 2011 at 6:24 pm

    hi, great tutorials..very helpful for beginners.
    i have a Question..i mean i really wasn’t able to do that “insert ‘hero_hit’ into ‘hero’ movie clip”, i read comments,etc but didn’t find solution..i tried that in all possible ways that came to my mind but no luck..can anyone explain that how to do that part ‘from 2nd tutorial’?..I am Stuck.
    thanks. :)

  149. Newbzoar

    on March 3, 2011 at 8:09 pm

    Alright, i couldn’t get the score to work, i just don’t have the faintest idea as to how i make the text box show the score:/

  150. iamanoob

    on April 6, 2011 at 1:09 am

    i am completely new to flash and am trying to make this game but tweak it a bit. i added lives and tried to make it so that 50 score == 1 life and such….. i couldnt get it to work…. this is the code i tried

    if (_root.score == 50) {_root.lives ++}

    btw i am only 13 so dont make me feel bad lol

  151. Christian

    on May 23, 2011 at 10:54 pm

    For those having score probs,put the varible “score” is the varible textbox in the text’s settings

  152. Im LEARNING!

    on July 14, 2011 at 9:20 pm

    I have created the level “The playing environment” everything is working but how do I make it change frame, for example after collecting 10 coins

  153. Carlos

    on August 30, 2011 at 3:16 am

    When I make the score it’s there, but when I grave a point it says 1 and then goes bak to 0, and the same when I hit a wal, it says -2 and then goes back to 0, I don’t know why is this happening, if someone knows how to fix this please tell me. Thank You in Advanced.

  154. Carlos

    on August 30, 2011 at 12:45 pm

    I already tried out everything it says in the comments, but the score keeps going back to 0…