• Stars
    star
    408
  • Rank 105,946 (Top 3 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ•ΉοΈ Phaser 3 - Starter Template with TypeScript and webpack.


header
Phaser 3 TypeScript Starter Template

A starter template for Phaser 3 with TypeScript 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 Features β€’ Preview β€’ How To Use β€’ enable3d β€’ PWA β€’ Native App β€’ Custom Configurations β€’ ES6 β€’ Useful Links β€’ Multiplayer Game β€’ Examples β€’ Credits β€’ License

Want to use ES6 instead of TypeScript? Check out the phaser-project-template-es6

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 TypeScript. 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 (yes, npx not npm)
$ npx gitget yandeu/phaser-project-template phaser-template

# Go into the repository
$ cd phaser-template

# 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 and is configured to only work in production mode.
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 https://html2app.dev/.

Or built it manually 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

TypeScript Compiler

Change the TypeScript compiler's settings in the tsconfig.json file.

If you are new to TypeScript, you maybe want to set "noImplicitAny" to false.

You'll find more information about the TypeScript compiler here.

Typings

You can put your custom type definitions inside typings/custom.d.ts.

Webpack

All webpack configs are in the webpack folder.

Obfuscation

Obfuscation is disabled by default.

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

ES6

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

Multiplayer Game

Making a multiplayer game? Check out geckos.io

Useful Links

Examples

Game Examples Built with this 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) 2021 - Yannick Deubel. Please have a look at the LICENSE for more details.

More Repositories

1

phaser3-multiplayer-with-physics

Phaser 3 - Real-Time Multiplayer example with Physics (MatterJS and Arcade)
TypeScript
177
star
2

five-server

⚑ Development Server with Live Reload Capability. (Maintained Fork of Live Server)
TypeScript
155
star
3

phaser-project-template-es6

Phaser 3 - Starter Template with ES6 (ESNext features included) and webpack.
JavaScript
149
star
4

five-server-vscode

⚑ VSCode Extension for Five Server.
TypeScript
121
star
5

phaser3-typescript-platformer-example

Phaser 3 TypeScript Platformer Example
JavaScript
81
star
6

phaser3-matter-car-on-curved-terrain

Phaser 3 + Matter.js: Car on curved terrain crosses a bridge
TypeScript
48
star
7

arcade-physics

Use Arcade Physics without Phaser.
JavaScript
47
star
8

phaser3-react-typescript-example

Phaser 3: with React and TypeScript Example
TypeScript
39
star
9

docker-swarm-visualizer

πŸ‹ A Visualizer for Docker Swarm using the Docker Engine API and Node.js.
TypeScript
35
star
10

phaser3-spine-example

JavaScript
35
star
11

docker-swarm-visualizer-rs

πŸ‹ A Visualizer for Docker Swarm written in Rust.
TypeScript
19
star
12

phaser3-optimal-resolution

JavaScript
18
star
13

phaser3-scaling-resizing-example

Phaser 3 - Scaling/Resizing Example
TypeScript
17
star
14

html2app-template

HTML
17
star
15

express6

πŸ… Modern, fast, unopinionated, minimalist web framework.
TypeScript
16
star
16

five-server-with-php

PHP
14
star
17

node-cli

πŸ–οΈ Build a beautiful Node.js CLI with colors, pre-build elements and optional JSX support.
TypeScript
13
star
18

gitget

πŸ“¦ Clone GitHub repos fast and easy.
TypeScript
11
star
19

ammo-worker-test

JavaScript
10
star
20

three-project-template

Three.js starter template with TypeScript and webpack.
TypeScript
10
star
21

phaser-basic-template

Phaser 3: Basic Starter Template with Intellisense
JavaScript
10
star
22

keyboard

⌨️ Handling of keyboard events.
TypeScript
9
star
23

phaser3-swipeable-level-selection

A very nice swipeable level selection menu for Phaser 3 games.
TypeScript
9
star
24

postgres-browser-proxy

🐘 Query your Postgres Database directly from the Browser.
Rust
8
star
25

react-to-static-or-ssr

A react starter template for creating single page applications, static html files or a server side rendered app.
TypeScript
5
star
26

kronos2-prototype

TypeScript
4
star
27

ionic-react-typescript-starter

Ionic 5 & React - Starter Template written in TypeScript
TypeScript
4
star
28

tauri-webxr-test

Rust
4
star
29

tap

πŸ–±οΈ Handling of user interactions such as mouse, touch and pointer events.
TypeScript
4
star
30

yandeu

3
star
31

events

⚑ Simplified and TypeScripted version of [email protected]
JavaScript
3
star
32

audio

🎡 Audio library for the Web Audio API. (TypeScripted version of Three.js@r126's Audio without Object3D)
TypeScript
3
star
33

handlebars-to-static-or-ssr

Run Handlebars on the Server Side (with node.js and express) or generate Static HTML files.
JavaScript
2
star
34

parse-markdown

TypeScript
2
star
35

docker-php

πŸ‹ A simple PHP environment with Docker for local development.
JavaScript
2
star
36

phaser-phonegap-template

HTML
2
star
37

tiny-http2-server

TypeScript
2
star
38

markdown-mail

πŸ“¬ Turn your Markdown files into Responsive HTML E-Mails.
TypeScript
1
star
39

struct-serval

Rust
1
star
40

www

HTML
1
star
41

wordpress-docker-compose

A simple docker-compose file to spin up WordPress, MariaDB and phpmyadmin.
1
star
42

arcade-physics_dev

JavaScript
1
star
43

video-to-m3u8

HTML
1
star
44

ftp-upload

Rust
1
star
45

nano-jsx-simple-template

JavaScript
1
star
46

npm-template

A simple template for making npm packages.
JavaScript
1
star
47

rust-rocket-mongodb

Rust
1
star
48

nordpress_preview

Dev Repository for nordpress.org
1
star
49

old-phaser-template

JavaScript
1
star
50

tarif590-json

Tarif590 to JSON - Turns "Tarif_590.xlsx" into "tarif590.json".
JavaScript
1
star
51

md-to-book

JavaScript
1
star