Mr. Ed
Nov 6th, 2005, 08:41 PM
I'm programming a stop and go game where you control a little character that moves right when you hold space and there is another character randomly turning around and if they are facing you while you're moving, you lose.
On the stage I have a movie clip of the turning character which has three frames in it, one with her back turned, one facing straight ahead and one facing the moving character. The code I'm using on the movie clip so far is:
onClipEvent (enterFrame) {
rand = Math.random();
if (rand<0.1) {
this.gotoAndPlay(2);
} else {
this.gotoAndStop(1);
}
}
The problem is it's running on every frame, so she never makes it to the third frame, she just quickly goes to the second frame and instead of advancing to the third she goes back to the first. I need to find a way to make the code only work when she's on the first frame. I've tried putting the code on the first frame in the movie clip but it had issues. Can anyone help?
On the stage I have a movie clip of the turning character which has three frames in it, one with her back turned, one facing straight ahead and one facing the moving character. The code I'm using on the movie clip so far is:
onClipEvent (enterFrame) {
rand = Math.random();
if (rand<0.1) {
this.gotoAndPlay(2);
} else {
this.gotoAndStop(1);
}
}
The problem is it's running on every frame, so she never makes it to the third frame, she just quickly goes to the second frame and instead of advancing to the third she goes back to the first. I need to find a way to make the code only work when she's on the first frame. I've tried putting the code on the first frame in the movie clip but it had issues. Can anyone help?