rexrainbow / phaser3-rex-notes

Notes of phaser3 engine
MIT License
1.21k stars 261 forks source link

Can I detect both of click down and up on one button...? #214

Closed KLA6 closed 2 years ago

KLA6 commented 2 years ago

I always appreciate for your great library, and I have a more question.

In the UI Buttons, the button has a custom event as 'button.click'.

But it has a configuration as 'click' which only choose one of 'pointerdown' and 'pointerup'.

I want to make a button...

Is there any wat to detect both of click down and up on one button...?

Thank you for your reading.

KLA6 commented 2 years ago

Just FYI, I can use this to detect 'pointerup' to mix with the button's action. : )

scene.input.on('pointerdown', function(pointer){
    // ...
});

BTW, I'm asking whether there is any better way to make the codes to be simpler.

rexrainbow commented 2 years ago

That's an application specific feature, not a normal ui behavior, imo. Thus I won't add it into Buttons. On the other hand, there has press behavior in rexui package

var press = scene.rexUI.add.press(gameObject, config)
    .on('pressstart', function(press, gameObject, lastPointer){
})
    .on('pressend', function(press, gameObject, lastPointer){
})
KLA6 commented 2 years ago

Thank you so much for your quick response, I've noted well...! : )