Making your jet movement so real
In the last tutorial, I had explained to you how to movement a Movieclip with arrow key on the keyboard to any direction. For anyone who not yet read that, you can read that here.
In the tutorial “Drive your jet, Man” jet plane movement seen stiff and not real. If you forgotten or never tried, please try and watch this.
Isn’t it true jet plane movement is stiff and not real?
Now I will try you to know how to make jet plane movement smooth and real.
1. If you not yet had the file jet.fla, please download here before : jet.fla
And than open the action panel jet movieclip.
2. Put this code,
xb = 20;
yb = 20;
in the line “ onClipEvent(load){ } “be like this :
onClipEvent(load){
speed = 20;
xb = 10;
yb = 10;
}
3. Change the code in the line “ onClipEvent(enterFrame){ } “ be like this :
onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
xb += speed;
}else if(Key.isDown(Key.LEFT)){
xb -= speed;
}
if(Key.isDown(Key.DOWN)){
yb += speed;
}else if(Key.isDown(Key.UP)){
yb -= speed;
}
this._x = _x + (xb - _x) / speed;
this._y = _y + (yb - _y) / speed;
}
4. Before all, save the change your have done than press “ Ctrl + Enter “. Result of it will be like this :
See, jet plane movement be smooth and real.
Is this the code who make jet plane movement smooth :
this._x = _x + (xb - _x) / speed;
this._y = _y + (yb - _y) / speed;
Why ?
Let study!
• this._x and this_y = coordinate x and y obeject
• _x and _y = the last coordinate x and y object
• xb and yb = value change of coordinate x and y
• speed = speed of coordinate change
if _x = 0, xb = 20 and speed = 10, the code look like this :
this._x = 0 + (20 – 0) / 10
the result is :
this._x = 2, then
this._x = 3.8, then
this._x = 5.42, and so on till value _x equal to value xb
Change of the object coordinate successively by leaps and by bounds make movement of object seen the refinement and real.
try to change the value xb and yb in the line ” onClipEvent(load){ } “, watch and learn until you understood what the meaning of the code.
Good luck! In the next tutorial your jet can shoot. See you there!
Related Posts :





































i was woundering if it is possible to make it shoot enemies or something like that ? just like an easy arcade game and to make borders so that the jet wont fly out.
Flashfanz Reply:
August 28th, 2008 at 5:26 am
Thanks Man ! Don’t missing next tutorials.
it doesn't work Reply:
November 9th, 2008 at 7:23 am
its full of errors, can u just write down the script needed without explanation for me, that would be great! thx for the tutorial
[...] 1. Drive your jet, Man! 2. Making jet movement so real [...]
[...] 2. Making jet movement so real [...]
hey great tutorial i was just wondering if you could write the entire code so i dont have to change anything because my jet still is moving badly and after changing the code it just got faster!
is there any way that the jet can’t leave the window