-
[MX04] change pt of rotation
hey lets say i have a square movie clip regestered at the center.
so
_rotation+=5
would rotate the square about the center.
how would I (IN ACTIONSCRIPT) change the point of regestration so i can get the square to rotate about a corner or even further.
If anyone can help me Please feel free it IM colbyneedshelp99 (AIM).
-
Interested User
Don't know if it's possible but otherwise you can put an pic_mc inside rotating_mc and moving the pic_mc off center which will give you the same effect.
There is "actionally" a truth to be found in flash.
-
cool..... can sombody give me the mathmatics of rotation around a certain point. Im pretty sure u need arctangent.
If anyone can help me Please feel free it IM colbyneedshelp99 (AIM).
-
All 1s and 0s
Hi,
It is faster and easier to do what Rohm suggests. Make your square a movieClip within another movie clip. Then by moving the movieClip of the square off-centre and rotating the parent clip, you can achieve a rotation about any point you please. However, if you really want to do it with maths:
code:
MovieClip.prototype.rotateAroundPoint = function(xCo:Number, yCo:Number, theta:Number) {
//Rotate the clip by theta;
this._rotation += theta;
//Convert theta to radians for Maths calculations;
theta = theta * Math.PI / 180;
//Get the x and y disances of our clip from the rotation point;
var xd:Number = this._x - xCo;
var yd:Number = this._y - yCo;
//Work out the current angle from the rotation point to our clip;
var currentAngle:Number = Math.atan2(yd, xd);
//Add theta to the current angle;
var resultAngle:Number = currentAngle + theta;
//Work out the distance from the rotation point to our clip;
var d:Number = Math.sqrt(xd*xd + yd*yd);
//Calculate the new x and y coordinates;
this._x = xCo + d * Math.cos(resultAngle);
this._y = yCo + d * Math.sin(resultAngle);
}
//Example
movieClip.rotateAroundPoint(100, 100, 60);
Simply enter the x and y coordinates of the point you want to rotate around and then the amount of rotation in degrees.
"If I have seen further, it is by standing on the shoulders of giants." - Sir Isaac Newton
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|