Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

10 years 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.

10 years ago by mr_j936

for future reference for lost souls who may come across this problem.I found my answer finally in This post

http://mandarin.no/article/startingrestarting-an-impactjs-game-without-reloading-the-page/

Reloading the game from scratch without refreshing the page. Works awesometacularly

10 years ago by stahlmanDesign

Nice tip.

This reminds me of how some technicians at Apple reportedly asked Dropbox how they integrated their service so tightly with the Mac OS X Finder. Dropbox had figured out some low-level things that the Apple team didn't even know how to do without a lot of research.
Page 1 of 1
« first « previous next › last »