basic-example.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>
  8. <script src="../dist/iife/spine-phaser.js"></script>
  9. <link rel="stylesheet" href="../../index.css" />
  10. <title>Spine Phaser Example</title>
  11. </head>
  12. <body class="p-4 flex flex-col items-center">
  13. <h1>Basic example</h1>
  14. </body>
  15. <script>
  16. class BasicExample extends Phaser.Scene {
  17. preload() {
  18. this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
  19. this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
  20. }
  21. create() {
  22. const spineboy = this.add.spine(
  23. 400,
  24. 500,
  25. "spineboy-data",
  26. "spineboy-atlas"
  27. );
  28. spineboy.setInteractive();
  29. spineboy.displayWidth = 200;
  30. spineboy.displayHeight = (spineboy.height / spineboy.width) * 200;
  31. this.input.enableDebug(spineboy, 0xff00ff);
  32. spineboy.animationState.setAnimation(0, "walk", true);
  33. }
  34. }
  35. new Phaser.Game({
  36. type: Phaser.AUTO,
  37. width: 800,
  38. height: 600,
  39. type: Phaser.WEBGL,
  40. scene: [BasicExample],
  41. plugins: {
  42. scene: [
  43. {
  44. key: "spine.SpinePlugin",
  45. plugin: spine.SpinePlugin,
  46. mapping: "spine",
  47. },
  48. ],
  49. },
  50. });
  51. </script>
  52. </html>