Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. const app = new PIXI.Application({
  2. width: 800, height: 600, backgroundColor: 0x1099bb, resolution: window.devicePixelRatio || 1,
  3. });
  4. document.body.appendChild(app.view);
  5.  
  6. const container = new PIXI.Container();
  7.  
  8. app.stage.addChild(container);
  9.  
  10. // Create a new texture
  11. const texture = PIXI.Texture.from('https://i.imgsafe.org/507ce7ed66.gif');
  12.  
  13. // Create a 5x5 grid of bunnies
  14. for (let i = 0; i < 25; i++) {
  15. const bunny = new PIXI.Sprite(texture);
  16. bunny.anchor.set(0.5);
  17. bunny.x = (i % 5) * 40;
  18. bunny.y = Math.floor(i / 5) * 40;
  19. container.addChild(bunny);
  20. }
  21.  
  22. // Move container to the center
  23. container.x = app.screen.width / 2;
  24. container.y = app.screen.height / 2;
  25.  
  26. // Center bunny sprite in local container coordinates
  27. container.pivot.x = container.width / 2;
  28. container.pivot.y = container.height / 2;
  29.  
  30. // Listen for animate update
  31. app.ticker.add((delta) => {
  32. // rotate the container!
  33. // use delta to create frame-independent transform
  34. container.rotation -= 0.01 * delta;
  35. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement