A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Move to point

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Move to point

    I posted this in the pyhsics forum but ill post it here to

    How do i move a mc to a specific point from any ponit on the stage.

    That i want to for the mc to move at the same speed to the destination ?

    i know how to make it ease in but thats not what i want. What i want is to move at a steady speed.

    FOR EASING: i used this

    targetx = 0;
    targety = 400;

    _x += (targetx - _x)/speed;
    _y += (targety - _y)/speed;

    That eases into the position. What i want is to move at say a speed of 5.

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Maybe:

    if (targetx<_x){
    _x-=speed;
    }
    if (targetx>_x){
    _x+=speed;
    }

    and same for y coord.

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Thanks Tonypa, Im going to stick to the easing because in the long run it looks smoother but thanks heaps

  4. #4
    383,890,620 polygons nGFX's Avatar
    Join Date
    Oct 2002
    Location
    Germany / Ruhrgebiet
    Posts
    901
    why not use both?

    for couldron i used something like

    PHP Code:
    var VelX = (targetx _x)/speed;
    var 
    VelY = (targety _y)/speed;

    _x += (VelX MaxVel) ? MaxVel VelX;
    _y += (VelY MaxVel) ? MaxVel VelY
    so if you set a MaxVel of 5 it would move at a max speed of 5 and when it comes closer to the target it will slow down.

    <olli/>

  5. #5
    onClipEvent (enterFrame)
    Join Date
    Sep 2002
    Location
    The Outer Rim
    Posts
    104
    Double post...
    Last edited by mastermute; 01-29-2003 at 09:38 AM.
    The future is no longer what it used to be...

  6. #6
    onClipEvent (enterFrame)
    Join Date
    Sep 2002
    Location
    The Outer Rim
    Posts
    104
    Originally posted by nGFX
    why not use both?

    var VelX = (targetx - _x)/speed;
    <snip/>
    so if you set a MaxVel of 5 it would move at a max speed of 5 and when it comes closer to the target it will slow down.
    Nice! I'm gonna hang out in these threads!
    The future is no longer what it used to be...

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