1
1
# @pixi/layers - PixiJS Layers Kit
2
2
3
- [ ![ Build] ( https://github.com/pixijs/layers/workflows/Build /badge.svg )] ( https://github.com/pixijs/layers/actions?query=workflow%3A%22Build%22 ) [ ![ npm version] ( https://badge.fury.io/js/%40pixi%2Flayers.svg )] ( https://badge.fury.io/js/%40pixi%2Flayers )
3
+ [ ![ Build CI ] ( https://github.com/pixijs/layers/actions/ workflows/build.yml /badge.svg )] ( https://github.com/pixijs/layers/actions/workflows/build.yml ) [ ![ npm version] ( https://badge.fury.io/js/%40pixi%2Flayers.svg )] ( https://badge.fury.io/js/%40pixi%2Flayers )
4
4
5
5
This package provides an extension to scene tree - layers. These layers allows you to change
6
6
the rendering order of items in your scene without moving them around in your scene. It's like
7
7
{@link PIXI.DisplayObject#zIndex zIndex}, but supercharged.
8
8
9
- It has been ported to PixiJS 6 since @pixi/layers 1 .0.0 (formerly pixi-layers).
9
+ It has been ported to PixiJS 7 since @pixi/layers 2 .0.0 (formerly pixi-layers).
10
10
11
11
** Nothing will work if you dont create Stage and set it as root. Please do it or read full explanation.**
12
12
@@ -16,28 +16,21 @@ It has been ported to PixiJS 6 since @pixi/layers 1.0.0 (formerly pixi-layers).
16
16
npm install --save @pixi/layers
17
17
```
18
18
19
- ### Migration from v5
20
-
21
- See [ usage with canvas and particles] ( #usage-with-canvas-and-particles ) part of this doc.
22
-
23
- If you still work with PixiJS ` v5 ` and prior - see README ` pixi-v5 ` branch, or just use npm package ` pixi-layers `
24
-
25
19
## Examples
26
20
27
- * [ Lighting example] ( https://pixijs.io/examples/#/plugin-layers/lighting.js )
28
- * [ Z-order example] ( https://pixijs.io/examples/#/plugin-layers/zorder.js )
29
- * [ Double buffering] ( http://pixijs.github.io/examples/#/layers/trail.js )
30
- * [ Normals example - WORK IN PROGRESS] ( http://pixijs.github.io/examples/#/layers/normals.js )
31
- * [ Normals with sorting - WORK IN PROGRESS] ( http://pixijs.github.io/examples/#/layers/normals.js )
21
+ * [ Blend Modes example] ( https://pixijs.io/layers/examples/blend-modes.html )
22
+ * [ Z-order example] ( https://pixijs.io/layers/examples/z-order.html )
23
+ * [ Double buffering] ( https://pixijs.io/layers/examples/trail.html )
24
+ * [ Bring To Top] ( https://pixijs.io/layers/examples/bring-to-top.html )
32
25
33
26
## Usage
34
27
35
28
{@link Layer} extends {@link PIXI.Container}:
36
29
37
30
``` js
38
- import { Layer } from ' @pixi/layers'
31
+ import { Layer } from ' @pixi/layers' ;
39
32
40
- let layer = new Layer ();
33
+ const layer = new Layer ();
41
34
```
42
35
43
36
A DisplayObject/Container can be rendered inside its layer instead of direct parent
@@ -89,29 +82,29 @@ When you move a character with attached sprites from different layers to a new s
89
82
90
83
Instead, you can create a new display Group:
91
84
92
- ```
93
- let lightGroup = new Group();
85
+ ``` js
86
+ const lightGroup = new Group ();
94
87
95
88
bunnySprite .parentGroup = lightGroup;
96
- let lightLayer = new Layer(lightGroup); // only one layer per stage can be bound to same group
89
+ const lightLayer = new Layer (lightGroup); // only one layer per stage can be bound to same group
97
90
```
98
91
99
92
Groups are working between different stages, so when you move bunny it will be rendered in its light layer.
100
93
101
94
Layer is representation of global Group in this particular stage.
102
95
103
- ## Vanilla JS, UMD build
96
+ ## Vanilla JS,
104
97
105
- All pixiJS v6 plugins has special ` umd ` build suited for vanilla.
106
- Navigate ` pixi-layers ` npm package, take ` dist/pixi-layers.umd. js ` file.
98
+ All PixiJS has a special bundle suited for vanilla JavaScript in the browser .
99
+ Navigate ` pixi-layers ` npm package, take ` dist/pixi-layers.js ` file.
107
100
108
101
``` html
109
- <script src =' lib /pixi.js ' ></script >
110
- <script src =' lib /pixi-layers.umd.js ' ></script >
102
+ <script src =" . /pixi.min.js " ></script >
103
+ <script src =" . /pixi-layers.js " ></script >
111
104
```
112
105
113
106
``` js
114
- let layer = new PIXI.display .Layer ();
107
+ const layer = new PIXI.layers .Layer ();
115
108
```
116
109
117
110
## Usage with canvas and particles
@@ -123,19 +116,19 @@ The important thing is to call it when you know that corresponding module is loa
123
116
If you use ` @pixi/canvas-renderer `
124
117
125
118
``` js
126
- import * as PIXI from ' pixi.js-legacy' ;
119
+ import { CanvasRenderer } from ' pixi.js-legacy' ;
127
120
import { applyCanvasMixin } from ' @pixi/layers' ;
128
121
129
- applyCanvasMixin (PIXI . CanvasRenderer );
122
+ applyCanvasMixin (CanvasRenderer);
130
123
```
131
124
132
125
If you use ` @pixi/particles `
133
126
134
127
``` js
135
- import * as PIXI from ' pixi.js' ;
128
+ import { ParticleContainer } from ' pixi.js' ;
136
129
import { applyCanvasMixin } from ' @pixi/layers' ;
137
130
138
- applyParticleMixin (PIXI . ParticleContainer );
131
+ applyParticleMixin (ParticleContainer);
139
132
```
140
133
141
134
## Advanced sorting
0 commit comments