In my game I have a startGame() function which initializes all the key functions that start the game. At the beginning, you press the start button to take you to the game. Once the game is complete the restart button appears. When this is clicked it takes you back to the start screen, where the start button is. Ideally
I would like at this point to be able to click the start button for the second time, and a new game appear. The problem is that it brings the old game up. I have tried to use How can I restart all the functions when the restart-button is clicked?
Fiddle with script in: http://jsfiddle.net/rVaFs/
asked Nov 26, 2012 at 12:22
3 It will be much easier if you stop using globals: everything not prefixed with var (including functions). If your startplay depends on initial DOM state, and it’s too difficult (or just takes too much time) to rewrite the code, you can just make a copy of that part of DOM before starting game and delete it on finish. answered Nov 26, 2012 at 12:45
WuronWuron 315 bronze badges 1 You could use the
Another thing you have to keep in mind is that you're creating a lot of implied globals, which could cause problems if you were to use the answered Nov 26, 2012 at 12:41
11 I created a function
called
I then called it in the
answered Nov 27, 2012 at 13:06
sMilbzsMilbz 9497 silver badges25 bronze badges |