A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: acceleration problem

  1. #1
    Member
    Join Date
    Nov 2001
    Posts
    30
    hi,
    I am unable to notice any visible change in the motion of my MC if I use the following code:
    onClipEvent (load) {
    function accel (finalX) {
    distance = finalX-_x;
    if (distance > 0) {
    _x += ( _x * .4) ;
    }
    }
    }
    onClipEvent (enterFrame) {
    this.accel(400);
    }

    what is wrong here?

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Cant see anything wrong here
    It accelerates quite well.

    Maybe your distance between finalX and _x is too small, so you dont notice, how the speed grows.

  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    I haven't tried it but theoretically speaking you should make the amount to move by depend on the distance variable, not _x.

    So if you are not happy with your current code, try:

    _x += distance/0.6;

    (if you use 0.4, it will go further and further away - value needs to be larger than 0.5 to get closer to the target location, use larger than 1 for an easing effect, smaller than 1 for a spring effect)

    not sure if this was what you were after...

    - n.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center