xtreme Posted April 15, 2014 Share Posted April 15, 2014 I am new with phaser and have looked at some examples. Some have just one. JS-file (and Phaser JS of course) while other have multiple files (such http://www.lessmilk.com/).What is the recommended file structure? Say for example, I'll make a snake game. Link to comment Share on other sites More sharing options...
Ezelia Posted April 15, 2014 Share Posted April 15, 2014 it depend on the complexity of your project, if you are the only developer, if you plan future versions of your game ...etcfor a snake game (like the one on nokia 3310), I'll use a single file.for this same snake game with multiplayer support, I'll add another file for networking layerif I want a snake that can spawn others snakes and mutate to another creatures depending on some evolution tree, I'll maybe use a more complex structure. Link to comment Share on other sites More sharing options...
rich Posted April 15, 2014 Share Posted April 15, 2014 I agree with Ezelia - it depends how complex your game is. If you look in the Phaser repository in the 'resources / Project Templates' folder you will find some examples of setting-up proper multi file projects you can copy. Link to comment Share on other sites More sharing options...
hugo Posted April 16, 2014 Share Posted April 16, 2014 i'm a little confused too on how to structure Phaser what's the difference betweenfunction create () and create: function () Link to comment Share on other sites More sharing options...
Ezelia Posted April 16, 2014 Share Posted April 16, 2014 i'm a little confused too on how to structure Phaser what's the difference betweenfunction create () and create: function () this is not a phaser question, this is JavaScript syntax function create() {...} is a standalone function declaration.if you want to declare a function inside an object, you can use the other syntaxvar myObject = { create:function() {...}}witch is the equivalent of :var myObject = {}myObject.create = function() {...}but again, this is JavaScript syntax, nothing to do with Phaser hugo 1 Link to comment Share on other sites More sharing options...
pat Posted April 16, 2014 Share Posted April 16, 2014 Hello all, This question is very interesting and please excuse this new question.When I am looking at phaser in the 'src' directory I have all the source in a lot of files and folders.in the 'bin' folder I have only one file that contains the whole source.What program are you using to 'compile' all the source in one file. Thanks a lot Patrick Link to comment Share on other sites More sharing options...
rich Posted April 16, 2014 Share Posted April 16, 2014 We use a series of Grunt tasks. Open the tasks folder and you'll see them all. http://gruntjs.com/ Link to comment Share on other sites More sharing options...
pat Posted April 16, 2014 Share Posted April 16, 2014 Thanks a lot, If you have time, it will be a good idea to explain the use of Grunt in your blog. Another thing.In the file src/intro.js the function is not closed.is it a bug or is it the good thing to do because intro.js is the first file to add in the grunt task (gruntFile.js)(function(){ var root = this; Link to comment Share on other sites More sharing options...
rich Posted April 16, 2014 Share Posted April 16, 2014 Look at the manifest files in the tasks folder, specifically the order in which they are put together. Then look at where Intro and Outro are in the list. Should give you the answer you need Link to comment Share on other sites More sharing options...
pat Posted April 16, 2014 Share Posted April 16, 2014 Thanks a lot.I understand :-) Link to comment Share on other sites More sharing options...
David Posted April 19, 2014 Share Posted April 19, 2014 Here's the basic template I use for all my simple js projects, including the Phaser project I'm working on: https://github.com/david0178418/simple-js-amd-app-boilerplate Note that I still need to push some stuff on builds that I'm refining in my local branch's gruntfile. I'm probably going to make a phaser-specific version of this since I think I'm using a structure that suits my needs pretty well. It would be the same thing as the above template along with some folders for "entities" and "states" as well as a few more base things that get the app going immediately. Anyone know if there is a non-typescript yeoman template? If you haven't formed any obnoxious opinions like I have already, that would probably be the best way to go. That way, you can spend more brain cycles on your game logic rather than meta things like your file structure. Link to comment Share on other sites More sharing options...
CtlAltDel Posted April 19, 2014 Share Posted April 19, 2014 @David: http://codevinsky.ghost.io/phaser-tutorial-getting-started-with-generator-phaser-official/ Link to comment Share on other sites More sharing options...
marvster Posted April 19, 2014 Share Posted April 19, 2014 I use phaser-official by codevinsky.It allows to generate states and prefabs as well:http://codevinsky.ghost.io/phaser-tutorial-getting-started-with-generator-phaser-official/ Link to comment Share on other sites More sharing options...
STuFF Posted April 20, 2014 Share Posted April 20, 2014 +1 for previous answer. love the generator Link to comment Share on other sites More sharing options...
Recommended Posts