Basically I have a scene with multiple image and text game objects. I want them to be clickable, but handle clicks on different objects with different handlers. I also want to use {useHandCursor: true} configuration on clickable objects.
But as far as I know every object that was .setInteractive() is handled by single this.input.on per scene. So is there a way to use different handlers for different objects in one scene?
The setInteractive() method allows you to use a different handler for each object. Something like this:
myObject.on('pointerdown', function (pointer) {
console.log('click');
});
The other way would be something like:
var myTextObject = this.add.text(50,50,'myText');
myTextObject.name = 'text1';
this.input.on('gameobjectdown', function (pointer, gameObject) {
switch(gameObject.name){
case 'text1':
myHandler1();
break;
case 'text2':
// more cases
}
});