mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-04 14:24:53 +08:00
46 lines
1.3 KiB
HTML
46 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script src="//cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js"></script>
|
|
<script src="https://unpkg.com/@esotericsoftware/spine-phaser@4.1.*/dist/iife/spine-phaser.min.js"></script>
|
|
<title>Spine Phaser Example</title>
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Basic example</h1>
|
|
</body>
|
|
<script>
|
|
class BasicExample extends Phaser.Scene {
|
|
preload() {
|
|
this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
|
|
this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
|
|
}
|
|
|
|
create() {
|
|
const spineboy = this.add.spine(400, 500, 'spineboy-data', "spineboy-atlas");
|
|
spineboy.scale = 0.5;
|
|
spineboy.animationState.setAnimation(0, "walk", true);
|
|
}
|
|
}
|
|
|
|
const config = {
|
|
type: Phaser.AUTO,
|
|
width: 800,
|
|
height: 600,
|
|
type: Phaser.WEBGL,
|
|
scene: [BasicExample],
|
|
plugins: {
|
|
scene: [
|
|
{ key: "spine.SpinePlugin", plugin: spine.SpinePlugin, mapping: "spine" }
|
|
]
|
|
}
|
|
};
|
|
|
|
const game = new Phaser.Game(config);
|
|
</script>
|
|
|
|
</html> |