Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Hey sorry it wasn't working but I've just tested it a bunch and it works on everything I have - can you confirm the little clickable icons aren't showing up in adjacent tiles? I'm not the best gif maker but I recorded a gif below:


Will play your game in just a moment when I make sure this is working!

Sorry, my gif isn't much better. It seemed like the mouse position was offset, and the left click didn't seem to do much. The gif doesn't show it, but I also tried clicking near the sub. I'm on a Mac if that helps! 

Are you using a Retina/High-DPI display? I had no idea this would affect it but after reading a bunch of StackOverflow posts I think I see what's happening. I appreciate you showing me what you're seeing as it is working fine on my old 2012 Macbook Pro but obviously they have come a long way in 10 years.

Yeah, I think you hit the nail on the head. I do indeed have a Retina display, I just tried the game on my other monitor and it worked perfectly!

Can you try it one more time on your Retina display please? I just pushed an update that should hopefully fix high-DPI issues if my understanding of the issue is correct.

(+1)

Yeah that fixed it, works perfectly!

(1 edit) (+1)

Hey man I really can't thank you enough for showing me there was a problem with the scaling on Macs; not sure how I ever would have known. Posting a little code snippet here for anyone else using mouse positions in case Google brings them to this corner of the internet while fighting with WebGL and Retina displays. Technically it could work for any tile-based game to easily say what tile (or even pixel on a low-res game like this) the mouse is over. Thank you!!!

Position WhatTileIsMouseIn() {
    Vector2 mousePos = Input.mousePosition;
    mousePos = new Vector2 (mousePos.x, mousePos.y);
    float scaledMouseX = ((mousePos.x / Screen.width)) * 8; // the 8 here is how many tiles across your screen has
    float scaledMouseY = ((mousePos.y / Screen.height)) * 8 - 1; // the 8 is vertical tiles, minus 1 for the bottom border in my game
    return new Position((int)scaledMouseY, (int)scaledMouseX); // casting the floats to integers truncates them
}