• home
  • forum
  • my
  • kt
  • download
  • Home / 2D Graphics / Flash / Games /

    Making your jet movement so real

    Author: 2008-10-08 13:33:34 From:

    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!

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      3D (20)
      Math Physics (14)
      3rd Party (5)
      Navigation (60)
      Actionscripting (26)
      Optimization (16)
      Animation (32)
      Projector (9)
      Audio (46)
      Special Effects (112)
      Backend (25)
      Text Effects (65)
      Drawing (18)
      Tips and Techniques (41)
      Dynamic Content (25)
      Tricks (6)
      Games (97)
      Utilities (21)
      Getting Started (91)
      Video (24)
      Interactivity (43)
      Web Design (29)

    New

    Hot