1 decade ago by mr_j936
Hello. I got myself in a big javascript mess I hope I can get some help. It's a long story, I'll try to keep it as brief as possible.
I am making a multiplayer web game with angular js and impact js. Impact is used for the actual game while impact is for the menu screens and logging in and chat box etc... Basically angular is the container.
Now angular js creates a single page application, which for the purposes of this question means that the browser never refreshes or reloads anything. The canvas element is removed from the screen by javascript and is drawn to the screen again by javascript when it is needed. And to allow my impact js code to draw inside the canvas, I wrapped my entire main code inside a function, and I call this function when I know the canvas is drawn so that my game would load.
This whole thing works for the first time an impact js game is started, I call my method as mentioned, and the game loads inside the canvas and everyone is happy. However if a user moves to another template and then moves back to the canvas template. This time the impact js loads but with many drawing bugs and problems. It seems that the previous load is somehow saved inside something that persists inside the document.
I am hoping to get some help on how I can manually purge my document from the old impact code and reload a fresh one without refreshing the page.
Refreshing is not an option, not because of my choice of engines, but because the whole app works with sockets. a socket is authenticated and has a state, refreshing would cause the socket to lose its state and reconnect, which would defeat the purpose.
I am making a multiplayer web game with angular js and impact js. Impact is used for the actual game while impact is for the menu screens and logging in and chat box etc... Basically angular is the container.
Now angular js creates a single page application, which for the purposes of this question means that the browser never refreshes or reloads anything. The canvas element is removed from the screen by javascript and is drawn to the screen again by javascript when it is needed. And to allow my impact js code to draw inside the canvas, I wrapped my entire main code inside a function, and I call this function when I know the canvas is drawn so that my game would load.
This whole thing works for the first time an impact js game is started, I call my method as mentioned, and the game loads inside the canvas and everyone is happy. However if a user moves to another template and then moves back to the canvas template. This time the impact js loads but with many drawing bugs and problems. It seems that the previous load is somehow saved inside something that persists inside the document.
I am hoping to get some help on how I can manually purge my document from the old impact code and reload a fresh one without refreshing the page.
Refreshing is not an option, not because of my choice of engines, but because the whole app works with sockets. a socket is authenticated and has a state, refreshing would cause the socket to lose its state and reconnect, which would defeat the purpose.