I'm trying to rotate a movie clip. Simple enough?
rot is the increment that I want the MC to rotate at. it equals 1 at present. destx and desty are the destination x,y coordinates of my MC.Code:dpx = _x-destx; dpy = _y-desty; distance = Math.sqrt(Math.pow(dpx, 2)+Math.pow(dpy, 2)); angle = Math.round(180*Math.atan2(dpy, dpx)/Math.PI)-90; if (angle>180) { angle -= 360; } else if (angle<-180) { angle += 360; } if (_rotation<angle) { _rotation+=rot; } else if (_rotation>angle) { _rotation-=rot; }
I'm having a hard time explaining this. The MC needs to be able to rotate to angle using the increments, but as we all know, _rotation goes from -180 to 180. Therefore, the MC rotates allllll the way back around (ie, it doesn't rotate the shortest distance) to get to the opposite "side."
I want this because I don't like that my MC would instantly jump to whatever angle the destination is at and then move. It's for aesthetics. I just need another brain to help me think about this.




Reply With Quote