Jump to content

Phaser resize events + input events question


Recommended Posts

Hi, I've searched the forum and couldn't really find an answer for this, so here is my question. In short is there a way to resize click regions for mouse events after you resize your canvas?

A bit of explanation. I have built an interactive map, where the user can click a region and highlight it green, the problem occurs when I shrink the browser and try to click on different regions.

It appears that even though I shrunk the map, the click regions still remain the same size (See example image). For instance I can click to the right of a region and still capture its event.

Any help with this would be greatly appreciated. I've attached a snippet of my resize code and can provide more examples on request. thanks :)


handleResize: function handleResize(event) {
            this.parentDiv = document.getElementById('world-map');
            this.parentWidth = this.parentDiv.offsetWidth;
            this.parentHeight = this.parentDiv.offsetHeight;

            console.log('this.parentWidth, this.parentHeight: ', this.parentWidth, this.parentHeight);

            // this.game.scale.scaleMode = Phaser.ScaleManager.RESIZE; // Breaks other functionality

            // Resize the canvas

            // Resize the game
            this.game.width = this.parentWidth;
            this.game.height = this.parentHeight;

            // Refresh the game scale



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...