I'm having problems with my 2d rotation script. Basically, it is supposed to rotate a list of objects around a central point (refered to by "this"). Here's the script, but it doesn't work properly, the points do not rotate about the center, they just sorta randomly fly around and distort in a perverted manner. This section of code is located in a for loop that goes through all the child objects and rotates each one about the parent object 'this':
Thanks to anyone who can figure this out. I've gotten this to work before in director, and i basically copied the script and converted it to JS, but it still refuses to work correctly.
Code:
//convert the angle to radians and switch the start axis
ang = (Math.PI/ 180) * (this.rotation + 90);
//get the relative coordinates on the object from the center
this.children[i].x = this.children[i].x - this.x;
this.children[i].y = -this.children[i].y + this.y;
//do calculation to procure new location
this.children[i].x = (Math.cos(ang) * this.children[i].x)-(Math.sin(ang) * this.children[i].y)
this.children[i].y = (Math.sin(ang) * this.children[i].x)+(Math.cos(ang) * this.children[i].y)
//convert back into normal coordinates
this.children[i].x += this.x;
this.children[i].y += this.y;
Thanks to anyone who can figure this out. I've gotten this to work before in director, and i basically copied the script and converted it to JS, but it still refuses to work correctly.