I know this could be done far easier then I do it, but there is a lot of great reasons for doing it my way, we have all checks and movements in the enter_frame event, which makes sure that we can actually have two separate movements at once, so if you hold down left key and if we also could set it to jump, it will not jump straight up but up to the left.
Here's another old tutorial that I've bought over from the previous site, showing you how to create nice and simple 8 directional movement with rotation, handy for top down games such as RPG's and the like.
Now we will add hit testing. On the stuff layer, draw a 10 px black line towards the bottom of the stage. Press f8 to convert this to a movieClip called 'MC_wall' with an instance name of 'MC_wall'.
I want the car to come in from the side but not the person controlling it. I used this code to move in the side (which I got off the gravity tut but it changed abit of it) onClipEvent (load) { acc = 9.8; time = 0; fps = 20; } onClipEvent (enterFrame) { time = time+1/fps; this._x -= Math.pow(time, 2)*acc; _root.restart.onPress = function() { _root.aircraft._x = -50; time = 0; }; }
First things first, draw a plane... but NOT on the main timeline. Make one in a new movie clip. This will keep the plane contained and easy to manipulate once complete. In drawing, use the grid and grid snapping to help you create your lines. I have my grid snapping at 10 px. Its good to know what yours are set at if you don't already. They determine the size of your grid as you're drawing it. If you want, you can use some checkerboard coloring to help distinguish the squares - like those I've been using in the examples above.
The reason for anyone to know them is that these trigonometric functions are fabulously useful in coding in Flash Adobe. Example? You probably can guess one by the title :-) Yes, circular movement.
Open the Macromedia Flash MX and create a new document with the size 345x231 pixels. Import in the stage the picture "clouds.jpg". For this, select File > Import, select the image and click "Open". Now, on the layer "layer 1" you have the picture with the clouds. In the stage, right click on the picture and select Convert to Symbol. In the new window which appears select "Movie clip":
If you've ever wanted to create a game in Flash that uses the arrow keys as the controls, here's the quick and easy way to do it. First, you need to draw the player. I used a circle, but you can use as much detail as you want. Next, make the drawing a movie clip and name it whatever you want (I named mine "player"). Add the player MC to the stage. Finally, you need to add the code. Open the actions for your player movie clip and add the following code:
In order to make the movement smoother, we're going to reduce how frequently the MC switches directions. In order to do that, we'll set a direction variables and increment the _x and _y properties with them. We'll then test a random number to see if we should change the direction variables.