md_lasalle Posted August 17, 2017 Share Posted August 17, 2017 Hey guys, I'm about to release a game made with Phaser 2.8.2 targeting Desktop browsers. I was wondering if there's anything I need to do to make sure the code runs as optimized/smooth as it can on players browser? In native world, I would simply create a "release" type build with compiler optimizations enabled. Is there such a thing? Thanks. Link to comment Share on other sites More sharing options...
Arcanorum Posted August 17, 2017 Share Posted August 17, 2017 You will want to use some build tools that handle things like minifying code for smaller files, and merging files for fewer file requests from the server, to improve load speed. Use a texture atlas if you aren't already, and check out this tutorial http://phaser.io/tutorials/advanced-rendering-tutorial. I've found that WEBGL_MULTI works a lot better on desktop than mobile, so if you are having FPS trouble, this should work well for you. Link to comment Share on other sites More sharing options...
md_lasalle Posted August 17, 2017 Author Share Posted August 17, 2017 10 hours ago, Arcanorum said: You will want to use some build tools that handle things like minifying code for smaller files, and merging files for fewer file requests from the server, to improve load speed. Ok great, let me know if you have any tools you recommend. 10 hours ago, Arcanorum said: Use a texture atlas if you aren't already, and check out this tutorial http://phaser.io/tutorials/advanced-rendering-tutorial. I've found that WEBGL_MULTI works a lot better on desktop than mobile, so if you are having FPS trouble, this should work well for you. I'm actually using 3 2048x2048 texture atlases, but in my game, at some point I'm displaying items with a text label below them. I need a way to control the rendering of items manually. So instead of doing renderItem -> renderText, renderNextItem -> renderNextText. I'd need to do renderAllItems -> renderAllTexts. Which would minimize the amount of context flushes needed to render. I know that you can override a state's render function, and make sprites renderable to false, but is there a way for me to actually call mySprite.render() and decide the render order from there? I'd like to stay away from bitmap fonts since I need to support lots of languages. Link to comment Share on other sites More sharing options...
mattstyles Posted August 17, 2017 Share Posted August 17, 2017 UglifyJS is widely used for mushing up a file, although there are options, such as Google Closure Compiler, if you wanted to go down that route. Concat can be used to whip multiple files in to one, usually without hiccup. Anything more complex than that would require a bundler of some sort, which would mean more dev work to support. If you're just including multiple script tags to your source in your dev builds then concatting them in to one (in the same order as they appear in the html) should not cause a problem and reduces your request count to 1. Do the minification after concatting, it'll be more effective. If you're using any dependencies that can be built with a prod mode then you'll want to enable that when you build them, Phaser doesn't need this so if thats your only dependency you don't need to do anything, just use the minified build already available. If you've got any console logging going on then remove it for prod builds. There's no perf reason to do this (although it will slow down your app if someone has the console open, but, thats hardly a valid use-case) but it looks shoddy and it some cases could leak implementation details to anyone looking to do something nasty to your game. Beyond that most work going in to production will mean making sure your server is set up to handle proper load, stuff like gzipping, load balancing etc etc. Of course if you're using a third-party to host your game this will all be taken care of. You're probably already doing it as part of your dev work but doing a double pass over all the platforms you're looking to target with your code all concatted/minified/etc would be prudent. md_lasalle 1 Link to comment Share on other sites More sharing options...
Recommended Posts