visibility-test.html 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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-v3.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. const config = {
  17. type: Phaser.AUTO,
  18. width: 800,
  19. height: 600,
  20. type: Phaser.WEBGL,
  21. scene: {
  22. preload: preload,
  23. create: create,
  24. pack: {
  25. files: [
  26. {
  27. type: "scenePlugin",
  28. key: "spine.SpinePlugin",
  29. url: "../dist/iife/spine-phaser-v3.js",
  30. sceneKey: "spine",
  31. },
  32. ],
  33. },
  34. },
  35. };
  36. const game = new Phaser.Game(config);
  37. function preload() {
  38. this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
  39. this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
  40. }
  41. function create() {
  42. const spineboy = this.add.spine(
  43. 250,
  44. 500,
  45. "spineboy-data",
  46. "spineboy-atlas"
  47. );
  48. spineboy.scale = 0.5;
  49. spineboy.animationState.setAnimation(0, "walk", true);
  50. const spineboy2 = this.add.spine(
  51. 550,
  52. 500,
  53. "spineboy-data",
  54. "spineboy-atlas"
  55. );
  56. spineboy2.scale = 0.5;
  57. spineboy2.animationState.setAnimation(0, "run", true);
  58. this.input.on(
  59. "pointerdown",
  60. () => (spineboy2.visible = !spineboy2.visible)
  61. );
  62. }
  63. </script>
  64. </html>