I am trying to create a rotating menu that rotates around the horizontal axis. At first the menus rotate 360 degrees and it all worked fine and the distance between the menus are equally spaced.
But then I changed it so that the menus only rotate in half the circle. When the animation first plays, it runs sweet but after a while I start noticing the distance between the menus are no longer equally spaced. I have been trying to figure it out for days, but the solutions I come up with just doesn’t work at all.
It would be greatly appreciated if anyone could give me some help here. I can already imagine myself looking at this for the next few months and still don’t know what to do :crying:.
Here’s the function for rotating each of the menu, it is registered with the enter frame event.
In the constructor the angle of each menu is set to i * (maximumAngle - minimumAngle)/numberOfSelections + minimumAngle
where i goes from 0 to numberOfSelections
maximumAngle is 1.5 PI, minimumAngle is 0.5 PI.
//Move the menus according to rotate speed and angle
public function RotateSelections(e:Event):void {
//Calculate the x and y position
e.target.x = Math.cos(e.target.angle) * radiusX + centerX;
e.target.y = -1 * Math.sin(e.target.angle) * radiusY + centerY;
//Calculate the scale
var s = e.target.x /(centerX+radiusX);
e.target.scaleX = e.target.scaleY = s * scaleFactor;
//Calculate the angle
var newAngle:Number = e.target.angle + speed;
//Something could be wrong here, but I don't know what
if (newAngle > maximumAngle) {
//Selections are moving downwards
newAngle = minimumAngle;
} else if (newAngle < minimumAngle) {
//Selections are moving upwards
newAngle = maximumAngle;
}
//Sort out the depth
arrangeDepth();
}