├── assets └── logo.png ├── .gitmodules ├── index.html ├── .babelrc ├── .gitignore ├── README.md ├── src └── index.ts ├── webpack.config.js ├── webpack.prod.config.js ├── LICENSE ├── package.json └── tsconfig.json /assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/miasmos/phaser3-typescript-template/HEAD/assets/logo.png -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "phaser3-docs"] 2 | path = phaser3-docs 3 | url = https://github.com/photonstorm/phaser3-docs.git 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | "@babel/env", 4 | "@babel/typescript" 5 | ], 6 | "plugins": [ 7 | "@babel/proposal-class-properties", 8 | "@babel/proposal-object-rest-spread" 9 | ] 10 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib 2 | dist 3 | .prettierrc 4 | 5 | # System and IDE files 6 | Thumbs.db 7 | .DS_Store 8 | .idea 9 | *.suo 10 | *.sublime-project 11 | *.sublime-workspace 12 | 13 | # Vendors 14 | node_modules/ 15 | 16 | # Build 17 | build/ 18 | /npm-debug.log 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Phaser 3 Typescript Project Template 2 | 3 | A Phaser 3 project template with Typescript support. 4 | 5 | ### Requirements 6 | 7 | [Node.js](https://nodejs.org) 8 | 9 | ## Install and run 10 | 11 | | Command | Description | 12 | | -------------------- | ------------------------------------------------------ | 13 | | `npm install` | Install dependencies | 14 | | `npm start` | Build app and launch browser | 15 | | `npm run production` | Build app with minification enabled | 16 | | `npm run type-check` | Runs tsc | 17 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import 'phaser'; 2 | declare const Phaser: any; 3 | 4 | class Game { 5 | game: Phaser.Game; 6 | 7 | constructor() { 8 | const config = { 9 | type: Phaser.AUTO, 10 | width: 800, 11 | height: 600, 12 | scene: { 13 | preload: this.preload, 14 | create: this.create, 15 | update: this.update 16 | } 17 | }; 18 | 19 | this.game = new Phaser.Game(config); 20 | } 21 | 22 | preload() { 23 | this.load.image('logo', 'assets/logo.png'); 24 | } 25 | 26 | create() { 27 | const logo = this.add.image(400, 150, 'logo'); 28 | 29 | this.tweens.add({ 30 | targets: logo, 31 | y: 450, 32 | duration: 2000, 33 | ease: 'Power2', 34 | yoyo: true, 35 | loop: -1 36 | }); 37 | } 38 | 39 | update() {} 40 | } 41 | 42 | window.onload = () => { 43 | const game: Game = new Game(); 44 | }; 45 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | 4 | module.exports = { 5 | entry: './src/index', 6 | mode: 'development', 7 | output: { 8 | path: path.resolve(__dirname, 'dist'), 9 | filename: 'app.bundle.js', 10 | publicPath: '/dist' 11 | }, 12 | 13 | resolve: { 14 | extensions: ['.ts', '.tsx', '.js', '.json'] 15 | }, 16 | 17 | module: { 18 | rules: [ 19 | { 20 | test: /\.(tsx?)|(js)$/, 21 | exclude: /node_modules/, 22 | loader: 'babel-loader' 23 | }, 24 | { 25 | test: [/\.vert$/, /\.frag$/], 26 | use: 'raw-loader' 27 | } 28 | ] 29 | }, 30 | 31 | plugins: [ 32 | new webpack.DefinePlugin({ 33 | CANVAS_RENDERER: JSON.stringify(true), 34 | WEBGL_RENDERER: JSON.stringify(true) 35 | }), 36 | new webpack.NamedModulesPlugin() 37 | ] 38 | }; 39 | -------------------------------------------------------------------------------- /webpack.prod.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); 4 | 5 | module.exports = { 6 | entry: './src/index', 7 | mode: 'production', 8 | output: { 9 | path: path.resolve(__dirname, 'dist'), 10 | filename: 'app.bundle.js', 11 | publicPath: '/dist' 12 | }, 13 | 14 | resolve: { 15 | extensions: ['.ts', '.tsx', '.js', '.json'] 16 | }, 17 | 18 | module: { 19 | rules: [ 20 | { 21 | test: /\.(tsx?)|(js)$/, 22 | exclude: /node_modules/, 23 | loader: 'babel-loader' 24 | }, 25 | { 26 | test: [/\.vert$/, /\.frag$/], 27 | use: 'raw-loader' 28 | } 29 | ] 30 | }, 31 | 32 | plugins: [ 33 | new webpack.DefinePlugin({ 34 | CANVAS_RENDERER: JSON.stringify(true), 35 | WEBGL_RENDERER: JSON.stringify(true) 36 | }), 37 | new UglifyJsPlugin() 38 | ] 39 | }; 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Stephen Poole 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "phaser3-typescript-template", 3 | "version": "0.0.4", 4 | "description": "A Phaser 3 project template with Typescript support", 5 | "main": "src/index.ts", 6 | "scripts": { 7 | "type-check": "tsc", 8 | "bundle": "webpack", 9 | "build": "webpack", 10 | "start": "npm run build && webpack-dev-server --port=8000 --open --hot", 11 | "production": "webpack --config=webpack.prod.config.js" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/stephenpoole/phaser3-typescript-template.git" 16 | }, 17 | "author": "Stephen Poole