Drag and drop image not dragging in Phaser 3 v3.54.0

1k Views Asked by At

I am trying to add Spine into my project, older versions of of Phaser won't load my Spine, the newest (3.45.0) works fine. But drag and drop doesn't work in 3.45.0. Older versions, my drag and drop works with no problem. My game object says draggable = true... Any help would be appreciated.

<script src="//cdn.jsdelivr.net/npm/[email protected]/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;
                    
     });

I am trying to smash an egg with a hammer, if you can tell by the code.

Thanks

1

There are 1 best solutions below

0
On

The fix - remove:

dom: {
      createContainer: true
  },

The container was interfering with the drag. Thanks to Milton on https://phaser.discourse.group/t/drag-and-drop-not-working/9424/2 for your help!

Magnus