I have the following code:
function preload() {
this.load.svg('table', 'assets/svg/table.svg');
}
function create {
this.add.image(400, 300, 'table');
}
How can I highlight this picture when I hover over it?
I have the following code:
function preload() {
this.load.svg('table', 'assets/svg/table.svg');
}
function create {
this.add.image(400, 300, 'table');
}
How can I highlight this picture when I hover over it?
You can use the pointerover event like so:
let tableSvg;
function preload() {
this.load.svg('table', 'assets/svg/table.svg');
}
tableSvg = this.add.image(400, 300, 'table');
tableSvg.setInteractive();
tableSvg.on('pointerover', () => {
console.log(tableSvg)
});
Edit:
You can change the image's color like so:
tableSvg.on('pointerover', () => {
// setTint method takes a color value & change the image's color accordingly
tableSvg.setTint(185273)
});