depth-test.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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>Depth 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. 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.image("logo", "phaser.png");
  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. this.add.image(400, 350, "logo").setName("logo1").setDepth(2);
  43. const spineboy = this.add.spine(
  44. 400,
  45. 600,
  46. "spineboy-data",
  47. "spineboy-atlas"
  48. );
  49. spineboy.animationState.setAnimation(0, "walk", true);
  50. spineboy.setScale(0.5);
  51. spineboy.setDepth(1);
  52. this.add
  53. .text(400, 300, "Set Depth Test", {
  54. font: "16px Courier",
  55. fill: "#00ff00",
  56. })
  57. .setName("text")
  58. .setOrigin(0.5);
  59. }
  60. </script>
  61. </html>