Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with setInteractive function in phaser 3

I have recently started using version 3.18 for a game which was earlier developed in version 3.9. Also, I am using Phaser.SCALE.FIT in config.

But on clicking or touching(in case of mobile) on some button images on the canvas nothing happens. I am using gameObject.setInteractive() and then gameObject.on(‘pointerdown’, function(){}) but the pointer down is not detected.

But if the size of the browser window changes somehow in between the game then the click is detected and everything else works fine.

How can I fix this issue any suggestion will be great help.

like image 947
Jagriti Agnihotri Avatar asked Dec 08 '25 09:12

Jagriti Agnihotri


1 Answers

I don’t know the exact problem but when I used scene.scale.setGameSize(width, height) (https://rexrainbow.github.io/phaser3-rex-notes/docs/site/scalemanager/#events) in the create() the game starts working properly.

like image 69
Jagriti Agnihotri Avatar answered Dec 14 '25 09:12

Jagriti Agnihotri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!