Be a Supporter!

Reset level

  • 253 Views
  • 12 Replies
New Topic Respond to this Topic
dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Reset level 2009-03-23 13:05:12 Reply

I'm making a game, with some levels.
Now when one level is finished, it follows this code: gotoAndStop(2);
Then it gets at frame two, but then the sound of the previous level and all the movieclips are still there, how can I reset them, or anything? (It's a lot of work to removeMovieClip them all..)

ThePeasant
ThePeasant
  • Member since: Aug. 30, 2007
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Reset level 2009-03-23 13:10:30 Reply

that's exactly what you need to do.

dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Reset level 2009-03-23 13:13:56 Reply

Aah fuck x)

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Reset level 2009-03-23 13:13:59 Reply

At 3/23/09 01:05 PM, dudejonne wrote: I'm making a game, with some levels.
Now when one level is finished, it follows this code: gotoAndStop(2);
Then it gets at frame two, but then the sound of the previous level and all the movieclips are still there, how can I reset them, or anything? (It's a lot of work to removeMovieClip them all..)

Depending on what you want to delete, you can use a for loop. If you need to get rid of everything then you can use this

for(var i in _root){
	_root[i].swapDepths(789);
	_root[i].removeMovieClip();
}

To stop sounds, use stopAllSounds();

Obviously both of these need to be run before you initiate stuff for the second level


- - Flash - Music - Images - -

BBS Signature
dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Reset level 2009-03-23 13:18:02 Reply

Thanks! Thats somuch easier! :)
So something like:
[code]
if(levelfinish==true) {
for(var i in _root){
_root[i].swapDepths(789);
_root[i].removeMovieClip();
}
stopAllSounds();
gotoAndStop(2)
}
[/code]
Will do it? This is AS2 rights? ( with that 'var i in' stuff )

liam
liam
  • Member since: Dec. 11, 2004
  • Offline.
Forum Stats
Member
Level 22
Blank Slate
Response to Reset level 2009-03-23 13:50:11 Reply

At 3/23/09 01:18 PM, dudejonne wrote: Will do it? This is AS2 rights? ( with that 'var i in' stuff )

Yes. For the record the HTML you may use in a message is listed to the left of the text box (<a>, <strong>, <em>, <ins>, <code>).

Also, in an if statement you never need to use true or false, because the if statement is only checking for true or false anyway. If I have a variable named "hi" that is Boolean (true/false) and that is set to true the following code:

if(hi){
// do stuff
}

Will be the same as:

if(hi==true){
// do stuff
}

because hi is true on it's own. Likewise to check for "false" you use the ! operator like so:

if(!hi){
// do stuff if hi is false
}

So, when you're checking something like.. if score = 10, the following statement will be used:

if(score==10)

Because the statement "score==10" returns true if score = 10. It's kinda hard to explain statements and how they work, even though it's quite simple.


Sup, bitches :)

BBS Signature
dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Reset level 2009-03-23 14:12:35 Reply

I get it. I know it, but I forget to use it. Thanks ppl :)

dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Reset level 2009-03-24 13:20:55 Reply

Does this also removes the variables that are used or declared on that frame?

TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to Reset level 2009-03-24 13:30:53 Reply

At 3/24/09 01:20 PM, dudejonne wrote: Does this also removes the variables that are used or declared on that frame?

no, it wouldn't do that.

dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Reset level 2009-03-24 14:19:00 Reply

Hmm then there's an other problem..
If I declare a variable, like in this case: var score = 0;
And then in the next frame I have as code: scorefield.text = score;
That should work right?

TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to Reset level 2009-03-24 14:25:34 Reply

yeah. or you could just make the text box dynamic and have its var be score.

dudejonne
dudejonne
  • Member since: Sep. 13, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Reset level 2009-03-24 14:33:54 Reply

It ís a dynamic textfield with instance name thing scorefield.
scorefield.text= score;

Wow, I did a major discovery :D
On a previous frame I also had a textbox with name scorefield, so this one doesn't works :p
Now its named scorefield2 andit works.

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to Reset level 2009-03-24 15:04:08 Reply

At 3/24/09 02:33 PM, dudejonne wrote: It ís a dynamic textfield with instance name thing scorefield.
scorefield.text= score;

Wow, I did a major discovery :D
On a previous frame I also had a textbox with name scorefield, so this one doesn't works :p
Now its named scorefield2 andit works.

It depends where you declare the .text. The var is constantly updated, the .text is a one-off - so if you declare scorefield.text= score; before the dynamic textbox with the instance name scorefield exists, it won't show the text you send (once it DOES exist)


- - Flash - Music - Images - -

BBS Signature