Skip to content

Commit 31c9af0

Browse files
committed
feat: doc updates
1 parent 62993db commit 31c9af0

33 files changed

+29836
-13473
lines changed

.github/workflows/deploy-docs.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- beta
8+
- alpha
9+
- docs
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
deploy:
17+
name: Deploy
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version: '20'
25+
cache: 'npm'
26+
27+
- run: npm ci
28+
- run: |
29+
git config --global user.name "$GITHUB_ACTOR"
30+
git config --global user.email "[email protected]"
31+
git remote set-url origin https://git:${GIT_PASS}@github.com/pixijs/react.git
32+
npm run deploy
33+
env:
34+
GIT_USER: $GITHUB_ACTOR
35+
GIT_PASS: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/handle-release-branch-push.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ jobs:
1212
strategy:
1313
matrix:
1414
script:
15-
# - name: Typecheck
16-
# command: test:types
15+
- name: Typecheck
16+
command: test:types
17+
installPlaywright: false
1718
- name: Lint
1819
command: test:lint
1920
installPlaywright: false

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ node_modules/
66
dist/
77
lib/
88
types/
9+
10+
# Generated files
11+
.docusaurus
12+
.cache-loader
13+
docs/build

docs/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

docs/babel.config.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3+
};
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
label: Creation Templates
2+
position: 1
3+
collapsed: false

docs/docs/guide/creations/engine.mdx

+152
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
---
2+
sidebar_position: 1
3+
title: Engine
4+
---
5+
6+
## Initializing the Creation Engine
7+
8+
To initialize the engine, you need to create an instance of the CreationEngine class and call its init method. This method sets up the PixiJS application, initializes the screen manager, and loads the necessary assets.
9+
10+
```ts
11+
import { CreationEngine } from './engine/engine';
12+
13+
const engine = new CreationEngine();
14+
15+
(async () => {
16+
await engine.init({
17+
background: '#1E1E1E',
18+
resizeOptions: { minWidth: 768, minHeight: 1024, letterbox: false },
19+
});
20+
})();
21+
```
22+
23+
## Handling Resizing
24+
25+
The engine automatically handles resizing of the application. The resize behavior can be customized by passing options to the init method.
26+
27+
```ts
28+
await engine.init({
29+
resizeOptions: { minWidth: 768, minHeight: 1024, letterbox: false },
30+
});
31+
```
32+
33+
- **minWidth**: The minimum width of the application. If the window width is less than this value, the application will scale down to fit the window, but will report a logical width of this value.
34+
- **minHeight**: The minimum height of the application. If the window height is less than this value, the application will scale down to fit the window, but will report a logical height of this value.
35+
- **letterbox**: If true, the canvas will be letterboxed to maintain the aspect ratio of the application. If false, the canvas will be stretched to fill the window.
36+
37+
## Navigation & Screens
38+
39+
The engine provides a screen manager that allows you to manage different screens in your application. Each screen is a PixiJS Container that implements the Screen interface.
40+
41+
```ts
42+
import { Container } from 'pixi.js';
43+
import { Screen } from './engine/navigation';
44+
45+
export class MyScreen extends Container implements Screen {
46+
/** Show the screen */
47+
show?(): Promise<void>;
48+
/** Hide the screen */
49+
hide?(): Promise<void>;
50+
/** Pause the screen */
51+
pause?(): Promise<void>;
52+
/** Resume the screen */
53+
resume?(): Promise<void>;
54+
/** Prepare screen, before showing */
55+
prepare?(): void;
56+
/** Reset screen, after hidden */
57+
reset?(): void;
58+
/** Update the screen, passing delta time/step */
59+
update?(time: Ticker): void;
60+
/** Resize the screen */
61+
resize?(width: number, height: number): void;
62+
/** Blur the screen */
63+
blur?(): void;
64+
/** Focus the screen */
65+
focus?(): void;
66+
}
67+
```
68+
69+
To show different screens in your app, you can use the `showScreen` method of the Navigation class. This method hides the current screen and presents a new screen.
70+
71+
```ts
72+
import { MainScreen } from './app/screens/main/MainScreen';
73+
import { LoadScreen } from './app/screens/LoadScreen';
74+
75+
await engine.navigation.showScreen(LoadScreen);
76+
await engine.navigation.showScreen(MainScreen);
77+
```
78+
79+
### Popup Screens
80+
81+
You can also show popup screens on top of the current screen. Popup screens are displayed in a separate layer above the main screen.
82+
83+
```ts
84+
import { PauseScreen } from './app/screens/PauseScreen';
85+
86+
await engine.navigation.presentPopup(PauseScreen);
87+
```
88+
89+
equally you can hide the popup screen using the `dismissPopup` method.
90+
91+
```ts
92+
await engine.navigation.dismissPopup();
93+
```
94+
95+
### Asset Loading
96+
97+
Using AssetPack you can define bundles of assets for your application. These bundles can be loaded individually to avoid loading all assets at once.
98+
Typically you would define a bundle for each screen in your application, and load them as needed.
99+
100+
To help with this a screen can implements a `static assetBundles: string[]` property that defines the bundles required for that screen. The engine will automatically load these bundles when the screen is shown.
101+
102+
```ts
103+
export class MainScreen extends Container {
104+
/** Assets bundles required by this screen */
105+
public static assetBundles = ["main"];
106+
107+
}
108+
```
109+
110+
## Audio
111+
112+
The engine includes built-in support for managing background music (bgm) and sound effects (sfx). You can control audio playback using the `audio` property on the `CreationEngine`.
113+
114+
```ts
115+
// Play background music
116+
engine.audio.bgm.play('background-music.mp3', { volume: 0.5 });
117+
118+
// Play sound effect
119+
engine.audio.sfx.play('explosion.mp3', { volume: 0.8 });
120+
```
121+
122+
### Background Music (bgm)
123+
Handles music background, playing only one audio file in loop at time, and fade/stop the music if a new one is requested. Also provide volume control for music background only, leaving other sounds volumes unchanged.
124+
125+
### Sound Effects (sfx)
126+
Handles short sound special effects, mainly for having its own volume settings. The volume control is only a workaround to make it work only with this type of sound, with a limitation of not controlling volume of currently playing instances - only the new ones will have their volume changed. But because most of sound effects are short sounds, this is generally fine.
127+
128+
### Global Volume
129+
While you can control the volume of each audio type, you can also control the global volume of all audio the exposed global volume functions
130+
131+
```ts
132+
engine.audio.setMasterVolume(0.5);
133+
const volume = engine.audio.getMasterVolume();
134+
```
135+
136+
## Utility Functions
137+
138+
The engine provides several utility functions for common tasks, such as calculating distances, interpolating values, and generating random numbers.
139+
140+
This is not an exhaustive list, but here are some examples:
141+
142+
```ts
143+
import { getDistance, lerp, clamp } from './engine/utils/maths';
144+
import { randomInt, randomFloat } from './engine/utils/random';
145+
146+
const distance = getDistance(0, 0, 10, 10);
147+
const interpolatedValue = lerp(0, 10, 0.5);
148+
const clampedValue = clamp(15, 0, 10);
149+
150+
const randValue = randomInt(0, 10);
151+
const randFloat = randomFloat(0, 10);
152+
```

docs/docs/guide/creations/intro.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
sidebar_position: 0
3+
title: Getting Started
4+
---
5+
6+
We have put together a simple "creation template" that takes advantage of the PixiJS ecosystem to help you get started with building web-based applications.
7+
8+
This template provides a solid foundation for a variety of applications, including game development. It includes essential features such as screen management, audio, and resize handling. It is designed to streamline your development process and make it easier for you to create engaging web based content. While it is not a full-fledged "game engine", we hope that it will help you get started quickly and build amazing content.
9+
10+
## Overview
11+
12+
The creation template is built on top of PixiJS, as well as other libraries in the PixiJS ecosystem. Lets take a quick look at the technologies used in the template:
13+
14+
- **[PixiJS](https://github.com/pixijs/pixijs)**: A powerful 2D rendering engine that provides a fast and flexible rendering pipeline for creating games and interactive applications.
15+
- **[AssetPack](https://github.com/pixijs/assetpack)**: A library for managing assets in PixiJS applications. It simplifies the creation of assets such as images, sounds, and spritesheets.
16+
- **[PixiJS UI](https://github.com/pixijs/ui)**: A library that contains commonly used UI components, that are extensible to allow them to be used in any project
17+
- **[PixiJS Sound](https://github.com/pixijs/sound)**: A WebAudio API playback library, with filters. Modern audio playback for modern browsers.
18+
- **[Vite](https://vitejs.dev/)**: A fast and lightweight build tool that provides instant server start-up. It is used to build and run the project.
19+
20+
We highly recommend that you familiarize yourself with these libraries to get the most out of the creation template
21+
22+
### Additional Libraries
23+
24+
- **[Spine](https://github.com/EsotericSoftware/spine-runtimes)**: A 2D skeletal animation tool that allows you to create animations for games and other interactive applications. The game template includes support for Spine animations.
25+
- **[motion](https://motion.dev/)**: A simple and powerful tweening library. It allows you to create smooth animations and transitions with minimal code.
26+
27+
## Creation Engine
28+
29+
Included in the template is a simple "creation engine" that provides a set of features to help you build your application. The engine provides features that new users typically struggle with such as screen management, asset loading, audio playback.
30+
31+
You can find more information about the engine in the [Engine Guide](/docs/guide/creations/engine).
32+
33+
34+
## Template Types
35+
36+
We are slowly building up templates to help you build a game for different platforms. Currently, we have the following templates:
37+
38+
- **Web**: A general template for building web-based applications.
39+
40+
**Coming Soon**:
41+
- **[Discord](https://github.com/discord/embedded-app-sdk)**: A multiplayer template for building applications that can be run on the Discord platform.
42+
- **[Facebook](https://www.facebook.com/fbgaminghome/developers)**: A template for building applications that can be run on the Facebook instant games platform.
43+
- **[YouTube](https://developers.google.com/youtube/gaming/playables/reference/sdk)**: A template for building applications that can be run on the YouTube Playables platform.
44+
45+
46+
You can find the specific documentation for each template in the sidebar.
47+
48+
## More Examples?
49+
50+
If you are looking for more examples, you can check out the [Open Games](https://github.com/pixijs/open-games) repo. It contains a collection of open-source games built with PixiJS that you can use as a reference for your own projects.
51+
52+
These examples use the same tech stack as the game template, however, these where built before this tool was created, so there are some differences to be aware of.

0 commit comments

Comments
 (0)