|
| 1 | +# Phaser 4 TypeScript - Keyboard Events Example |
| 2 | + |
| 3 | +Contains example code of how to use keyboard events in Phaser 4. This is the sample code that I shared in my tutorial video hosted on YouTube here: |
| 4 | + |
| 5 | +Coming soon... |
| 6 | + |
| 7 | +You can see a live demo of the example here: <a href="https://devshareacademy.github.io/phaser-4-typescript-games-and-examples/examples/rc5/keyboard-events/index.html" target="_blank">Keyboard Events</a> |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Local Development |
| 12 | + |
| 13 | +### Requirements |
| 14 | + |
| 15 | +<a href="https://nodejs.org" target="_blank">Node.js</a> and <a href="https://pnpm.io/" target="_blank">PnPm</a> are required to install dependencies and run scripts via `pnpm`. |
| 16 | + |
| 17 | +<a href="https://vitejs.dev/" target="_blank">Vite</a> is required to bundle and serve the web application. This is included as part of the projects dev dependencies. |
| 18 | + |
| 19 | +### Available Commands |
| 20 | + |
| 21 | +| Command | Description | |
| 22 | +|---------|-------------| |
| 23 | +| `pnpm install --frozen-lockfile` | Install project dependencies | |
| 24 | +| `pnpm start` | Build project and open web server running project | |
| 25 | +| `pnpm build` | Builds code bundle for production | |
| 26 | +| `pnpm lint` | Uses ESLint to lint code | |
| 27 | + |
| 28 | +### Writing Code |
| 29 | + |
| 30 | +After cloning the repo, run `pnpm install --frozen-lockfile` from your project directory. Then, you can start the local development |
| 31 | +server by running `pnpm start`. |
| 32 | + |
| 33 | +After starting the development server with `pnpm start`, you can edit any files in the `src` folder |
| 34 | +and parcel will automatically recompile and reload your server (available at `http://localhost:8080` |
| 35 | +by default). |
| 36 | + |
| 37 | +### Deploying Code |
| 38 | + |
| 39 | +After you run the `pnpm build` command, your code will be built into a single bundle located at |
| 40 | +`dist/*` along with any other assets you project depended. |
| 41 | + |
| 42 | +If you put the contents of the `dist` folder in a publicly-accessible location (say something like `http://myserver.com`), |
| 43 | +you should be able to open `http://myserver.com/index.html` and play your game. |
| 44 | + |
| 45 | +### Static Assets |
| 46 | + |
| 47 | +Any static assets like images or audio files should be placed in the `public` folder. It'll then be served at `http://localhost:8080/path-to-file-your-file/file-name.file-type`. |
| 48 | + |
| 49 | +## Credit |
| 50 | + |
| 51 | +The assets used in this demo were created by <a href="https://beamedeighth.itch.io/simplekeys-animated-pixel-keyboard-keys" target="_blank">beamedeighth</a>. |
0 commit comments