View Full Version : An Obvious Problem?
Insane Knux
January 23rd, 2007, 09:07 PM
I know this is obvious but... I can't figure it out!
Okay, these arms look at the mouse. When he looks behind him, it should flip him over...
onEnterFrame = function(){
if(main._rotation <= 180){
main._xscale =+ 100;
}
if(main._rotation >= 180){
main._xscale =- 100;
}
}
If you don't understand... play StickManSam. http://www.crazymonkeygames.com/Stickman-Sam-3.html
Sort of like that... Help please?
SacrificialLamb
January 23rd, 2007, 11:01 PM
other than you don't need to have "+ 100" just "100" will do and both will be trying to happen if it == 180. what is going wrong because both things I pointed out will not stop it from working.
Try
onEnterFrame = function(){
if(main._rotation >90 || main._rotation < -90){
main._xscale = 100;
} else
main._xscale = -100;
}
}
The problem might be that the aTan2 rotation equation that is popular around here gives the angle between 180 and -180.
Insane Knux
January 24th, 2007, 06:01 PM
Thanks, but no dice :/
SacrificialLamb
January 24th, 2007, 06:58 PM
can you give the fla and/or "look at the mouse" code because what you have there 'could be right' but apparently is not so i (any one else that helps) will need more info
Insane Knux
January 24th, 2007, 07:12 PM
onClipEvent (enterFrame) {
Xd =_root._xmouse-_x; //Get _x distance from gun to mouse
Yd =_root._ymouse-_y; //Get _y distance from gun to mouse
radAngle = Math.atan2(Yd, Xd); //Use atan2 to calculate the angle from gun to mouse
_rotation = int((radAngle*360 / (2*Math.PI))+90); //Use PI to calculate and set gun rotation
}
SacrificialLamb
January 24th, 2007, 08:21 PM
where did you put the code i had made my code for the frame and that code as off the MC. also i missed a "{" after the else.
anyway this code i have working.
gun.onEnterFrame = function(){
Xd =_root._xmouse-this._x; //Get _x distance from gun to mouse
Yd =_root._ymouse-this._y; //Get _y distance from gun to mouse
radAngle = Math.atan2(Yd, Xd); //Use atan2 to calculate the angle from gun to mouse
this._rotation = int((radAngle*360 / (2*Math.PI))+90); //Use PI to calculate and set gun rotation
if(this._rotation >0){
bd._xscale = 100;
} else {
bd._xscale = -100;
}
}
put this on the frame.
bd is the name of the body
and gun is the name of the arm/gun
you have change the MC names in the code or on your MC
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.