mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
47 lines
1.6 KiB
HTML
47 lines
1.6 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>spine-pixi</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/pixi.js@7.4.2/dist/pixi.min.js"></script>
|
|
<script src="../dist/iife/spine-pixi-v7.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/tweakpane@3.1.9/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: 0x333333,
|
|
hello: true,
|
|
});
|
|
document.body.appendChild(app.view);
|
|
|
|
// Pre-load the skeleton data and atlas. You can also load .json skeleton data.
|
|
PIXI.Assets.add("sackData", "./assets/sack-pro.skel");
|
|
PIXI.Assets.add("sackAtlas", "./assets/sack-pma.atlas");
|
|
await PIXI.Assets.load(["sackData", "sackAtlas"]);
|
|
|
|
// Create the spine display object
|
|
const sack = spine.Spine.from({skeleton: "sackData", atlas: "sackAtlas",
|
|
scale: 0.2,
|
|
});
|
|
|
|
// Center the spine object on screen.
|
|
sack.x = window.innerWidth / 2;
|
|
sack.y = window.innerHeight / 2 + sack.getBounds().height / 2;
|
|
|
|
// Set animation "cape-follow-example" on track 0, looped.
|
|
sack.state.setAnimation(0, "cape-follow-example", true);
|
|
|
|
// Add the display object to the stage.
|
|
app.stage.addChild(sack);
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |