PDA

View Full Version : Drag and rotate problem



izikon
February 23rd, 2009, 10:54 AM
I have this swf that written in AS2
http://www.knowingames.com/test_ik_06.swf

if (stage.mouseX == _lastMouseX && stage.mouseY == _lastMouseY) {
return;
}
var dX:Number = stage.mouseX - _myClip.x;
var dY:Number = -(stage.mouseY - _myClip.y);
var angleRad:Number = - (Math.atan2(dY, dX) + Math.atan2(_offsetX, _offsetY));
_myClip.rotation = angleRad * 180 / Math.PI + 90 ;
//trace(drizzler.rotation);
var dxX:Number = (_offsetX*Math.cos(angleRad) - _offsetY*Math.sin(angleRad));
var dyY:Number = (_offsetX*Math.sin(angleRad) + _offsetY*Math.sin(Math.PI/2 - angleRad));

_myClip.x = stage.mouseX - dxX;
_myClip.y = stage.mouseY - dyY;

_lastMouseX = stage.mouseX;
_lastMouseY = stage.mouseY;


this _offsetX and _offsetY is where you pressing with the mouse
does anyone have idea why it doesn't working in AS3?
or have an exmple for rotate and drag phisycs

bLasTamos
February 23rd, 2009, 12:19 PM
Why doesn't it work? what happens?

izikon
February 23rd, 2009, 01:02 PM
well... it keeps on turing around the mouse instead of staying with the mouse

bLasTamos
February 23rd, 2009, 01:39 PM
Maybe its because you are inverting the Y axis and adding 90 degrees to the rotation, dunno how that affects things.

izikon
February 23rd, 2009, 05:40 PM
the problem is the the clip keeps on spining abround and not do what he needs to do