Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Phaser framework 未触发Phaser 3场景输入.on()触摸事件_Phaser Framework - Fatal编程技术网

Phaser framework 未触发Phaser 3场景输入.on()触摸事件

Phaser framework 未触发Phaser 3场景输入.on()触摸事件,phaser-framework,Phaser Framework,我在一个角度组件(ionic项目)的构造函数中有以下设置 我在create方法中为click/touch事件设置了一个监听器,如下所示: create(scene){ scene.input.on('pointerup', this.moveSourceSprite, scene); } 但是,永远不会调用moveSourceSprite。但是,当我在游戏中收听pointerupoutside并单击时,会调用moveSourceSprite 我想,由于某种原因,这个场景听不到

我在一个角度组件(ionic项目)的构造函数中有以下设置

我在create方法中为click/touch事件设置了一个监听器,如下所示:

create(scene){
   scene.input.on('pointerup', this.moveSourceSprite, scene);      
}
但是,永远不会调用moveSourceSprite。但是,当我在游戏中收听pointerupoutside并单击时,会调用moveSourceSprite

我想,由于某种原因,这个场景听不到整个游戏区域的声音

我对Phaser是全新的,并且在这一点上被卡住了。如果你能帮助我,我将不胜感激

谢谢

道格
var myScene1={
键:'scene1',
预加载:函数(){
this.load.image('alien1','sprites/phaser-alien.png');;
},
创建:函数(){
this.add.image(100100,'alien1');
this.input.on('pointerup',()=>{game.scene.start('scene2');game.scene.stop('scene1')},myScene1);
},
}
var myScene2={
关键词:“场景2”,
预加载:函数(){
this.load.image('alien2','sprites/alien2.png');;
},
创建:函数(){
this.add.image(100100,'alien2');
this.input.on('pointerup',()=>{game.scene.start('scene1');game.scene.stop('scene2')},myScene2);
},
}
变量配置={
类型:Phaser.AUTO,
宽度:600,
身高:600,
加载器:{
baseURL:'https://raw.githubusercontent.com/nazimboudeffa/assets/master/',
交叉源:“匿名”
},
父级:'相位器示例',
场景:[myScene1,myScene2]
};
var game=new Phaser.game(配置);
游戏。场景。开始('scene1')
var myScene1={
键:'scene1',
预加载:函数(){
this.load.image('alien1','sprites/phaser-alien.png');;
},
创建:函数(){
this.add.image(100100,'alien1');
this.input.on('pointerup',()=>{game.scene.start('scene2');game.scene.stop('scene1')},myScene1);
},
}
var myScene2={
关键词:“场景2”,
预加载:函数(){
this.load.image('alien2','sprites/alien2.png');;
},
创建:函数(){
this.add.image(100100,'alien2');
this.input.on('pointerup',()=>{game.scene.start('scene1');game.scene.stop('scene2')},myScene2);
},
}
变量配置={
类型:Phaser.AUTO,
宽度:600,
身高:600,
加载器:{
baseURL:'https://raw.githubusercontent.com/nazimboudeffa/assets/master/',
交叉源:“匿名”
},
父级:'相位器示例',
场景:[myScene1,myScene2]
};
var game=new Phaser.game(配置);
游戏。场景。开始('scene1')

非常感谢您的回复,非常感谢。您的示例与文档相符。然而,由于某些原因,我的点击只能被捕获为外部事件。我的意思是,不是pointerup,而是pointerupoutside工作,这让我觉得命中区域有问题。不过,我还没弄明白。试着在JSFIDLE中发布一些代码并分享一条评论。我会看看ITI Nazim,非常感谢您的时间。你的JS代码运行得很好。我认为我的问题与html连接有关。我用的是离子型的,所以这可能也与此有关。基本上,我的目标是phaser父级,几乎将phaser置于后台!因此,它无法捕获单击。例如,当我为div添加背景色时,我看不到phaser场景。这正常吗?我玩了z指数,但那没有帮助。你以前见过类似的东西吗?上面的评论有误导性,因为我注意到游戏对象可以捕捉点击。它只是因为某些原因与场景相关…很多问题道格,我不知道从哪一个开始,所以首先我们只使用canvas,这意味着你给它一个id,或者让phaser自动将其添加到HTML5页面,请尝试JSFIDLE或codepen,最好谈谈代码;)非常感谢您的回复,我非常感谢。您的示例与文档相符。然而,由于某些原因,我的点击只能被捕获为外部事件。我的意思是,不是pointerup,而是pointerupoutside工作,这让我觉得命中区域有问题。不过,我还没弄明白。试着在JSFIDLE中发布一些代码并分享一条评论。我会看看ITI Nazim,非常感谢您的时间。你的JS代码运行得很好。我认为我的问题与html连接有关。我用的是离子型的,所以这可能也与此有关。基本上,我的目标是phaser父级,几乎将phaser置于后台!因此,它无法捕获单击。例如,当我为div添加背景色时,我看不到phaser场景。这正常吗?我玩了z指数,但那没有帮助。你以前见过类似的东西吗?上面的评论有误导性,因为我注意到游戏对象可以捕捉点击。它只是因为某些原因与场景相关…很多问题道格,我不知道从哪一个开始,所以首先我们只使用canvas,这意味着你给它一个id,或者让phaser自动将其添加到HTML5页面,请尝试JSFIDLE或codepen,最好谈谈代码;)
create(scene){
   scene.input.on('pointerup', this.moveSourceSprite, scene);      
}