123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <html>
- <head>
- <meta charset="UTF-8" />
- <title>spine-pixi</title>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/pixi.min.js"></script>
- <script src="../dist/iife/spine-pixi-v7.js"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/tweakpane.min.js"></script>
- <link rel="stylesheet" href="../../index.css">
- </head>
- <body>
- <script>
- (async function () {
- var app = new PIXI.Application({
- width: window.innerWidth,
- height: window.innerHeight,
- resolution: window.devicePixelRatio || 1,
- autoDensity: true,
- resizeTo: window,
- backgroundColor: 0x2c3e50,
- hello: true,
- });
- document.body.appendChild(app.view);
- // Pre-load the skeleton data and atlas. You can also load .json skeleton data.
- PIXI.Assets.add("spineboyData", "./assets/spineboy-pro.skel");
- PIXI.Assets.add("spineboyAtlas", "./assets/spineboy-pma.atlas");
- await PIXI.Assets.load(["spineboyData", "spineboyAtlas"]);
- // Create the spine display object
- const spineboy = spine.Spine.from({skeleton: "spineboyData", atlas: "spineboyAtlas",
- scale: 0.5,
- });
- // Set the default mix time to use when transitioning
- // from one animation to the next.
- spineboy.state.data.defaultMix = 0.2;
- // Center the spine object on screen.
- spineboy.x = window.innerWidth / 2;
- spineboy.y = window.innerHeight / 2 + spineboy.getBounds().height / 2;
- // Set animation "run" on track 0, looped.
- spineboy.state.setAnimation(0, "run", true);
- // Add the display object to the stage.
- app.stage.addChild(spineboy);
- })();
- </script>
- </body>
- </html>
|