Search Tutorials
(All the actions will be explained at the end of the tutorial) Here we will learn how to make an arkanoid game in my way. First, we will make the ship then, the ball (remember to make them movie clips and name the ball in the instance). Now we will create a movie clip that will not be seen on the screen, make it the shape that you want and name it “line” in the instance. Make a double click on it an make another movie clip into it. Now, make double click again on the movie clip and write the next on the frame actions:
tellTarget (_root._root.ball) {
_x -= 10;
_y -= 10;}
this will make that the ball gets in way to the northwest. Now make another frame and write; gotoAndPlay (1),this will make that the movement repeats constantly. Now make a double click out of the clip and write in the frame actions : stop ();,now make another frame (2nd) and make another movie clip in this second frame into the first movie clip we had already done (not the last one). Make a double click on it an write on the frame actions the next:
tellTarget (_root._root.ball) {
_x -= 10;
_y += 10;}
This will make the ball gets in way to the southwest. Make another frame in this movie clip, an write: gotoAndPlay (1);.make double click out of the movie clip and make another frame (3rd) , then make another movie clip and repeat the same process (rememer to write: stop ();)but in this one you will write:
tellTarget (_root._root.ball) {
_x += 10;
_y -= 10;}
to get northeast position. Repeat the same and in the next frame (4th) you will make the same but in the frame actions of the movie clip you will write:
tellTarget (_root._root.ball) {
_x += 10;
_y += 10;}
to get southeast position. Now make a double click out and write: stop();on the frame actions. Make another double click out to get in the movie. Now we will get into the ship, make double click on it. In there make an invisible movie clip (if you don´t know how to make transparent colours just select the colour you want and make a click on the mixer icon an there write 0% in the alpha) with a rectangle shape and there write the next:
onClipEvent (enterFrame) {
if (this.hitTest(_root._root.ball)) {
_root._root.line.gotoAndPlay(2);
} else {
}
}
The number of the frame depends on the way you want the ball to go ( the frame number is of the movie clip we were working on) . I recommend to copy this movie clip, paste it next to the other one and to write in the actions another frame number for the ball to get in two different directions. Now make the walls and write: onClipEvent (enterFrame) {
if (this.hitTest(_root.ball)) {
_root.line.gotoAndPlay(3);
} else {
}
}
depending on the frame number of the direction of the ball. Now, we will make the blocks that will be destroyed by the ball. Make a block with the shape you want, make a double click to enter in the movie clip and write a stop (); in the first frame, make another frame which will have no drawing, and write stop (); again in the frame actions. Now make double click out of the movie clip and write the next actions for the movie clip:
onClipEvent (enterFrame) {
if (this.hitTest(_root.ball)) {
_root.line.gotoAndPlay(4);
gotoAndPlay (2);
} else {
}
}
Remember that the frame number of the “line” can be the way you want, but the frame number that appears beneath it cannot be changed because it says that the movie clip will go to its second frame, where it is nothing, this is the frame where it will go when the ball hits the block. Now write the next actions on the ship:
onClipEvent (keyDown) {
if (Key.isDown(key.LEFT)) {
_x -= 7;
}
}
onClipEvent (keyDown) {
if (Key.isDown(key.RIGHT)) {
_x +=7;
}
}
This will allow you to move the ship. And the number 7 indicates the number of pixels it will advance. Now you can make the ball to go any direction you want and to make the walls that you want and make the game more complex. This is the explanation some of the actions: _root. is a very useful action that means that the movie clip you are referring is out of the movie clip you actually are.
tellTarget ( ) {
}means that you want another movie clip to make something when you want it.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|