11# @pixi/layers - PixiJS Layers Kit
22
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 )
44
55This package provides an extension to scene tree - layers. These layers allows you to change
66the rendering order of items in your scene without moving them around in your scene. It's like
77{@link PIXI.DisplayObject#zIndex zIndex}, but supercharged.
88
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).
1010
1111** Nothing will work if you dont create Stage and set it as root. Please do it or read full explanation.**
1212
@@ -16,28 +16,21 @@ It has been ported to PixiJS 6 since @pixi/layers 1.0.0 (formerly pixi-layers).
1616npm install --save @pixi/layers
1717```
1818
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-
2519## Examples
2620
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 )
3225
3326## Usage
3427
3528{@link Layer} extends {@link PIXI.Container}:
3629
3730``` js
38- import { Layer } from ' @pixi/layers'
31+ import { Layer } from ' @pixi/layers' ;
3932
40- let layer = new Layer ();
33+ const layer = new Layer ();
4134```
4235
4336A 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
8982
9083Instead, you can create a new display Group:
9184
92- ```
93- let lightGroup = new Group();
85+ ``` js
86+ const lightGroup = new Group ();
9487
9588bunnySprite .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
9790```
9891
9992Groups are working between different stages, so when you move bunny it will be rendered in its light layer.
10093
10194Layer is representation of global Group in this particular stage.
10295
103- ## Vanilla JS, UMD build
96+ ## Vanilla JS,
10497
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.
107100
108101``` 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 >
111104```
112105
113106``` js
114- let layer = new PIXI.display .Layer ();
107+ const layer = new PIXI.layers .Layer ();
115108```
116109
117110## Usage with canvas and particles
@@ -123,19 +116,19 @@ The important thing is to call it when you know that corresponding module is loa
123116If you use ` @pixi/canvas-renderer `
124117
125118``` js
126- import * as PIXI from ' pixi.js-legacy' ;
119+ import { CanvasRenderer } from ' pixi.js-legacy' ;
127120import { applyCanvasMixin } from ' @pixi/layers' ;
128121
129- applyCanvasMixin (PIXI . CanvasRenderer );
122+ applyCanvasMixin (CanvasRenderer);
130123```
131124
132125If you use ` @pixi/particles `
133126
134127``` js
135- import * as PIXI from ' pixi.js' ;
128+ import { ParticleContainer } from ' pixi.js' ;
136129import { applyCanvasMixin } from ' @pixi/layers' ;
137130
138- applyParticleMixin (PIXI . ParticleContainer );
131+ applyParticleMixin (ParticleContainer);
139132```
140133
141134## Advanced sorting
0 commit comments