physics.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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>Physics example</h1>
  14. </body>
  15. <script>
  16. class BasicExample extends Phaser.Scene {
  17. preload() {
  18. this.load.spineBinary("sack-data", "assets/sack-pro.skel");
  19. this.load.spineAtlas("sack-atlas", "assets/sack.atlas");
  20. }
  21. create() {
  22. const gameObject = this.add.spine(
  23. 275,
  24. 500,
  25. "sack-data",
  26. "sack-atlas"
  27. );
  28. gameObject.displayWidth = 150;
  29. gameObject.displayHeight = (gameObject.height / gameObject.width) * 150;
  30. gameObject.animationState.setAnimation(0, "cape-follow-example", true);
  31. }
  32. }
  33. new Phaser.Game({
  34. type: Phaser.AUTO,
  35. width: 800,
  36. height: 600,
  37. type: Phaser.WEBGL,
  38. scene: [BasicExample],
  39. plugins: {
  40. scene: [
  41. {
  42. key: "spine.SpinePlugin",
  43. plugin: spine.SpinePlugin,
  44. mapping: "spine",
  45. },
  46. ],
  47. },
  48. });
  49. </script>
  50. </html>