I currently have two pointer events which essentially do the same thing:
gameState.idle.on('pointerout', function(){
scene.sys.canvas.style.cursor = 'default';
gameState.pet_cursor.alpha = 0;
});
gameState.idle.on('pointerup', function(){
scene.sys.canvas.style.cursor = 'default';
gameState.pet_cursor.alpha = 0;
});
Is there any way to combine these two? For example, I tried gameState.idle.on('pointerup, pointerout', function(){});
, but that evidently didn't work.
CodePudding user response:
No, it is not possible, but you could write one handler function and use it for both events.
like this:
...
function mouseHandler(){
scene.sys.canvas.style.cursor = 'default';
gameState.pet_cursor.alpha = 0;
}
function create() {
...
gameState.idle.on('pointerout', mouseHandler);
gameState.idle.on('pointerup', mouseHandler);
...
}
Important: not parentheses after
mouseHandler
, in the event handler.