physics4.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <html>
  2. <head>
  3. <meta charset="UTF-8" />
  4. <title>spine-pixi</title>
  5. <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pixi.min.js"></script>
  6. <script src="../dist/iife/spine-pixi-v7.js"></script>
  7. <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/tweakpane.min.js"></script>
  8. <link rel="stylesheet" href="../../index.css">
  9. </head>
  10. <body>
  11. <script>
  12. (async function () {
  13. var app = new PIXI.Application({
  14. width: window.innerWidth,
  15. height: window.innerHeight,
  16. resolution: window.devicePixelRatio || 1,
  17. autoDensity: true,
  18. resizeTo: window,
  19. backgroundColor: 0x333333,
  20. hello: true,
  21. });
  22. document.body.appendChild(app.view);
  23. // Pre-load the skeleton data and atlas. You can also load .json skeleton data.
  24. PIXI.Assets.add("cloudPotData", "./assets/cloud-pot.skel");
  25. PIXI.Assets.add("cloudPotAtlas", "./assets/cloud-pot-pma.atlas");
  26. await PIXI.Assets.load(["cloudPotData", "cloudPotAtlas"]);
  27. // Create the spine display object
  28. const cloudPot = spine.Spine.from({skeleton: "cloudPotData", atlas: "cloudPotAtlas",
  29. scale: 0.25,
  30. });
  31. // Center the spine object on screen.
  32. cloudPot.x = window.innerWidth / 2;
  33. cloudPot.y = window.innerHeight / 2 + cloudPot.getBounds().height / 4;
  34. // Set animation "playing-in-the-rain" on track 0, looped.
  35. cloudPot.state.setAnimation(0, "playing-in-the-rain", true);
  36. // Add the display object to the stage.
  37. app.stage.addChild(cloudPot);
  38. })();
  39. </script>
  40. </body>
  41. </html>