Game Structure - How to organize a Phaser Project

Recommended Posts


I started a hobby project to learn Phaser ( It's lika a Clash Royale Soccer, with punchs (not implemented yet).

The code is growing and I need to split the game logic in more than one file. I have knowledge of some Javascript frameworks, like Sencha and JQuery Mobile, and I'm familiar to the MVC concept.

I'll probably try to create files for every game object (Player.js, Goal.js, Ball.js, etc.).

So I would like to ask: how do you organize your code files? Please send examples! 

Share this post

Link to post
Share on other sites

For me, I'm used to working with larger files 2000 lines or less(not really all that large, but to some it is) so I like to organized my code in about 3 - 4 files depending on the project. Usually states, sprites, managers and windows (if required) if I have specific mechanics I like to make a plugin which can be used in more than one game so ill do that and keep the logic separate from the game. The managers file can usually used in more than one game as well, as its basically just functions with asset urls and global functions. Other than that it's really all personal taste and how you like working, unless of course your working with a team. So really however you feel comtorable is how you should do it. 

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.