sinanqd10 Posted December 18, 2014 Share Posted December 18, 2014 Now I have only one javascript file which included many states there. Here is my sample code:var WelcomeState = { preload: function () { game.load.image('bg1', 'games/RockPaperScissors/assets/Game0002.png'); }, create: function () { game.add.sprite(0, 0, 'bg1'); }, start: function () { this.game.state.start('instruct'); }// other methods....};var InstructState = { preload: function () { game.load.image('bg2', 'games/RockPaperScissors/assets/Game0001.png'); game.load.image('guide', 'games/RockPaperScissors/assets/Game0015.png'); game.load.spritesheet('readyPlay', 'games/RockPaperScissors/assets/ready.png', 130, 46); }, readyPlay: function () { this.game.state.start('rockpaperscissor'); }// other methods....};var game = new Phaser.Game(480, 360, Phaser.AUTO, 'game_container', null, false, false);game.state.add('welcome', WelcomeState);game.state.add('instruct', InstructState);game.state.start('welcome');Can anyone tell me the best practice way to separate Javascript file in order to get better performance of the game? Link to comment Share on other sites More sharing options...
jouniii Posted December 18, 2014 Share Posted December 18, 2014 Separation doesn't really give you performance. Just convience on writing the code. Infact many of us use automated tools to combine and minify the separate files to get smaller file size and less files for browser to download. Good example for simple separation is in Phaser library and it's Grunt file itself. Link to comment Share on other sites More sharing options...
sinanqd10 Posted December 19, 2014 Author Share Posted December 19, 2014 @jouniii, Thanks you for answered. Is there any links guiding me? Link to comment Share on other sites More sharing options...
ranska Posted December 20, 2014 Share Posted December 20, 2014 http://gruntjs.com/getting-started there is olso in this posthttp://www.html5gamedevs.com/topic/11107-integartion-test-and-game-testing/pushing this link who can help youhttps://github.com/eguneys/generator-phaserjs Link to comment Share on other sites More sharing options...
Recommended Posts