A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Random move...orient to path?

Threaded View

  1. #1
    Junior Member
    Join Date
    Jul 2004
    Posts
    9

    Random move...orient to path?

    How do I make my MC point in the direction its moving?
    This is the code

    code:

    acceleration = 10;
    newpos = function () { ranx = Math.round((Math.random()*250));rany = Math.round((Math.random()*250));};
    newpos();
    this.onEnterFrame = function() {
    this._x += ((ranx-this._x)/acceleration);
    this._y += ((rany-this._y)/acceleration);
    if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
    newpos();
    }
    };



    EDIT: I added [ as ] tags to your code for readability. See the forum guidelines. - jbum
    Last edited by jbum; 10-15-2004 at 06:36 PM.

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