bounds-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. <link rel="stylesheet" href="../../index.css" />
  9. <title>Spine Phaser Example</title>
  10. </head>
  11. <body class="p-4 flex flex-col items-center">
  12. <h1>Bounds test</h1>
  13. </body>
  14. <script>
  15. const config = {
  16. type: Phaser.AUTO,
  17. width: 800,
  18. height: 600,
  19. type: Phaser.WEBGL,
  20. scene: {
  21. preload: preload,
  22. create: create,
  23. update: update,
  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. let spineboy;
  38. function preload() {
  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. spineboy = this.add.spine(
  44. 400,
  45. 300,
  46. "spineboy-data",
  47. "spineboy-atlas",
  48. new spine.SkinsAndAnimationBoundsProvider("run")
  49. );
  50. spineboy.scale = 0.4;
  51. spineboy.setInteractive();
  52. this.input.enableDebug(spineboy, 0xff00ff);
  53. spineboy.on("pointerdown", () =>
  54. spineboy.animationState.setAnimation(0, "run", true)
  55. );
  56. }
  57. let time = 0;
  58. function update(t, delta) {
  59. time += delta / 1000;
  60. const scale = 0.4 + Math.cos(time) * 0.2;
  61. spineboy.scale = scale;
  62. spineboy.angle++;
  63. }
  64. </script>
  65. </html>