mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
71 lines
2.4 KiB
HTML
71 lines
2.4 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>
|
|
<script src="https://cdn.jsdelivr.net/npm/lil-gui@0.20.0/dist/lil-gui.umd.min.js"></script>
|
|
<link href="https://cdn.jsdelivr.net/npm/lil-gui@0.20.0/dist/lil-gui.min.css" rel="stylesheet">
|
|
<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: "spineboyData", src: "./assets/coin-pro.json"});
|
|
PIXI.Assets.add({alias: "spineboyAtlas", src: "./assets/coin-pma.atlas"});
|
|
await PIXI.Assets.load(["spineboyData", "spineboyAtlas"]);
|
|
|
|
// Create the spine display object
|
|
const spineboy = spine.Spine.from({
|
|
skeleton: "spineboyData",
|
|
atlas: "spineboyAtlas",
|
|
scale: 1,
|
|
// darkTint: true,
|
|
});
|
|
spineboy.autoUpdate = false;
|
|
|
|
// 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;
|
|
|
|
// Set animation "run" on track 0, looped.
|
|
spineboy.state.setAnimation(0, "animation", true);
|
|
|
|
// Add the display object to the stage.
|
|
app.stage.addChild(spineboy);
|
|
|
|
const myObject = { time: 0, time2: 0 };
|
|
let prevValue = myObject.time;
|
|
let prevValue2 = myObject.time2;
|
|
spineboy.update(prevValue / 10)
|
|
|
|
const gui = new lil.GUI({});
|
|
gui
|
|
.add(myObject, 'time').min(0).max(10).step(0.001)
|
|
.name( 'time' )
|
|
.onChange(value => {
|
|
spineboy.update((value - prevValue) / 10)
|
|
prevValue = value;
|
|
});
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html> |