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

How to capture global touch event in phaser.js

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

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");
});

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