ForumsProgramming ForumHelp with Rotation

4 2988
chiliad_nodi
offline
chiliad_nodi
640 posts
1,260

onClipEvent (load) {
this._y = 1;
this._x = 1;
this.speed = 4;
}
onClipEvent (enterFrame) {
if (this._y>_root.mouse._y+5) {
this._y -= this.speed;
}
if (this._y<_root.mouse._y-5) {
this._y += this.speed;
}
if (this._x>_root.mouse._x-5) {
this._x -= this.speed;
this.gotoAndPlay(1);
}
if (this._x<_root.mouse._x+5) {
this._x += this.speed;
}
if (this._x<_root.mouse._x-1) {
this.gotoAndPlay(53);
}
if (this._x>_root.mouse._x+1) {
this.gotoAndPlay(1);
}
this.setProperty (this, _rotation, mouse)
}
onClipEvent (enterFrame) {
if (this.hitTest(_root.mouse)) {
_root.gotoAndPlay(3);
}
}
I need to change the line about rotation. I can't get it to rotate to face the movieclip "mouse" around line:
this.setProperty (this, _rotation, mouse)
Can somebody correct me?

  • 4 Replies
chiliad_nodi
offline
chiliad_nodi
640 posts
1,260

Amazing! I don't understand half the code, but it looks like it works. That bunch of code up there is the first actual coding I wrote for a movie clip in a game. I can see that I still a long way to go before I understand actionscript.
I have one other think that can be solved by soneone who knows actionscript.
if (this._x<_root.mouse._x-1) {
this.gotoAndPlay(53);
}
if (this._x>_root.mouse._x+1) {
this.gotoAndPlay(1);
This makes the animation only play 2 frames.
I need to make it play on the firt frame and on the 52 frame. all the coding inside the mc is set.

chiliad_nodi
offline
chiliad_nodi
640 posts
1,260

No, actually this is for changing the mc's frames depending on where the movieclip is in perspective of another mc. 1-52 are an animation and 53-104 are another animation.
Thanks.

chiliad_nodi
offline
chiliad_nodi
640 posts
1,260

Hang on. I just tried the first code you gave me, and the mc goes in the opposite direction of the mouse. It also faces away from the mouse. Since I don't really understand the code, can you please fix it? I think there was a misunderstanding. I want the eagle to follow a mc (instance)named "mouse"
Oh yeah. I am trying to have it change the set of frames it plays depending on whether it is to the left or to the right of the mc named "mouse."

chiliad_nodi
offline
chiliad_nodi
640 posts
1,260

What does Math.Pl mean?
Thank you for listening and correcting.
Sorry if I am asking too many questions.

Showing 1-4 of 4