View Full Version : when score reaches 150 gotoAndPlay scene...
New@actionscript
06-15-2008, 06:39 AM
There are alot of questions regarding this but i am trying to find the code for when the score reaches a certain point it with go to another scene called you win. i have tried all of the other answers but none have worked :(
so far in my game i have got the code to collect things when you go over them with the character and i have a timer that goes to 30secs. :)
I need as much help as i can for this one please help!!!!!! :confused:
THANKS ;)
DiamondDog
06-15-2008, 07:06 AM
Every time you update the score, test to see if it's reached your magic number.
If, as you say, you want to go to another scene, called "you win", you could do something like this:
// update the score
// ...
// ...
if(score >= 150)
{
gotoAndPlay(1,"you win"); // the first frame of a new scene called "you win"
}
On the other hand, if everything is in one scene, and you merely want to go to a frame that has been labelled "you win", you could do this:
// update the score
// ...
// ...
if(score >= 150)
{
gotoAndPlay("you win");
}
New@actionscript
06-15-2008, 11:30 AM
thanks for that :D although i am not sure if it works?
just in case it doesn't do you or does anybody else know any other code i could use!
thanks to all that can help!;)
atomic
06-15-2008, 02:00 PM
Don't target a scene name, but only a labeled frame in the targeted scene...
Thus, label the targeted frame in the targeted scene with an unique label such as you_win (no number only labels, or at least not starting off with a number, no spaces and no other special character than the underscore), add _root or _level0 to your path to target the main timeline, and only target that labeled frame on your script...
You could use an onEnterFrame that continuously monitors the value of score, something like...
this.onEnterFrame = function(){
if(score >= 150){
_level0.gotoAndPlay("you_win");
}
};
If it still doesn't work, attach your .fla to this forum...
DiamondDog
06-15-2008, 03:36 PM
Thanks, atomic.
My apologies. I was in AS3 mode.
atomic
06-15-2008, 03:54 PM
So it's working?
New@actionscript
06-16-2008, 08:13 AM
The Code:
// update the score
// ...
// ...
if(score >= 150)
{
gotoAndPlay(1,"you win"); // the first frame of a new scene called "you win"
}
and
// update the score
// ...
// ...
if(score >= 150)
{
gotoAndPlay("you win");
}
But it didn't quite work.
Although I haven't tried:
this.onEnterFrame = function(){
if(score >= 150){
_level0.gotoAndPlay("you_win");
}
};
what does the and ?:confused:
thanks :)
New@actionscript
06-16-2008, 08:15 AM
what does the b & the /b mean? :confused:
DiamondDog
06-16-2008, 09:39 AM
Try the code that atomic posted.
ie.
this.onEnterFrame = function(){
if(score >= 150){
_level0.gotoAndPlay("you_win");
}
};
The b and /b were just tags intended to turn some of the text BOLD, like this, but for some reason they didn't work. (I think on this forum you can't use tags like that within blocks of code. On some forums you can, and it works fine.)
The code that I posted earlier was written in AS3. My apologies for the confusion.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.