【问题标题】:Drag and drop image not dragging in Phaser 3 v3.54.0在 Phaser 3 v3.54.0 中拖放图像不拖动
【发布时间】:2021-04-29 06:59:05
【问题描述】:

我正在尝试将 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;
                    
     });

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

谢谢

【问题讨论】:

  • 更新 - dragstart 和 dragend 都触发,因为我可以从中获取 console.log,拖放输入 - 无响应

标签: javascript drag-and-drop draggable phaser-framework spine


【解决方案1】:

修复 - 删除:

dom: {
      createContainer: true
  },

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

马格纳斯

【讨论】:

    猜你喜欢
    • 2010-12-05
    • 1970-01-01
    • 2013-06-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多