JavaScript restart canvas script
I have a canvas script written in <script> tag in HTML body, with global
variables. It include the game code. Now I want to add some restart option
(for example when player die, restart the game). How can I reload all
things/main script? I tried to remove <canvas> tag from HTML and add it
again, but the game animation (after that) stops and it shows the first
keyframe (which is visible after game restart) is the last one from the
game before. At the moment the only way for me is location.reload(), but
it's a really bad solution.
So the question is - is there any way to restart whole script? I want to
make it work like after page reload (default everything). I can use only
pure JavaScript.
Thank you for help.
No comments:
Post a Comment