Hello Flashers!!
In this Tutorial, I'm going to show you how to manipulate a plane position and how to make it move.
In the next tutorials I'm going to show you how to add enemies in your game and weapons to your little plane to score points, but only with actionScript 2.0.
I downloaded a plane image and delete its background with photoshop.
Open up flash and let's get started.
As I said before we are going to use actionScript 2. So open a new action Script 2 file or go (file->publish settings-> flash -> choose action script2).
I named the first frame as "BG" this frame will contain our background which is by the way will do 50% of the job.
Minimize your page. Now draw your background.
Rq: the background image has the same height of the page but 4 times larger. The part of the image that's not in the page will not appear with swf file.
Select all of your background image and convert it to a movie clip (F8 -> movie clip).
In this step we are going to make our background moving, it's like the camera will follow our future plane.
So go to frame 50 and create a keyFrame (left click->F6).
Select the first frame and move your backgrounf to the extreme right.
Now Select your last frame (the new keyFrame) and move your background to the extreme left.
Left click somewhere between the two keyFrames (the first and the last frame) and choose Create Classic Tween.
Test your movie (ctrl+ enter).
Now we are finished with our background so make it invisible and let us add our plane.
Create a new layer and name it "plane".
File->import -> import to library the photoshop made plane.
Grab your plane into the plane layer and adjust it size while pressing the shift key to keep it centered.
Convert the plane to a movie clip, and give it an instance name in the properties panel.
Select the first frame of the plane layer and press F9 to write some code.
Here's the code try to get it to use and modified as your needs.
var keyboardListener:Object = new Object();
keyboardListener.onKeyDown = function() {
if (Key.isDown(Key.RIGHT)) {
pln._x +=2;
}
if (Key.isDown(Key.LEFT)) {
pln._x -=2;
}
if (Key.isDown(Key.UP)) {
pln._y -=2;
}
if (Key.isDown(Key.DOWN)) {
pln._y +=2;
}
};
Key.addListener(keyboardListener);
Download all the work from here
Thanks for your attention. See you guys in my next tutorial.
Mazen :]
Aucun commentaire:
Enregistrer un commentaire