It lags everytime assets are unloaded. However, if I change it to non-minified version of phaser.js, it does not lag. It lags only with phaser.min.js. How is this possible? They shouldn’t be different in anyway am I right?
Using the ASDW keys you can move about in the game. Terrain is loaded and unloaded as you move about. When terrain “chunks” are unloaded, it freezes for a second or so.
If I use the phaser.js instead of the phaser.min.js, it doesn’t lag. Also, if I override the tiles destroy function, like so: tile.destroy = function() {}
it doesn’t lag.
1024 sprites being destroyed sounds like much but I don’t know if that number is high or low really, I’m new to game programming.
But a thought I had when you said that. May this be a problem that occurs because Javascript it single-threaded? In another language, say Java/C# you would probably do that work in a separate thread while the main thread/GUI-thread continues displaying frames, and add the result of the separate thread to the GUI once calculations have completed?
How do you fella game-programmers deal with javascript being single-threaded? Or is it normally not a problem?