/boilerplate-phaser-es2016

:fork_and_knife: Example game based on Phaser.js. Use ECMAScript 2016 syntax.

Primary LanguageJavaScript

boilerplate-phaser-es2016

🍴 Example game based on Phaser.js. Use ECMAScript 2016 syntax.

Features ✔

  • Phaser v2.6.2
  • Webpack v2.2.1
  • Babel (ECMAScript 2015 + ECMAScript 2016 + Stage 0 of ECMAScript 2017)
  • super-event-emitter v4.1.4 as event management
  • Typings (Phaser, super-event-emitter) for syntax highlighters
  • Task to count line of code (LOC)
  • Simple structure for app: constants/, models/, states/
  • Example map (build in Tiled)
  • Static directory: public/
  • Maximum 80 characters per line in each file!

Steps to launch the project

$ npm install       # install dependencies
$ npm run build     # build distribution files in public/dist/

Development

$ npm run typings   # support syntax highlighters
$ npm run watch     # run Webpack to listen of file modifications

Misc

$ npm run clear     # remove all generated files
$ npm run count     # count LOC (line of code)

Troubleshooting

Uncaught TypeError: Cannot read property 'cache' of undefined

Player sprite does not have reference to main game object.

new Player();           // ERROR
new Player(this.game);  // OK

Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)'

List of used tileset in map should be defined after map setup.

this.map = this.add.tilemap('example-map');
this.map.addTilesetImage('street');     // MUST BE ADDED

License

The MIT License @ 2016