Here is a tutorial on how to make your character, object, car (or whatever you want!) to accelerate and decelerate to add a bit more life to the object.
In this first example we will be using a car which we will make. Hopefully you know the basics of flash if you dont here is a link to the basics.
Make sure your car has two wheels, one with the instance name “wheel” and the other “wheel1″ and a base called “car”.
So here is my car:-

Ok now we have the car lets get down to the scripting. In the first frame add this code :-

Here is what it means :-
lines 1 - 6 = Are setting up variables indicating the speed, friction, and a blank variable so we can add to it.
lines 8 - 14 = Setting up movement for the car - adding variables to the blank variable making the speed feature.
lines 16 - 22 = Adding the values to the x axis and rotation and making friction work. The way the friction works is by multiplying by a number which is of a 0.1-0.9 value. It slowly decreases making the car Decelerate. The way the acceleration is made is by having a blank variable we can add to it, to make an increasing number making it faster and faster aka accelerate.
Here is the finished .fla and .swf file.
Happy game making!!
Joshua Beynon
josh.thedude@hotmail.com
Did you find this tutorial useful? Do you have any questions about the tutorial or a request for another? Please sign up now and post your comments below!
Tags: accelleration, Add new tag, AS2, car, flash, friction, Josh




