问题描述
我正在尝试将 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;
});
我想用锤子砸鸡蛋,如果你能从代码看出。
谢谢
解决方法
修复 - 删除:
dom: {
createContainer: true
},
容器干扰了拖动。 感谢 https://phaser.discourse.group/t/drag-and-drop-not-working/9424/2 的 Milton 的帮助!
马格努斯