mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 22:34:53 +08:00
47 lines
1.6 KiB
HTML
47 lines
1.6 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>spine-pixi-v8</title>
|
|
<script src="https://cdn.jsdelivr.net/npm/pixi.js@8.4.1/dist/pixi.js"></script>
|
|
<script src="../dist/iife/spine-pixi-v8.js"></script>
|
|
<link rel="stylesheet" href="../../index.css">
|
|
</head>
|
|
|
|
<body>
|
|
<script>
|
|
(async function () {
|
|
var app = new PIXI.Application();
|
|
await app.init({
|
|
width: window.innerWidth,
|
|
height: window.innerHeight,
|
|
resolution: window.devicePixelRatio || 1,
|
|
autoDensity: true,
|
|
resizeTo: window,
|
|
backgroundColor: 0x2c3e50,
|
|
hello: true,
|
|
})
|
|
document.body.appendChild(app.canvas);
|
|
|
|
// Pre-load the skeleton data and atlas. You can also load .json skeleton data.
|
|
PIXI.Assets.add({alias: "snowglobeData", src: "./assets/snowglobe-pro.skel"});
|
|
PIXI.Assets.add({alias: "snowglobeAtlas", src: "./assets/snowglobe-pma.atlas"});
|
|
await PIXI.Assets.load(["snowglobeData", "snowglobeAtlas"]);
|
|
|
|
// Create the spine display object
|
|
const snowglobe = spine.Spine.from({skeleton: "snowglobeData", atlas: "snowglobeAtlas",
|
|
scale: 0.25,
|
|
});
|
|
|
|
// Center the spine object on screen.
|
|
snowglobe.x = window.innerWidth / 2;
|
|
snowglobe.y = window.innerHeight / 2 + snowglobe.getBounds().height / 4;
|
|
|
|
// Set animation "FOA" on track 0, looped.
|
|
snowglobe.state.setAnimation(0, "shake", true);
|
|
|
|
// Add the display object to the stage.
|
|
app.stage.addChild(snowglobe);
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |