Home

Awesome

<h1 align="center"> <br> <a href="https://github.com/yandeu/phaser-project-template-es6#readme"><img src="readme/header-es6.png" alt="header" width="600"></a> <br> Phaser 3 ES6 Starter Template <br> </h1> <h4 align="center"> A starter template for <a href="https://phaser.io/" target="_blank" >Phaser 3</a> with <strong>ES6</strong> and <a href="https://webpack.js.org/" target="_blank" >webpack</a> for building excellent html5-games that work great in the browser and on mobile devices.</h4> <p align="center"> <a href="https://david-dm.org/yandeu/phaser-project-template-es6" title="dependencies status"> <img src="https://david-dm.org/yandeu/phaser-project-template-es6/status.svg?style=flat-square"/> </a> <a href="https://opensource.org/licenses/MIT" title="License: MIT" > <img src="https://img.shields.io/badge/License-MIT-greenbright.svg?style=flat-square"> </a> <img src="https://img.shields.io/github/package-json/v/yandeu/phaser-project-template-es6.svg?style=flat-square" alt="GitHub package.json version"> <img src="https://img.shields.io/github/last-commit/yandeu/phaser-project-template-es6.svg?style=flat-square" alt="GitHub last commit"> <a href="https://github.com/prettier/prettier" alt="code style: prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square"></a> </p> <p align="center"> <a href="#key-features">Key Features</a> • <a href="#preview">Preview</a> • <a href="#how-to-use">How To Use</a> • <a href="#enable3d">enable3d</a> • <a href="#progressive-web-app-pwa">PWA</a> • <a href="#native-app">Native App</a> • <a href="#custom-configurations">Custom Configurations</a> • <a href="#typescript">TypeScript</a> • <a href="#useful-links">Useful Links</a> • <a href="#multiplayer-game">Multiplayer Game</a> • <a href="#examples">Examples</a> • <a href="#credits">Credits</a> • <a href="#license">License</a> </p> <blockquote align="center"> Want to use TypeScript instead? Switch to the <a href="https://github.com/yandeu/phaser-project-template#readme" >phaser-project-template</a> </blockquote> <br> <br>

* * * * * *

⚠️ IMPORTANT

Please use the phaser-project-template instead!

Although it uses TypeScript under the hood, all TypeScript features are disabled by default. This means you can just write JavaScript (ES2015+) as you are used to. Give it a try! 👍

* * * * * *

<br> <br>

Key Features

Preview

This is what you get after installing this template. A simple and clean starter template written in ES6+. Try it!

<a href="https://s3.eu-central-1.amazonaws.com/phaser3-typescript/starter-template/index.html"> <img src="readme/screenshot.png" width="640" style='border: 0.25em solid #e1e4e8;border-radius: 20px;'/> </a>

How To Use

To clone and run this template, you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

# Clone this repository
$ git clone --depth 1 https://github.com/yandeu/phaser-project-template-es6.git phaser3-game

# Go into the repository
$ cd phaser3-game

# Install dependencies
$ npm install

# Start the local development server (on port 8080)
$ npm start

# Ready for production?
# Build the production ready code to the /dist folder
$ npm run build

# Play your production ready game in the browser
$ npm run serve

Change the gameName in /webpack/webpack.common.js.

All your game code lies inside the /src/scripts folder. All assets need to be inside the /src/assets folder in order to get copied to /dist while creating the production build. Do not change the name of the index.html and game.ts files.

enable3d

<a href="https://github.com/yandeu/enable3d#readme"><img src="readme/enable3d-logo.png" alt="enable3d logo" width="300"></a>

Want to add 3D objects and physics to your Phaser game? Checkout enable3d!

Progressive Web App (PWA)

PWA

This template is 100% PWA ready.

The ServiceWorker is disabled by default. Uncomment the line below inside /src/index.html to enable it.

<script>
  if ('serviceWorker' in navigator) {
    window.addEventListener('load', () => {
      navigator.serviceWorker.register('./sw.js')
    })
  }
</script>

You can easily personalize its settings by following these steps:

Read more about PWA on developers.google.com

Native App

The simplest way to build a Native App is using Capacitor and following its Documentation.

The only thing you need to change after installing Capacitor is the webDir inside the capacitor.config.json file. Set it to dist like so:

{
  "appId": "com.example.app",
  "appName": "YOUR_APP_NAME",
  "bundledWebRuntime": false,
  "webDir": "dist"
}

Custom Configurations

Babel Compiler

Change the Babel compiler's settings in the .babelrc file.

You'll find more information about the babel here.

Webpack

All webpack configs are in the webpack folder.

Obfuscation

We are using the webpack-obfuscator. Change its settings in webpack/webpack.prod.js if needed. All available options are listed here.

TypeScript

Want to use TypeScript instead of ES6? Switch to the phaser-project-template

Multiplayer Game

Making a multiplayer game? Check out geckos.io

Useful Links

Examples

Game Examples Built with the TypeScript Starter Template

Platformer Example [Play this game - Visit its Repository]

phaser3-typescript-platformer

Phaser 3 + Matter.js: Car Example [Play this game - Visit its Repository]

<a href="https://github.com/yandeu/phaser3-matter-car-on-curved-terrain#readme"> <img src="https://raw.githubusercontent.com/yandeu/phaser3-matter-car-on-curved-terrain/master/readme/myimage.gif" width="640" alt="phaser3-matter-car-example"> </a>

Credits

A huge thank you to Rich @photonstorm for creating Phaser

License

The MIT License (MIT) 2019 - Yannick Deubel. Please have a look at the LICENSE for more details.