Jump to content

Resizing renderer makes tap/touche events off


stamas47
 Share

Recommended Posts

I have a canvas with a set aspect ratio of 16:9 and I am resizing the renderer every time the window size changes 

game.resize = function()    {        var original = _default_screenWidth / _default_screenHeight;        var designer = window.innerWidth / window.innerHeight;                if ( window.innerWidth < _default_screenWidth || window.innerHeight < _default_screenHeight )        {            if ( original > designer )            {                game.renderer.resize(window.innerWidth,window.innerWidth/original);            }            else            {                game.renderer.resize(window.innerHeight*original,window.innerHeight);            }            _DOM.style.width = game.renderer.width;            _DOM.style.height = game.renderer.height;            game.stage.scale.x = game.renderer.width / _default_screenWidth;            game.stage.scale.y = game.renderer.height / _default_screenHeight;        }    };        window.addEventListener("resize",game.resize);

Problem is if I tap certain buttons (PIXI.Container) , they are not firing, only if i tap a little bit lower, so it's only the Y axis that's off.

 

Here is the code for the button

if ( Game.mobile )    {        button.container.interactive = true;        button.container.buttonMode = true;        button.container.tap = function()        {            button.Press();        };    }

If the window does not need any scaling then everything works fine.

Link to comment
Share on other sites

I'm seeing this problem too, on pixi.js v3.0.6. Clicks seem to work fine; only touch-events stop working properly.

 

I worked around this temporarily by setting the correct resolution, width and height on the renderer when starting up PIXI. Touch events will probably stop working again if the window is resized for any reason though.

 

Note: my project is also using renderer.resolution > 1. Not sure if this is required to encounter the problem. 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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