-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,72 @@ | ||
# pixi-scenes | ||
Managing multiple scenes within your pixi application. | ||
[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)[![forthebadge](https://forthebadge.com/images/badges/check-it-out.svg)](https://forthebadge.com) | ||
[![dependencies](https://david-dm.org/florisdh/pixi-scenes.svg)](https://david-dm.org/florisdh/pixi-scenes) | ||
|
||
Split your **pixi.js** application into multiple **scenes** and manage them with ease. | ||
|
||
## Getting started | ||
|
||
### Installation | ||
``` | ||
npm i pixi-scenes | ||
``` | ||
|
||
## Usage | ||
|
||
### Setup | ||
```ts | ||
import {SceneManager} from "pixi-scenes"; | ||
const sceneManager: SceneManager = new SceneManager(myPixiApplication); | ||
``` | ||
|
||
### Adding scenes | ||
```ts | ||
sceneManager.add('splashScreen', new SplashScreen()); | ||
``` | ||
|
||
### Switching scenes | ||
```ts | ||
sceneManager.start('splashScreen'); | ||
``` | ||
|
||
### Example scene | ||
```ts | ||
import {BaseScene} from 'pixi-scenes'; | ||
|
||
export default class SplashScreen extends BaseScene { | ||
|
||
private header: PIXI.Text; | ||
|
||
public init(): void { | ||
this.header = new PIXI.Text('My Game Studio'); | ||
this.header.x = this.app.screen.width / 2; | ||
this.header.y = this.app.screen.height / 2; | ||
this.header.anchor.set(0.5); | ||
this.addChild(this.header); | ||
} | ||
|
||
public start(): void { | ||
this.header.angle = 0; | ||
setTimeout(() => { | ||
this.scenes.start('mainMenu'); | ||
}, 5000); | ||
} | ||
|
||
public update(delta: number): void { | ||
this.header.angle += delta / 1000 * 45; | ||
} | ||
} | ||
``` | ||
|
||
|
||
## About | ||
Please let me know if you're using it or have some feedback. :) | ||
|
||
## TODO | ||
- Document code | ||
- Improve readme | ||
- Add documentation pages | ||
- Add example project | ||
- Add tests | ||
- Setup seperate esm export | ||
- Bundle definitions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters