canvas-test.html 1.4 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. <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>Canvas test</h1>
  13. </body>
  14. <script>
  15. const config = {
  16. type: Phaser.AUTO,
  17. width: 800,
  18. height: 600,
  19. type: Phaser.CANVAS,
  20. scene: {
  21. preload: preload,
  22. create: create,
  23. pack: {
  24. files: [
  25. {
  26. type: "scenePlugin",
  27. key: "spine.SpinePlugin",
  28. url: "../dist/iife/spine-phaser-v3.js",
  29. sceneKey: "spine",
  30. },
  31. ],
  32. },
  33. },
  34. };
  35. const game = new Phaser.Game(config);
  36. function preload() {
  37. this.load.spineBinary("spineboy-data", "/assets/spineboy-pro.skel");
  38. this.load.spineAtlas("spineboy-atlas", "/assets/spineboy-pma.atlas");
  39. }
  40. function create() {
  41. const spineboy = this.add.spine(
  42. 400,
  43. 300,
  44. "spineboy-data",
  45. "spineboy-atlas"
  46. );
  47. spineboy.scale = 0.5;
  48. spineboy.animationState.setAnimation(0, "walk", true);
  49. }
  50. </script>
  51. </html>