12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <!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/[email protected]/dist/phaser.js"></script>
- <script src="../dist/iife/spine-phaser.js"></script>
- <link rel="stylesheet" href="../../index.css" />
- <title>Spine Phaser Example</title>
- </head>
- <body class="p-4 flex flex-col items-center">
- <h1>Multi-scene test</h1>
- </body>
- <script>
- class Scene1 extends Phaser.Scene {
- constructor() {
- super({ key: "Scene1" });
- }
- 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);
- this.input.once("pointerdown", () => this.scene.start("Scene2"));
- }
- }
- class Scene2 extends Phaser.Scene {
- constructor() {
- super({ key: "Scene2" });
- }
- preload() {
- this.load.spineJson("raptor-data", "assets/raptor-pro.json");
- this.load.spineAtlas("raptor-atlas", "assets/raptor-pma.atlas");
- }
- create() {
- const raptor = this.add.spine(300, 600, "raptor-data", "raptor-atlas");
- raptor.scale = 0.5;
- raptor.animationState.setAnimation(0, "walk", true);
- this.input.once("pointerdown", () => this.scene.start("Scene1"));
- }
- }
- const config = {
- type: Phaser.AUTO,
- width: 800,
- height: 600,
- type: Phaser.WEBGL,
- scene: [Scene1, Scene2],
- plugins: {
- scene: [
- {
- key: "spine.SpinePlugin",
- plugin: spine.SpinePlugin,
- mapping: "spine",
- },
- ],
- },
- };
- const game = new Phaser.Game(config);
- </script>
- </html>
|