how to get activePointer pressed duration of sprite in Phaser

前端 未结 2 978
南笙
南笙 2021-01-17 04:45

I\'m creating pinball game using Phaser Framework.

When the ball holder is pressed (please check attached screenshot so you have an idea what I mean ball holder), d

相关标签:
2条回答
  • 2021-01-17 05:14

    You can get the time from the scene and calculate it with the downTime from the activePointer. So, you can try this approach:

    function update(time, delta){
        console.log(time - window.game.input.activePointer.downTime);
    }
    

    I came to the conclusion that this is the best approach when you want to get the duration on press down key because there is not duration attribute in activePointer anymore(Phaser3). So, this code works on Phaser 3 as well.

    I hope it helps!

    0 讨论(0)
  • 2021-01-17 05:41

    in phaser 3 something like

    function update(){
     var duration = 0
     if( this.input.activePointer.isDown ){
      duration++;
     }
    }
    
    0 讨论(0)
提交回复
热议问题