index.html 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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: 0x2c3e50,
  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("spineboyData", "./assets/spineboy-pro.skel");
  25. PIXI.Assets.add("spineboyAtlas", "./assets/spineboy-pma.atlas");
  26. await PIXI.Assets.load(["spineboyData", "spineboyAtlas"]);
  27. // Create the spine display object
  28. const spineboy = spine.Spine.from({skeleton: "spineboyData", atlas: "spineboyAtlas",
  29. scale: 0.5,
  30. });
  31. // Set the default mix time to use when transitioning
  32. // from one animation to the next.
  33. spineboy.state.data.defaultMix = 0.2;
  34. // Center the spine object on screen.
  35. spineboy.x = window.innerWidth / 2;
  36. spineboy.y = window.innerHeight / 2 + spineboy.getBounds().height / 2;
  37. // Set animation "run" on track 0, looped.
  38. spineboy.state.setAnimation(0, "run", true);
  39. // Add the display object to the stage.
  40. app.stage.addChild(spineboy);
  41. })();
  42. </script>
  43. </body>
  44. </html>