Tips     Beginners     Intermediate     Advanced     Resources     E-mail me

Arkanoid/Breakout

Part 3:
To make a game out of this we need to create a "paddle". Create a new Layer called Paddle and draw a rectangle on it. Convert it to a movie clip object called paddle.
The player needs to move the paddle left and right so that the ball will bounce of it. Highlight the paddle and add the following code in it's Action Window
		onClipEvent (load) {
	
			this._x = 275;
			this._y = 350;
			paddle_speed = 10;
		}
	
		
This puts the paddle in an initial position.
Next we need to move the paddle if the player presses a key. We will use the right arrow key to move the paddle right and the left arrow key to move it left.
Enter the following code in the onClipEvent (enterFrame); function.
			if ( Key.isDown(Key.RIGHT) ){
				this._x+= paddle_speed;
			} else if ( Key.isDown(Key.LEFT) ){
				this._x-= paddle_speed;
			}	
		
You should now have a moveable paddle on the screen along with the ball. Move the paddle using the right and left arrow key. What's wrong with this ??

Back to top     Previous     Next
Hosted by www.Geocities.ws

1