Hello everyone,
right now I have a stick figure that walks towards the mouse cursor. I want his arm to rotate so that he points to the cursor. I have an UpperBody_mc and inside of it I have the arm that needs to rotate. I am accessing it by doing this UpperBody_mc.Arm_mc._rotation. The rotation code isn’t the problem I believe its just how I am accessing the arm or something…
heres all the code
speed = 1
onEnterFrame = function()
{
Mx = _root._xmouse;
My = _root._ymouse;
CharX = (UpperBody_mc._width/2)+UpperBody_mc._x;
if(Mx-20 < CharX && Mx+40 > CharX)
{
Legs_mc.stop();
}
else if(Mx-20 > CharX)
{
if(UpperBody_mc._xscale < 0)
{
UpperBody_mc._xscale *= -1;
Legs_mc._x -= 5;
Legs_mc._xscale *= -1;
}
UpperBody_mc._x += speed;
Legs_mc.play();
Legs_mc._x += speed;
//Arm movement
}
else
{
if(UpperBody_mc._xscale > 0)
{
UpperBody_mc._xscale *= -1;
Legs_mc._xscale *= -1;
Legs_mc._x += 5;
}
UpperBody_mc._x -= speed;
Legs_mc.play();
Legs_mc._x -= speed;
}
}
onMouseMove = function()
{
adjside =_root._xmouse - _root.UpperBody_mc.Arm_mc._x;
oppside = -1*(_root._ymouse - _root.UpperBody_mc.Arm_mc._y);
angle = Math.atan2(oppside, adjside); // in radians
angle = Math.round(angle/Math.PI*180); // convert to degrees
_root.UpperBody_mc.Arm_mc._rotation = -1*(angle);
}
heres the swf. http://img406.imageshack.us/my.php?image=testguyfc1.swf
heres the fla. [COLOR=#0000ff]http://download.yousendit.com/C9D1DE39116F4832[/COLOR]