Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

πŸ“¦ For people who want to spend time making Phaser 3 games in TypeScript instead of configuring build tools. πŸ‘Ύ

License

Notifications You must be signed in to change notification settings

ourcade/phaser3-typescript-parcel-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚨 NOTE 🚨

October 2022

This template has been deprecated in favor of a more modern version using Vite. You can find it here: https://github.com/ourcade/phaser3-typescript-vite-template


phaser3-parceljs-template

Phaser 3 + TypeScript + Parcel Template

For people who want to spend time making Phaser 3 games in TypeScript instead of configuring build tools.

License

This is a TypeScript specific fork of phaser3-parcel-template.

Prerequisites

You'll need Node.js, npm, and Parcel installed.

It is highly recommended to use Node Version Manager (nvm) to install Node.js and npm.

For Windows users there is Node Version Manager for Windows.

Install Node.js and npm with nvm:

nvm install node

nvm use node

Replace 'node' with 'latest' for nvm-windows.

Then install Parcel:

npm install -g parcel-bundler

Getting Started

Clone this repository to your local machine:

git clone https://github.com/ourcade/phaser3-typescript-parcel-template.git

This will create a folder named phaser3-typescript-parcel-template. You can specify a different folder name like this:

git clone https://github.com/ourcade/phaser3-typescript-parcel-template.git my-folder-name

Go into your new project folder and install dependencies:

cd phaser3-typescript-parcel-template # or 'my-folder-name'
npm install

Start development server:

npm run start

To create a production build:

npm run build

Production files will be placed in the dist folder. Then upload those files to a web server. πŸŽ‰

Project Structure

    .
    β”œβ”€β”€ dist
    β”œβ”€β”€ node_modules
    β”œβ”€β”€ public
    β”œβ”€β”€ src
    β”‚   β”œβ”€β”€ scenes
    β”‚   β”‚   β”œβ”€β”€ HelloWorldScene.ts
    β”‚   β”œβ”€β”€ index.html
    β”‚   β”œβ”€β”€ main.ts
    β”œβ”€β”€ package.json

The contents of this template is the basic Phaser 3 getting started example.

This template assumes you will want to organize your code into multiple files and use TypeScript.

TypeScript files are intended for the src folder. main.ts is the entry point referenced by index.html.

Other than that there is no opinion on how you should structure your project. There is a scenes folder in src where the HelloWorldScene.ts lives but you can do whatever you want.

Static Assets

Any static assets like images or audio files should be placed in the public folder. It'll then be served at http://localhost:8000/images/my-image.png

Example public structure:

    public
    β”œβ”€β”€ images
    β”‚   β”œβ”€β”€ my-image.png
    β”œβ”€β”€ music
    β”‚   β”œβ”€β”€ ...
    β”œβ”€β”€ sfx
    β”‚   β”œβ”€β”€ ...

They can then be loaded by Phaser with this.image.load('my-image', 'images/my-image.png').

TypeScript ESLint

This template uses a basic typescript-eslint set up for code linting.

It does not aim to be opinionated.

Dev Server Port

You can change the dev server's port number by modifying the start script in package.json. We use Parcel's -p option to specify the port number.

The script looks like this:

parcel src/index.html -p 8000

Change 8000 to whatever you want.

Other Notes

parcel-plugin-clean-easy is used to ensure only the latest files are in the dist folder. You can modify this behavior by changing parcelCleanPaths in package.json.

parcel-plugin-static-files is used to copy static files from public into the output directory and serve it. You can add additional paths by modifying staticFiles in package.json.

License

MIT License

About

πŸ“¦ For people who want to spend time making Phaser 3 games in TypeScript instead of configuring build tools. πŸ‘Ύ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published