Giter Club home page Giter Club logo

phaser-project-template-es6's Introduction


header
Phaser 3 ES6 Starter Template

A starter template for Phaser 3 with ES6 and webpack for building excellent html5-games that work great in the browser and on mobile devices.

GitHub package.json version GitHub last commit

Key FeaturesPreviewHow To Useenable3dPWANative AppCustom ConfigurationsTypeScriptUseful LinksMultiplayer GameExamplesCreditsLicense

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


* * * * * *

⚠️ 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! 👍

* * * * * *



Key Features

  • ESNext features ready (async/await, Rest/Spread operators)
  • Code Splitting
  • Obfuscation
  • Development Server with SourceMap and Live-Reload
  • PWA ready with offline support and "Add to Home screen" install prompt
  • Easy to build Native App using Capacitor
  • Includes Phaser 3 TypeScript typings
  • For development and production builds
  • Adds a webpack ContentHash to the JavaScript files (in production)

Preview

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

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

enable3d logo

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:

  • Replace both icons in /pwa/icons with your own.
    • One is 512x512 the other 192x192
  • Add your own favicon.ico to /src
  • Adjust these parameters in the manifest.json file in /pwa
    • short_name: Max. 12 characters
    • name: The full game name
    • orientation: "landscape" or "portrait"
    • background_color: color of the splash screen
    • theme_color: color of the navbar - has to match the theme-color in the index.html file
  • You can leave the sw.js (serviceWorker) in /pwa how it is.
  • Change the gameName in /webpack/webpack.common.js

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]

phaser3-matter-car-example

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.

phaser-project-template-es6's People

Contributors

budda avatar dependabot[bot] avatar yandeu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phaser-project-template-es6's Issues

I can't get enable3D to work with Phaser 3.

I have a main.js file with the configuration, all the .js files are loaded in my index.html. However, I get multiple requests for three.js in the console and a couple other errors. The way I've learned Phaser is to use separate files for each scene and then add those to index.html and the scene manager in my main.js configuration.

What should the configuration look like to use enable3d? I have never used a plugin before with Phaser, so I'm sure it's just me doing something wrong. I tried going through the documentation myself, but it uses a lot of super and constructor which I have never done. I think that works when everything is within one file, but my projects are spread out and I can't find the way to convert it.

NSFW filter

No matter what I put into the prompt, I end up with a black image. I looked for a way to disable this, but when I open dream.py or text2img.py, neither of them contains "nsfw" or "safety" when I do a search. How do I turn this off so I can see my images? I suspect there's another issue going on, probably the green box thing, but I can't even see the results to know.

Clean Webpack Plugin v3 : breaking change

Hello ! The third version of Clean Webpack Plugin introduces a breaking change.
cf. johnagan/clean-webpack-plugin#106

The first error message :
TypeError: CleanWebpackPlugin is not a constructor

In webpack.prod.js, I change for :

const { CleanWebpackPlugin } = require('clean-webpack-plugin')

const prod = {
  [...]
  plugins: [
    new CleanWebpackPlugin(),
    [...]
  ]
}

Access the localhost dev site from a mobile device for testing

With my mobile connected to the same local network - should I be able to access the dev server on the machines IP address and port 8080 in order to test on a real mobile device in real-time?

Currently, I don't seem to be able to access my MacBook localhost dev server on port 8080.

Support for the experimental syntax 'classProperties' isn't currently enabled

Hi,
I just cloned your template, but I wasn't able to start the development server:

Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /Users/Merlin/git/phaser/src/scripts/scenes/mainScene.js: Support for the experimental syntax 'classProperties' isn't currently enabled (7:3):

   5 |   fpsText
   6 |
>  7 |   constructor() {
     |   ^
   8 |     super({ key: 'MainScene' })
   9 |   }
  10 |

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.