-
Rotationing help
hello people, I am making a game where you are a car that rotates so that it faces the direction of the mouse. when you click you start to accelerate.
what is bad is i am using two scripts, one of them you need the car to face left at default to rotate right, and one you need it to to face up at default.
The scripts work different and I haven't been able to figure out a way so that both the scripts make it so that it only faces one direction. I don't care which direction, its as long as i know which direction.
here's my script..... its ACTIONSCRIPT 2.0
I use flash CS3... wait that won't affect.
Code:
onClipEvent(load){
speed = 0;
}
onClipEvent (enterFrame) {
a1 = this._y-this._parent._ymouse;
b1 = this._x-this._parent._xmouse;
angleA1 = Math.atan2(a1, b1);
degrees = angleA1/(Math.PI/180);
this._rotation = degrees;
onMouseDown = function(){
acc = "yes";
}
onMouseUp = function(){
acc = "no";
}
if (acc=="yes") {
speed += 0.5;
}
if (Math.abs(speed)>10) {
speed *= .7;
}
speed *= .98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.land.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
} else {
speed *= -.6;
}
}
-
x = speed * Math.cos(_rotation/180*Math.PI);
y = speed * Math.sin(_rotation/180*Math.PI);
-
-
uh oh... that didn't work! It still had to be 2 directions, and now it goes backwards!!!!!
-
that will change depending on the initial direction of your MC you can change that, or have fun playing around changing the 180 to something else :P
-