Jump to content

Recommended file structure?


Recommended Posts

it depend on the complexity of your project, if you are the only developer, if you plan future versions of your game ...etc

for 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 layer

if 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


i'm a little confused too on how to structure Phaser 
what's the difference between
function create () 
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 syntax

var myObject = {

   create:function() {...}


witch is the equivalent of :

var myObject = {}

myObject.create = function() {...}

but again, this is JavaScript syntax, nothing to do with Phaser ;)


Link to comment
Share on other sites

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



Link to comment
Share on other sites

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

Here's the basic template I use for all my simple js projects, including the Phaser project I'm working on:




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


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...