Skip to content

Commit 5657154

Browse files
committed
Init
1 parent 7a9aea1 commit 5657154

22 files changed

+1318
-2
lines changed

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Phaser
3+
Copyright (c) 2024 Phaser Studio Inc
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,100 @@
1-
# template-vite-ts
1+
# Phaser Vite TypeScript Template
2+
3+
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.
4+
5+
### Versions
6+
7+
This template has been updated for:
8+
9+
- [Phaser 3.70.0](https://github.com/phaserjs/phaser)
10+
- [Vite 5.0.8](https://github.com/vitejs/vite)
11+
- [TypeScript 5.2.2](https://github.com/microsoft/TypeScript)
12+
13+
![screenshot](screenshot.png)
14+
15+
## Requirements
16+
17+
[Node.js](https://nodejs.org) is required to install dependencies and run scripts via `npm`.
18+
19+
## Available Commands
20+
21+
| Command | Description |
22+
|---------|-------------|
23+
| `npm install` | Install project dependencies |
24+
| `npm run dev` | Launch a development web server |
25+
| `npm run build` | Create a production build in the `dist` folder |
26+
27+
## Writing Code
28+
29+
After cloning the repo, run `npm install` from your project directory. Then, you can start the local development server by running `npm run dev`.
30+
31+
The local development server runs on `http://localhost:8080` by default. Please see the Vite documentation if you wish to change this, or add SSL support.
32+
33+
Once the server is running you can edit any of the files in the `src` folder. Vite will automatically recompile your code and then reload the browser.
34+
35+
## Template Project Structure
36+
37+
We have provided a default project structure to get you started. This is as follows:
38+
39+
- `index.html` - A basic HTML page to contain the game.
40+
- `src` - Contains the game source code.
41+
- `src/main.ts` - The main entry point. This contains the game configuration and starts the game.
42+
- `src/scenes/` - The Phaser Scenes are in this folder.
43+
- `public/style.css` - Some simple CSS rules to help with page layout.
44+
- `public/assets` - Contains the static assets used by the game.
45+
46+
## Handling Assets
47+
48+
Vite supports loading assets via JavaScript module `import` statements.
49+
50+
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 JavaScript file you are using it in:
51+
52+
```js
53+
import logoImg from './assets/logo.png'
54+
```
55+
56+
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:
57+
58+
```js
59+
preload ()
60+
{
61+
// This is an example of an imported bundled image.
62+
// Remember to import it at the top of this file
63+
this.load.image('logo', logoImg);
64+
65+
// This is an example of loading a static image
66+
// from the public/assets folder:
67+
this.load.image('background', 'assets/bg.png');
68+
}
69+
```
70+
71+
When you issue the `npm run build` command, all static assets are automatically copied to the `dist/assets` folder.
72+
73+
## Deploying to Production
74+
75+
After you run the `npm run build` command, 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.
76+
77+
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.
78+
79+
## Customizing the Template
80+
81+
### Vite
82+
83+
If you want to customize your build, such as adding plugin (i.e. for loading CSS or fonts), you can modify the `vite/config.js` file for cross-project changes, or you can modify and/or create new configuration files and target them in specific npm tasks inside of `package.json`. Please see the [Vite documentation](https://vitejs.dev/) for more information.
84+
85+
## Join the Phaser Community!
86+
87+
We love to see what developers like you create with Phaser! It really motivates us to keep improving. So please join our community and show-off your work 😄
88+
89+
**Visit:** The [Phaser website](https://phaser.io) and follow on [Phaser Twitter](https://twitter.com/phaser_)<br />
90+
**Play:** Some of the amazing games [#madewithphaser](https://twitter.com/search?q=%23madewithphaser&src=typed_query&f=live)<br />
91+
**Learn:** [API Docs](https://newdocs.phaser.io), [Support Forum](https://phaser.discourse.group/) and [StackOverflow](https://stackoverflow.com/questions/tagged/phaser-framework)<br />
92+
**Discord:** Join us on [Discord](https://discord.gg/phaser)<br />
93+
**Code:** 2000+ [Examples](https://labs.phaser.io)<br />
94+
**Read:** The [Phaser World](https://phaser.io/community/newsletter) Newsletter<br />
95+
96+
Created by [Phaser Studio](mailto:[email protected]). Powered by coffee, anime, pixels and love.
97+
98+
The Phaser logo and characters are &copy; 2011 - 2024 Phaser Studio Inc.
99+
100+
All rights reserved.

index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/png" href="/favicon.png" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="stylesheet" href="/style.css">
8+
<title>Phaser - Template</title>
9+
</head>
10+
11+
<body>
12+
<div id="app">
13+
<div id="game-container"></div>
14+
</div>
15+
<script type="module" src="/src/main.ts"></script>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)