Advertisement
Guest User

Untitled

a guest
Jun 18th, 2020
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This is demo of pixi-layers.js, https://github.com/pixijs/pixi-layers
  2. // Drag the rabbits to understand what's going on
  3.  
  4. const app = new PIXI.Application({ backgroundColor: 0x1099bb });
  5. document.body.appendChild(app.view);
  6.  
  7. const textureGreen = PIXI.Texture.from('examples/assets/bunny_green.png');
  8. const textureBlue = PIXI.Texture.from('examples/assets/bunny_blue.png');
  9.  
  10. let blue = new PIXI.Container();
  11. let green = new PIXI.Container();
  12.  
  13. app.stage = new PIXI.display.Stage();
  14.  
  15. const defaultGroup = new PIXI.display.Group(5, false);
  16. const defaultLayer = new PIXI.display.Layer(defaultGroup);
  17. app.stage.addChild(blue, green, defaultLayer);
  18.  
  19. for (let i = 0; i < 15; i++) {
  20.     const bunny = new PIXI.Sprite(textureGreen);
  21.     bunny.width = 50;
  22.     bunny.height = 50;
  23.     bunny.position.set(100 + 20 * i, 100 + 20 * i);
  24.     bunny.anchor.set(0.5);
  25.  
  26.     green.addChild(bunny);
  27. }
  28.  
  29. for (let i = 9; i >= 0; i--) {
  30.     const bunny = new PIXI.Sprite(textureBlue);
  31.     bunny.width = 50;
  32.     bunny.height = 50;
  33.     bunny.position.set(100 + 20 * i, 150 + 20 * i);
  34.     bunny.anchor.set(0.5)
  35.  
  36.     if (i == 9) {
  37.       bunny.tint = 0xFF0000;
  38.       bunny.parentGroup = defaultGroup;
  39.     }
  40.  
  41.     blue.addChild(bunny);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement