Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-03-2012, 01:08 PM   #1
vandread
Registered User
 
Join Date: Apr 2012
Posts: 5
Default [AS3] Game Reset

Hi,

Does anyone have good ideas on how to reset the game.

When the player presses the Try Again button?
I'm currently reloading the swf file, but I want other options..
vandread is offline   Reply With Quote
Old 05-03-2012, 02:02 PM   #2
Poony
Senior Member
 
Poony's Avatar
 
Join Date: Aug 2011
Location: Sweden
Posts: 389
Default

When resetting a game, all you're really doing is resetting the variables and returning to the desired graphical state. There is no golden answer to what you're asking for, it totally depends on your game and structure.

I usually implement a resetAll function that i can call whenever.
Poony is offline   Reply With Quote
Old 05-03-2012, 02:22 PM   #3
vandread
Registered User
 
Join Date: Apr 2012
Posts: 5
Default

Yeah. I just made a gameStart function that adds all the eventlisteners and positions.
when I reset the game i just call the gameStart() :P
vandread is offline   Reply With Quote
Old 05-03-2012, 07:18 PM   #4
Scearezt
Satisfied User
 
Scearezt's Avatar
 
Join Date: Jun 2010
Location: C:\\System32\Hungary
Posts: 426
Lightbulb

Seperate gameStart and restartGame functions. So the functions won't depend on each-other, therefore you can call them whenever you need it.
Scearezt is offline   Reply With Quote
Old 05-04-2012, 09:12 AM   #5
PasD
pseudoActionscripter
 
Join Date: Apr 2012
Posts: 68
Default

if your code if frame based, you can try
//Object(root) or whevever you store your game stuff, e.g root.map
for (var prop in Object(root)){
delete Object(root)
}
//that deletes everything, then you can go to the first frame or the frame to load that level or whatever to start the game again.
__________________
PseudoActionScript Console: Control your flash movie, at runtime, using 'actionscript'.
PasD is offline   Reply With Quote
Old 05-04-2012, 03:35 PM   #6
rrh
throw a trace() in there
 
Join Date: Dec 2006
Posts: 1,982
Default

But if you delete everything like that, I think there's a risk the EventListeners will still keep running, so you should remove all them first, then add them to your newly created first frame.
rrh is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:36 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.