What is the Phaser Project Template?
This is a simple project template I created to help add structure and automation to your next Phaser game. It includes the following things:
- A package.json for installing npm dependencies
- GruntFile.js for automating build tasks and compiling your game
- src folder where you can put your game code.
- deploy folder where all code gets compiled to and you can push to a server
Installing NodeJS and Grunt
You can get a copy of NodeJS on its site here and install it. After installing it you will want to install grunt from the command line.
Now you can install Grunt's command line tools by typing out the following:
> npm install -g grunt-cli
From here, Grunt should work via the command line. If you have never installed Node or Grunt, make sure you watch these two videos:
- Installing Git, NodeJS and PHP for Impact Game Dev Part 1
- Installing Git, NodeJS and PHP for Impact Game Dev Part 2
These two videos help walk you through how I have used Node and Grunt in the past with my other game starterkits. Note: You will not need to install PHP for this project which is covered in these videos.
Setting up the Template's Dependencies
Via the command line, navigate into the template directory's root and run the following command:
> npm install
This will download all the dependencies in the package.json file and install them locally for you to use.
After that you can simply run the following:
It will launch a browser with the default screen which will look something like this:
While I have included a version of Phaser to get you started, chances are very good that it is already out of date. Make sure you go to the Phaser github page and download the latest source code. Once you have that, simply copy the minified version of Phaser into the src/lib directory and replace the one that is currently there.
Also, if you are lost or need some point of reference I highly suggest going through each of the tests in the Phaser project to see how things work until more of the framework is documented.