Results 1 to 6 of 6
-
January 14th, 2003, 10:15 AM #12Junior Member
postsquestion about keeping score / defining a winner
I've made a game where you click on different floating objects to get different point amounts. I have a dynamic text box that has a variable set to score and then when the user presses the floating objects it adds points to the score.
That all works fine, but now I need an action so that
when the score reaches 100 it proclaims you as the winner.
Any suggestions?
-
January 14th, 2003, 10:57 AM #2
how about:
# = number of the frame with the message: You Win!Code:if (score>=100){ _root.gotoAndStop (#); }
-
January 14th, 2003, 11:08 AM #32Junior Member
postsThanks for your help!
Unfortunately I tried putting the code
if (score>=100){
_root.gotoAndStop (2);
}
on frame one of the movie (it's only 2 frames long) and when I rack up to 100 it still doesn't go on to frame 2. Any ideas as to why?
They way I'm adding points is with an action attatched to a button that says
on (release) {
_root.score = _root.score +5;
}
is there something wrong with that?
-
January 14th, 2003, 11:24 AM #4
-
January 14th, 2003, 11:53 AM #5
sen is right.
That happens cause the if condition in the frame doesnīt keep updating itself, it checks once (in the beggining) and the score is lower than 100, so it doesnīt do anything but when it reaches 100 the condition isnīt checking again.
You can place it on the on (release), of the button, like sen told you to do, and every time the button is released the condiditons is checked again.
-
January 14th, 2003, 12:01 PM #6
if you want to do it by frame, you can be a 'good' mx programmer and use object.watch

since you are 'watching' the score value in _root, you call watch from root and include "score" (variable to watch) and the function to be run whenever that variable changes, which in this case is onNewScore. onNewScore checks the score and sees if its over 100, and it it is, goes to frame 2. The return arguments[2]; just keeps the score from changing (since watch lets the onNewScore function change that value should it need to with a return argument, if you dont want to change it, just return arguments[2] which is the value it was changed to when this was called in the first place)Code:onNewScore = function(){ if (this.score >= 100) this.gotoAndStop(2); return arguments[2]; } _root.watch("score", onNewScore);

Reply With Quote



Bookmarks