actionscript 3 - Rotate object around centre? -


i'm working on project , need wheel rotates mouse movement, i've made wheel rotate mouse, rotates around corner, not center.

what code can add make rotate around center?

this code i'm using far:

var dx : number; var dy : number;  stage.addeventlistener( event.enter_frame, checkmouse );  function checkmouse( evt : event ) : void { dx = mousex - rota.x; dy = mousey - rota.y; rota.rotation = (math.atan2(dy, dx) * 180 / math.pi); } 

you'll ever rotating object around origin, , origin can't moved. however, can move child object rest @ center of parent's origin. when rotating parent, child appears move around own center.

enter image description here

programmatically, if wheel child of rota, you'd following...

wheel.x = -wheel.width/2; wheel.y = -wheel.height/2;  rota.rotation = (math.atan2(dy, dx) * 180 / math.pi) 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -