|
-
How do I run a script until changing path?
I have a page I'm playing with. It's a very simple game with letters and numbers for my grandson (yes, I'm that old).
On a scene called MENU I can press a button to start. This button takes me to a scene called RANDOM.
This page will make a random number to take me to a random page. Either GAME1, GAME2, GAME3, and so on.
Here I want to make a count++. I also want it to check if the number have reached 5. Then it should take me to a bonus scene called BONUS.
If it haven't reached number 5, then it should just continue the script and load the random scene (GAME1, GAME2 or whatever).
When I press a letter or number on GAME1 it will either reload the same scene for another try or, if you press the correct letter it will move me to RANDOM to add 1 to the number of tries.
But I can't make it work the way I want.
On the MENU I have this code to set things to 0.
var count:Number = 0;
On the RANDOM scene I have this code on the first frame.
var maxTimesToPlay:Number = 5;
count++;
count_txt.text = count;
if(count == maxTimesToPlay){
gotoAndPlay('BONUS');
}else{
HERE I HAVE ALL THE RANDOM PARTS
}
And on the Game pages I have a code on the Letter or Number that is the correct one.
So if you press D, which is the correct one on GAME1, then I have this code:
on (release) {
gotoAndStop('RANDOM');
}
But there must be something wrong. Since it doesn't stop after 5 times.
I have tried to change things a lot of times and found some code here and there.
I'm not at home right now and not sure if this is the latest code I did use. But it is something like that.
Can anyone see what is wrong or maybe a better way to get it right?
I'm definitely a newbie.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|