gpt4 book ai didi

javascript - 如何在 phaser.js 中捕获全局触摸事件

转载 作者:行者123 更新时间:2023-11-29 21:39:50 27 4
gpt4 key购买 nike

我需要在触摸屏幕的任何部分后执行一些操作。此刻,我正在使用这样的东西:

update: function() {
if (this.game.input.activePointer.isDown) {
this.game.input.keyboard.onDownCallback = null;
this.start();
}
}

但我只是觉得不对,虽然我可能可以像使用键盘一样使用回调:

 this.game.input.keyboard.onDownCallback = function(e){
this.game.input.keyboard.onDownCallback = null;
self.start();
}

有什么方法可以使用触摸回调而不是检查更新吗?

最佳答案

this.game.input.onDown.add(function() {
console.log("input captured");
});

就这么简单。它适用于鼠标和触摸。

关于javascript - 如何在 phaser.js 中捕获全局触摸事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33369940/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com