8000 GitHub - z-starter/vite-phaser-ts: A Phaser 3 project template that uses TypeScript and Vite for bundling
[go: up one dir, main page]

Skip to content

A Phaser 3 project template that uses TypeScript and Vite for bundling

License

Notifications You must be signed in to change notification settings

z-starter/vite-phaser-ts

 
 

Folders and files

< A206 tr class="react-directory-row truncate-for-mobile" id="folder-row-11">
NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Phaser Vite TypeScript Template

This is a Phaser 3 project template that uses Vite for bundling. It supports hot-reloading for quick development workflow, includes TypeScript support and scripts to generate production-ready builds.

Requirements

Node.js is required to install dependencies and run scripts.

Template Project Structure

We have provided a default project structure to get you started. This is as follows:

  • index.html - A basic HTML page to contain the game.
  • src - Contains the game source code.
  • src/main.ts - The main entry point. This contains the game configuration and starts the game.
  • src/vite-env.d.ts - Global TypeScript declarations, provide types information.
  • src/scenes/ - The Phaser Scenes are in this folder.
  • public/assets - Contains the static assets used by the game.

Handling Assets

Vite supports loading assets via TypeScript module import statements.

This template provides support for both embedding assets and also loading them from a static folder. To embed an asset, you can import it at the top of the TypeScript file you are using it in:

import logoImg from './assets/logo.png'

To load static files such as audio files, videos, etc place them into the public/assets folder. Then you can use this path in the Loader calls within Phaser:

preload ()
{
    //  This is an example of an imported bundled image.
    //  Remember to import it at the top of this file
    this.load.image('logo', logoImg);

    //  This is an example of loading a static image
    //  from the public/assets folder:
    this.load.image('background', 'assets/bg.png');
}

When you build the project, all static assets are automatically copied to the dist/assets folder.

Deploying to Production

After you build the project, your code will be built into a single bundle and saved to the dist folder, along with any other assets your project imported, or stored in the public assets folder.

In order to deploy your game, you will need to upload all of the contents of the dist folder to a public facing web server.

About

A Phaser 3 project template that uses TypeScript and Vite for bundling

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 79.7%
  • SCSS 14.5%
  • HTML 5.8%
0