SkillAgentSearch skills...

Firmware

Free FOC firmware for Lishui E-Bike-Controllers

Install / Use

/learn @653673449/Firmware
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Phaser-CE NPM Webpack TypeScript Starter Project (catchy name, isn't it?)

GitHub package version GitHub last commit

GitHub watchers GitHub stars GitHub forks

GitHub issues GitHub pull requests

David

PhaserNPMWebpackTypeScriptStarterProject

Hit the ground running and make some great games!
If you use this template/starter project in any capacity; I'd love to hear about your experience with it. Whether you continued with it or decided not to (I really want to hear why you made your decision).

Features:

  • Phaser-CE 2.11.1 (npm module, no having to download the library separately...)
  • TypeScript + TSLint
  • 3 States (Boot, Preloader, Title) showing transition between states and where some things should be done and how a TypeScript state looks
  • Google Web Font loader
  • Webpack
  • Separate Development and Distribution builds
  • Live server (builds and reloads the browser on changes)
  • No hassle asset management requiring no code, on your part, to load and parse assets
    • Assets are required and hashed via webpack, you can now guarantee that when you push an update, everyone will get the new files and not cached ones
    • Assets class created automatically allowing you to access all the assets and their frames and sprites (in the case of Atlases and Audiosprites) in a compiler validating way!
  • Setting up the game size and scaling through a script that does it all for you
    • Automatic template background
    • Sets up the size the game so that it is scaled only when absolutely necessary
    • Refer to src/utils/utils.ts for an explanation on the background_template and the sizing/scaling style
    • Landscape and Portrait support

TODO (in no particular order):

  • Clean up generateAssetsClass.js
  • Get Custom/Local Web Fonts hashed by Webpack (to avoid cache issues)
    • If anyone has experience webpacking font-face in css style web fonts and loading said fonts via webfontloader, let me know as I was having some trouble getting the font-face src to use the hashed assets.
  • Multiple resolution asset loader (@2x, @3x, etc...)
  • Yeoman Generator
  • Optional Analytics integration
  • Optional Cordova integration for iOS and Android builds

Folder Structure:

  • assets/ – This is where your assets that are processed when building goes
  • assets_raw/ – This folder is NOT processed at all and is merely an organizational folder (I use it for things like my individual images that get compiled into a spritesheet, individual sounds that get compiled into an audiosprite, etc...)
  • dist/ – This is where the built game will go
  • node_modules/ – This is where the node modules required for the game will be put with npm install
  • scripts/ – This is where node scripts go
  • src/ – This is where all the games code goes
  • templates/ – This is where the html template that gets built by Webpack goes
  • .gitignore – List of files and folders that are ignored by git
  • .npmrc – List of some project wide npm settings
  • electron-main.js – Entry point and application life controller for electron builds
  • package.json – Node config for the project
  • README.md – This is the README displayed ont he GitHub page
  • README_HEADER.png – This is just the header image for the GitHub README
  • tsconfig.json – List of some TypeScript settings
  • tslint.json – List of some TypeScript Linting rules
  • webpack.dev.config.js – Webpack config for the DEV build
  • webpack.dist.config.js – Webpack config for the DIST build

Setup:

To use this you’ll need to install a few things before you have a working copy of the project. But once you have node.js installed it only takes a few seconds and a couple commands to get going.

0. Install Git:

[GIT Installation Instructions and Links][git-scm]

1. Download or Clone this repo:

Download:

Download the latest zip/tar.gz from [GitHub Releases][releases], extract it to where you want your project to be.

If you want a clean project ready for you to just start your own game and not have to worry about cleaning up the examples and samples from the v1.11.0 release, just download the v1.11.0-fresh release instead.

Clone (must've completed Step 0 first):

Navigate into your workspace directory.

Run:

git clone https://github.com/rroylance/phaser-ce-npm-webpack-typescript-starter-project.git

If you want a clean project ready for you to just start your own game and not have to worry about cleaning up the examples and samples from the master branch, just pull the 'fresh-start' branch instead of master.

2. Install node.js and npm (npm is included and installed with node.js):

[NodeJS Installation Instructions and Links][nodejs]

3. Install dependencies:

Navigate to the cloned repo’s directory.

Run:

npm install

4. Run the dev server:

Run to use the dev build while developing:

npm run server:dev

Run to use the dist build while developing

npm run server:dist

The only real reason I can think of to use the dist server is if the minification process is breaking something in your game and you need to test using the minified version, or something you excluded with the DEBUG flag shouldn't have been excluded.

This will run a server that serves your built game straight to the browser and will be built and reloaded automatically anytime a change is detected.

Build for testing/developing/debugging:

Run:

npm run build:dev

This will build the game with a few caveats;

  • A compile time flag, DEBUG, set to true; allowing you to include or not include certain code depending on if it's DEBUG build or not.
  • The resulting game.js will not be minified

Build for release:

Run:

npm run build:dist

This will build the game with a few caveats;

  • The compile time flag, DEBUG, set to false; allowing you to include or not include certain code depending on if it's DEBUG build or not.
  • The resulting game.min.js will be minified

Generate Assets Class:

This project will manage your assets for you! All you need to do is drop your assets in assets/ (subdirectories do not matter) and run (you need to run this manually if you change assets while the server is running, otherwise it's run automatically when running a build);

npm run assets

or (if your dev GOOGLE_WEB_FONTS is different from your dist);

npm run assets:dev

src/assets.ts will be generated which contains sections for all your asset types (the generator is smart enough to distinguish what assets are what !) and classes for every asset, it will also generate an enum containing every frame and sprite in Atlases and AudioSprites respectively!

No need to remember keys, frames, or sprites anymore; which means no more typos resulting in asset not found errors. Just use, for example, Assets.Images.ImagesBackgroundTemplate.getName() or Assets.Audiosprites.AudiospritesSfx.Sprites.Laser1. This also allows the compiler to warn you if you are trying to use an asset that doesn't exist!

The preloader will use this class to load everything, you don't have to do anything in code to get your assets loading and available (except for any assets you need for your loading screen...)!

Currently supports the following (if you need a new extension or find an issue with one of your assets not exporting correctly, just let me know);

  • Images:
    • bmp, gif, jpg, jpeg, png, webp
  • Spritesheets:
    • bmp, gif, jpg, jpeg, png, webp
    • [frameWidth, frameHeight, frameMax, margin, spacing] - frameWidth & frameHeight are required.
    • Example: spritesheet.[100, 100].png
  • Atlases:
    • bmp, gif, jpg, jpeg, png, webp
    • json (the loader figures out if it's a JSONArray or JSONHash, no need to remember or care), xml
  • Audio:
    • aac, ac3, caf, flac, m4a, mp3, mp4, ogg, wav, webm
  • Audiosprites:
    • aac, ac3, caf, flac, m4a, mp3, mp4, ogg, wav, webm
    • json
  • Local Fonts:
    • eot, otf, svg, ttf, woff, woff2
    • css
  • Bitmap Font:
    • bmp, gif, jpg, jpeg, png, webp
    • xml, fnt
  • JSON:
    • json
  • Tilemap JSON:
    • json
  • XML:
    • xml
  • Text:
    • txt
  • Scripts:
    • js
  • Shaders:
    • frag

Which version of the audio to load

View on GitHub
GitHub Stars769
CategoryDevelopment
Updated10h ago
Forks569

Languages

JavaScript

Security Score

95/100

Audited on Apr 3, 2026

No findings