Sign in to follow this  
Dylan M

Image and Button Click Not Working on Android Chrome

Recommended Posts

Hello all. I am having a browser-specific issue with Phaser 2.10.0 that I cannot seem to understand. I have the following code for a button.

minDimension = Math.min(game.width, game.height);
resetButton = game.add.sprite(game.width * 0.5, game.height * 0.925, 'Reset');
resetButton.anchor.setTo(0.5, 0.5);
resetButton.width = resetButton.height = minDimension * 0.075;
resetButton.inputEnabled = true;
resetButton.events.onInputDown.add(resetProcess, this);

This puts a reset button image at the middle of the bottom of the browser window.

As expected, when clicked or tapped, the resetProcess() function is called and the level in my game is reset. This works as expected in most browsers on desktop and mobile; however, in Android Chrome (in my case, Android 7.0.0 and Chrome 64.0.3282.137) the button appears but does not do anything when clicked. I verified that the issue is not in my resetProcess() function. It seems that the onInputDown event isn't working properly.

I also tried the following code, using a button instead of an image.

minDimension = Math.min(game.width, game.height);
resetButton = game.add.button(game.width * 0.5, game.height * 0.925, 'Reset', resetProcess, this);
resetButton.anchor.setTo(0.5, 0.5);
resetButton.width = resetButton.height = minDimension * 0.075;

This caused behavior identical to the snippet above. 

Previously, a few months ago, I was able to get my button working as expected no matter the browser, and no changes were made to this part of my code since then. 

Does anyone have any thoughts as to what might be causing this issue, and how to fix it?

Thanks.

Share this post


Link to post
Share on other sites

I'm having the same problem I noticed that if the sprites were really big it would work. I drew debug info for the active pointer it seems that the input coordinates do not match up. So you still have input but its not in the right place. Looking into a fix now.

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

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.