0

我正在尝试将 Spine 添加到我的项目中,旧版本的 Phaser 不会加载我的 Spine,最新版本 (3.45.0) 可以正常工作。但是拖放在 3.45.0 中不起作用。旧版本,我的拖放工作没有问题。我的游戏对象说 draggable = true ......任何帮助将不胜感激。

<script src="//cdn.jsdelivr.net/npm/phaser@3.54.0/dist/phaser.min.js"></script>
<script src="./libraries/SpinePlugin.min.js"></script>
config = {
  type: Phaser.AUTO,
  //mode: Phaser.Scale.FIT,
  parent: "content",
  width: windWide,
  height: windHigh,
  physics: {
      default: "arcade",
      arcade: {
        debug: true,
     
    }
      },
  dom: {
      createContainer: true
  },
  scene:[
    LoadScene, MenuScene, UIScene, TurnDevice, Review, Vocab, ListenMatch, Spell, WordImageMatch, GameScene
  ],
  plugins: {
    scene: [
        { key: 'SpinePlugin', plugin: window.SpinePlugin, mapping: 'spine' }
    ]
  }
this.load.spine('eggBreak', 'src/assets/json/eggBreak.json', 'src/assets/json/eggBreak.atlas');
this.load.spine('eggWhole', 'src/assets/json/eggWhole.json', 'src/assets/json/eggWhole.atlas');
  let egg = _this.add.spine(windWide*.5, windHigh*.25, 'eggWhole', 'idle', true)
  this.physics.add.existing(egg);
     
  let hammer = this.physics.add.image(windWide*.5, windHigh*.85, "hammer").setInteractive()
       
    this.input.setDraggable(hammer);

    this.input.on('drag', function (pointer, gameObject, dragX, dragY) {

         gameObject.x = dragX;
         gameObject.y = dragY;
                    
     });

我正试图用锤子砸鸡蛋,如果你能从代码中看出的话。

谢谢

4

1 回答 1

0

修复 - 删除:

dom: {
      createContainer: true
  },

容器干扰了阻力。感谢 Milton 在https://phaser.discourse.group/t/drag-and-drop-not-working/9424/2上的帮助!

马格努斯

于 2021-04-30T02:13:42.327 回答