adamkdean Posted September 20, 2015 Share Posted September 20, 2015 Hi all, Seasoned developer here. I'm looking at using Phaser as an easy way to visualise some simulations. In the docs, the author hints at a better way of organising your code: "The final parameter is an object containing four references to Phasers essential functions. Their use is thoroughly explained here. Note that this object isn't required - Phaser supports a full State system allowing you to break your code into much cleaner single objects. But for a simple Getting Started guide such as this we'll use this approach as it allows for faster prototyping." Does anyone have an example of this? Thanks! Adam Link to comment Share on other sites More sharing options...
rich Posted September 20, 2015 Share Posted September 20, 2015 There's an example in the repo in the resources folder (Project Templates) showing how to use States instead of global functions. Hopefully that will get you going. For a complete in-depth guide on how States work it's part of issue 1 of Interphase (disclosure: commercial book, not free) Link to comment Share on other sites More sharing options...
adamkdean Posted September 20, 2015 Author Share Posted September 20, 2015 There's an example in the repo in the resources folder (Project Templates) showing how to use States instead of global functions. Hopefully that will get you going. For a complete in-depth guide on how States work it's part of issue 1 of Interphase (disclosure: commercial book, not free) Thanks Rich. Do you have a link to the book? (I'm guessing it's not going to be revealed to me in a Star Trek novel!) Regards, Adam Link to comment Share on other sites More sharing options...
rich Posted September 20, 2015 Share Posted September 20, 2015 http://phaser.io/interphase/ Link to comment Share on other sites More sharing options...
NateTheGreatt Posted September 20, 2015 Share Posted September 20, 2015 I regularly utilize require.js to help organize my codebases. I'm not sure if it fits your organizational desires but you can check out this repo for an example of how I usually go about it in tandem with Phaser if you want. Every state, sprite, component, etc. has its own file. Require.js essentially treats the folder structures as namespaces that you gain access to via definitions in the beginning of each file. hoskope 1 Link to comment Share on other sites More sharing options...
drhayes Posted September 21, 2015 Share Posted September 21, 2015 Similarly, I really like browserify or webpack for concatting, minimizing, and some other assorted tricks. hoskope 1 Link to comment Share on other sites More sharing options...
staff0rd Posted January 8, 2016 Share Posted January 8, 2016 I regularly utilize require.js to help organize my codebases. I'm not sure if it fits your organizational desires but you can check out this repo for an example of how I usually go about it in tandem with Phaser if you want. Every state, sprite, component, etc. has its own file. Require.js essentially treats the folder structures as namespaces that you gain access to via definitions in the beginning of each file. This is a great example, very clean. Thanks for sharing. hoskope 1 Link to comment Share on other sites More sharing options...
hoskope Posted January 8, 2016 Share Posted January 8, 2016 I don't have experience on the subject, but here's handbook for Browserify : https://github.com/substack/browserify-handbook Link to comment Share on other sites More sharing options...
Recommended Posts