A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: mc move towards another mc

  1. #1
    Member
    Join Date
    Jun 2009
    Posts
    44

    mc move towards another mc

    hello,
    i am having a problem with making an mc(fielder) move towards another mc(ball). The ball is always moving.
    the problem is that the fielder gets the shakes all the time(he goes all shaky)
    could anyone please help me.

  2. #2
    Ozzy the Grey
    Join Date
    Sep 2007
    Posts
    61
    ok let me give you some basic code okay on the following ball put this

    onClipEvent(enterframe){
    //if ball is farther right then move right
    if (_root.ball._x > this._x){
    this._x +=5
    //if its not farther right but farther left then move left
    }else if (_root.ball._x < this._x){
    this._x -= 5
    }
    //if ball is farther down then move down
    if (_root.ball._y > this._y){
    this._y +=5
    //if its not farther down but farther up then move up
    }else if (_root.ball._y < this._y){
    this._y -= 5
    }
    }

    this will make it follow now if it does shake make sure that the ball and fielder x and y placement doesnt have a decimal and there speeds have a common denomenator like 2 and 4, 1 and 2, 3 and 6, and such and such

  3. #3
    Member
    Join Date
    Jun 2009
    Posts
    44
    thankyou much

Tags for this Thread

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