I’m working on a puzzle game that presents a grid of objects that the player needs to click/tap on. I am using Camera2D and BoxingViewportAdapter from Monogame Extended to scale the screen so that it will display in the same way across all devices. Clicking/tapping on them works perfectly and as-expected when playing the Windows version of the game, and also works perfectly on the two phones I’ve tried. The issue is, on some friends’ phones, when wanting to test the game on their devices, they are not able to accurately touch the objects throughout the screen. Those on the bottom of the grid (aka bottom of the screen), they have to offset their touch by an entire row on the grid, tapping on an object above the one they want to select the one they want.
After further questioning it seems that at the top of the screen, the touch controls are more receptive, and grow worse as it nears the bottom. Again, this doesn’t happen on my phone or any I have the disposal to test with easily, so I’m kind of stumped. Here’s the relevant code in my Game class where I declare the Camera and ViewportAdapter and use them to draw:
public void Initialize()
{
//…
viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, (int)Constants.WORLD_WIDTH, (int)Constants.WORLD_HEIGHT);
camera = new Camera2D(viewportAdapter);
//…
graphics.PreferredBackBufferWidth = 480;
graphics.PreferredBackBufferHeight = 800;
graphics.ApplyChanges();
//…
}
public void Draw(GameTime gameTime)
{
//…
spriteBatch.Begin(transformMatrix: camera.GetViewMatrix());
screenManager.Draw(spriteBatch);
spriteBatch.End();
//…
}
Just a note, I have tried both camera.GetViewMatrix() and viewportAdapter.GetScaleMatrix() and neither are able to fix the touch issues on other peoples’ phones. I’ve also tried not giving any PreferredBackBufferWidth and Height. When polling for input, I am using this:
camera.ScreenToWorld(touchCollection[0].Position)
Any reason you can think of why this wouldn’t work across all devices? I greatly appreciate any help or feedback.
PS - If you want to try for yourself to see if it works for you, my latest test build is on itch.io: https://yityit2000.itch.io/bubble-pop, password is bubblepop. You’ll have to allow sources outside google play for apps to try it. No build for iOS yet.