Copy link to clipboard
Copied
Hi everyone,
I've been trying to code quite a complex mobile game using Flash CS6 and AIR similar in style to the game "Dots" for Android and iOS.
I have all the game distributed in scenes, as an example, "Scene 1" has all the contents and animations for the menu. and "Scene 2" has the actual game itself.
The code inside "Scene 2" creates a bunch of objects at the beginning, and then runs the code for the game using those objects.
There is a button inside "Scene 2" that returns you to the menu located inside "Scene 1".
Here's the problem: If i attempt to return to the game located inside "Scene 2" everything brakes. The reason this happens is because the code was executed once already, the objects and variables were created, and if you try and erase the objects and get into the scene again, it will crash because it is expecting for the objects to be there.
The code runs once for every scene, what i would like to do is reset everything once i return to the menu, and be able to play the game when i return to "Scene 2".
Basically, i would like to reset the scene and run the ActionSctipt located within the scene once again. Something similar to resetting the entire SWF file.
Copy link to clipboard
Copied
reload the game.
Copy link to clipboard
Copied
What would the code be to reload the current frame?
Copy link to clipboard
Copied
How do you code a button to restart the game?
Copy link to clipboard
Copied
either:
1. reset everything by hand
2. reload the swf with the code you want to reset.
Copy link to clipboard
Copied
Not helpful.
Copy link to clipboard
Copied
Another thing is, if i try to use frames instead of scenes to distribute the parts of the game and the levels, everything brakes down. buttons start moving to random locations, you can click them from far away, hit detection doesnt work anymore. I don't know if this is a common problem with Flash, but it has happened to me all the time, that's why i usually use Scenes with single frames to run all the game.
Copy link to clipboard
Copied
reload your swf.
Copy link to clipboard
Copied
I had success by following another user’s suggestion. Simply have a menu or loading screen on frame 1, then have your game on frame 2, or 10 to help keep it spaced out. Then just have a gotoAndStop command on your game frame so it doesn’t leave the frame until you’re ready. I had the reset button jump to the first frame that said “loading level...”