Resizing renderer makes tap/touche events off

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);            }   = game.renderer.width;   = 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 ( )    {        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.

Share this post

Link to post
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. 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.