A starting point to build a game with Phaser, using CommonJS modules to organise your code.
Parts included:
- Phaser: to build your games with
- Browserify: to organise your code in a CommonJS format
- BrowserSync: to test your code
- Jade: for templating
- Google Analytics: for tracking
You will need to have node, gulp and slush setup on your machine.
To install the generator, run the following command, making sure you use the global tag.
npm install -g slush-phaser-node
Navigate to where you want to develop your game (you can create a new folder too if you like).
$ cd /path/to/folder
$ mkdir myGreatGame
$ cd ./myGreatGame
Then call the slush template to begin.
$ slush phaser-node
Finally run gulp to launch a server.
$ gulp
When editing, make sure you update the files within the src
directory. These files will then be compressed and added to the bin
directory ready for publishing.
The JavaScript files have been set in a modular way using browserify. This means you can treat the files like you do with node
modules.
Google analytics have been included so that you can track user actions. This is useful for seeing how far the user gets, which in turn will alert you to any bugs or levels that are impossible to complete.
To track an event, just add the following code anywhere in your game:
game.analytics.trackEvent('action', 'label', 'value');
Only the action is required, but you may want to add extra options, such as health, level or simply what just happend.
Happy coding!
The MIT License (MIT)
Copyright (c) 2014 Matt Gale
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.