View Full Version : Smooth Movie Clip Rotation
Mr. Twinkles
September 13th, 2002, 05:00 PM
is there any way to get a smooth rotation in AS? I would assume i would use this._rotation, but it doesn't smoothly rotate the way i want it to...
I'm trying to make a movie clip that randomly goes to a location while rotating. here's what code i have now.
onClipEvent (load)
{
speed = .2;
xLocation = 0;
yLocation = 0;
}
onClipEvent (enterFrame)
{
if (Math.ceil(this._x) == xLocation && Math.ceil(this._y) == yLocation)
{
xLocation = random(390);
yLocation = random(190);
}
this._x = (this._x + (xLocation - this._x) * speed);
this._y = (this._y + (yLocation - this._y) * speed);
}
Any Ideas?
Mr. Twinkles
September 13th, 2002, 05:06 PM
Ok, i've put in a clip of code where it continuously rotates, but how do i get it so it slows rotation when it gets closer to the point it's going to?
i used this._rotation += random(20);
Mr. Twinkles
September 13th, 2002, 05:44 PM
I guess i might as well turn this into a tutorial, or someone else can, cause i figured out how to do this now.
This is the line of code to make it rotate, i put some extras in there to make it seem like it's rolling...
this._rotation = (yLocation - this._y) - (xLocation - this._x);
So there we go, i've solved my own problem.
upuaut
September 13th, 2002, 10:40 PM
Sorry no one replied to you in time. Glad you got it working though. Good job sir.
Bezzer
September 14th, 2002, 05:57 AM
hehe yeah good work...i was working on a menu thing once and it sorta stuffed up after clicking the button 3 or 4 times...
Rotate Thing (http://home.iprimus.com.au/berryfam/temp/rotate.swf)
i havn't looked it in a while...but yeah i dont know what the problem is...
i think that if i had a look it might work agian hehe :)
Mr. Twinkles
September 16th, 2002, 05:39 PM
Guess i might as well post this so that y'all can see what it looks like...only 1k. Sorry about it being geocities, just had to set something up real quick.
http://www.geocities.com/randommovement2002
By the way, here's the code:
onClipEvent (load)
{
speed = .1;
xLocation = 0;
yLocation = 0;
}
onClipEvent (enterFrame)
{
if (Math.ceil(this._x) == xLocation && Math.ceil(this._y) == yLocation)
{
xLocation = random(390);
yLocation = random(190);
}
this._x = (this._x + (xLocation - this._x) * speed);
this._y = (this._y + (yLocation - this._y) * speed);
this._rotation = ((yLocation - this._x) + (xLocation - this._y)/2);
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.