Thank you to Ourcade for the phaser3-parcel-template and open license to use it :) This Readme is largely borrowed from the template Readme.
I am a spiritual computing phd student at the university of southern california, which occupies the stolen land of the Tongva people, Tovaangar.
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: (Note: template repo uses deprecated parcel-bundler module so I replaced it here with latest parcel module)
npm install -g parcel
Clone this repository to your local machine:
git clone https://github.com/palmerjh/regen.git
This will create a folder named regen
. You can specify a different folder name like this:
git clone https://github.com/palmerjh/regen.git my-folder-name
Go into your new project folder and install dependencies:
cd regen # 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. 🎉
.
├── dist
├── node_modules
├── public
├── src
│ ├── scenes
│ │ ├── HelloWorldScene.js
│ ├── index.html
│ ├── main.js
├── package.json
The contents of this template is the basic Phaser3 getting started example.
This template assumes you will want to organize your code into multiple files and use modern JavaScript (or TypeScript).
JavaScript files are intended for the src
folder. main.js
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.js
lives but you can do whatever you want.
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')
.
This template includes class property support out of the box using @babel/plugin-proposal-class-properties
.
A .babelrc
is included as well as the use of babel-eslint
as the parser for ESLint.
This template uses a basic eslint
set up for code linting to help you find and fix common problems in your JavaScript code.
It does not aim to be opinionated.
See here for rules to turn on or off.
Check out the phaser3-typescript-parcel-template for a ready-to-use version of this template in TypeScript!
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.
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
.