Coder Social home page Coder Social logo

phaser-project-template's Introduction

What is the Phaser Project Template?

This is a simple project template I created to help add a structure 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

To get started all you need to do is download a copy of this template, the latest version of Phaser and make sure you have NodeJS and Grunt installed.

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.

If you have installed Grunt in the past you may want to remove it first:

> npm uninstall -g grunt

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 want to learn more about how all of this works check out my blog post on Automating TypeScript with Node and Grunt.

Setting up the Template's Dependencies

Via the command line, cd into the template's directory on your compute and run the following command:

> npm install

This will run through all the dependencies in the package.json file and install them locally for the project to use.

Next you will need to download a copy of Phaser's source code add it to your src directory. I keep it in a folder called src/libs/Phaser. Make sure you copy the main Phaser project code, you don't need the tests or other files floating around the directory.

After that you can simply run:

> grunt

In the directory and it will launch a browser with the default screen which will look something like this:

You can start building a game with Phaser by modifying the game.ts file inside of the src/game directory. While you have the Grunt task running in the browser your project will automatically recompile every time you make a change to any TypeScript file inside of the src directory. Make sure you disable your browser's cache to see changes.

What Else?

Since git doesn't include empty directories the one thing I would suggest adding is an assets directory in your deploy folder. This is where you should keep all of your externally loaded content such as sounds, sprites and textures. I usually create folders with the name of each type of media I am loading to keep things organized.

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.

phaser-project-template's People

Contributors

jessefreeman avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.