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




Reply With Quote