Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gamestdio/pixi-engine
Provides a minimal engine-like structure for developing games with PixiJS
https://github.com/gamestdio/pixi-engine
Last synced: about 1 month ago
JSON representation
Provides a minimal engine-like structure for developing games with PixiJS
- Host: GitHub
- URL: https://github.com/gamestdio/pixi-engine
- Owner: gamestdio
- License: mit
- Created: 2017-12-21T17:40:08.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-22T18:38:24.000Z (over 6 years ago)
- Last Synced: 2024-09-29T10:41:05.857Z (about 2 months ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 73
- Watchers: 7
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pixi-engine
Provides a minimal engine-like structure for developing games with
[PixiJS](https://github.com/pixijs/pixi.js/).## Classes
- [Application](#application)
- [Mediator](#mediator)
- [SceneManager](#scenemanager)
- [PlayerPrefs](#playerprefs)Also, consider using other packages such as [@gamestdio/mathf](https://github.com/gamestdio/mathf) and [@gamestdio/keycode](https://github.com/gamestdio/keycode).
## `Application`
A singleton that extends from `PIXI.Application`. You might not need to use it directly. When switching scenes using [SceneManager](#scenemanager), the `Application` is used under the hood.
## `Mediator`
Mediators are meant for handling business logic in your game.
```typescript
import { Mediator } from "pixi-engine";class MenuMediator extends Mediator {
initialize () {
console.log(this.view, "has been added.");
}destroy () {
console.log(this.view, "has been removed.");
}onButtonClick () {
console.log("Let's handle the click action here!");
}}
``````typescript
import { mediate, action } from "pixi-engine";@mediate(MenuMediator)
class MenuView extends PIXI.Container {
button: PIXI.Sprite = PIXI.Sprite.fromFrame("my-button.png");@action("onButtonClick")
handleClick () {
// handles the animation of this.button
}// pixi-engine will call `update` method at every frame
update () {
}// pixi-engine will call `resize` automatically when the window is resized
resize () {
}
}
```## `SceneManager`
Inspired by Unity, `SceneManager` handles switching the current active scene. Scenes are instances of `PIXI.Container`.
```typescript
import { SceneManager } from "pixi-engine";class MyScene extends PIXI.Container {
// definition of your scene
}// Go-to target scene.
SceneManager.goTo(MyScene);
```## `PlayerPrefs`
Inspired by Unity, `PlayerPrefs` are meant for storing and retrieving data locally. Currently, it's just a wrapper for `localStorage`. In the future more adapters might be implemented to handle another storage option.
```typescript
import { PlayerPrefs } from "pixi-engine";// Key-value usage
PlayerPrefs.set("name", "Player Name");
PlayerPrefs.set("accessToken", "1f92h3f928h39f8h2");// Object usage
PlayerPrefs.set({
name: "Player Name",
accessToken: "1f92h3f928h39f8h2"
});// Retrieving data
console.log(PlayerPrefs.get("name"));
```## License
MIT