visibility-test-container.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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>Visibility Test 2</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.js",
  30. sceneKey: "spine",
  31. },
  32. ],
  33. },
  34. },
  35. };
  36. const game = new Phaser.Game(config);
  37. function preload() {
  38. this.load.image("coin", "assets/coin-pma.png");
  39. this.load.spineBinary("spineboy-data", "assets/spineboy-pro.skel");
  40. this.load.spineAtlas("spineboy-atlas", "assets/spineboy-pma.atlas");
  41. }
  42. function create() {
  43. const spineboy = this.add.spine(
  44. 100,
  45. 400,
  46. "spineboy-data",
  47. "spineboy-atlas"
  48. );
  49. spineboy.scale = 0.25;
  50. spineboy.animationState.setAnimation(0, "idle", true);
  51. const spineboy2 = this.add.spine(
  52. 250,
  53. 400,
  54. "spineboy-data",
  55. "spineboy-atlas"
  56. );
  57. spineboy2.scale = 0.25;
  58. spineboy2.animationState.setAnimation(0, "walk", true);
  59. window.coin = this.add
  60. .image(400, 500, "coin")
  61. .setOrigin(0.5, 1)
  62. .setScale(0.3)
  63. .setCrop(304, 283, 286, 284);
  64. const spineboy3 = this.add.spine(
  65. 500,
  66. 400,
  67. "spineboy-data",
  68. "spineboy-atlas"
  69. );
  70. spineboy3.scale = 0.25;
  71. spineboy3.animationState.setAnimation(0, "run", true);
  72. const spineboy4 = this.add.spine(
  73. 650,
  74. 400,
  75. "spineboy-data",
  76. "spineboy-atlas"
  77. );
  78. spineboy4.scale = 0.25;
  79. spineboy4.animationState.setAnimation(0, "shoot", true);
  80. const grp = this.add
  81. .container()
  82. .add([spineboy, spineboy2, coin, spineboy3, spineboy4]);
  83. this.input.on(
  84. "pointerdown",
  85. () => (spineboy2.visible = !spineboy2.visible)
  86. );
  87. }
  88. </script>
  89. </html>