Godot Version
Godot v4.2.1.stable - Windows 10.0.22621 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1660 Ti (NVIDIA; 31.0.15.5222) - Intel(R) Core™ i7-9750H CPU @ 2.60GHz (12 Threads)
Question
Hi there! I am attempting to duplicate a match 3 type game with some RPG elements and I can’t seem to get the GridContainer to arrange it’s Children so that they are clickable…
I have a Tile.tscn with a parent Control node and a Sprite2D child
The custom_minimum_size is set to 64x64 and the tile sprites are also that size.
I then have my Puzzle.tscn with a parent Node2D and a child GridContainer.
I programmatically instantiate a Tile.tscn and randomly load a sprite texture onto it and then add it to the GridContainer with: $GridContainer.add_child(tile)
The GridContainer is also set to a custom_minimum_size of 512x512 since my grid is an 8x8 with 64px size tiles.
It looks amazing when test playing the scene, see example here:
The problem is when I go to click on the Tiles or even when I click outside of the grid, it registers that I am clicking 10+ Tiles at once.
After some debugging I realized the Tiles’ global_positions were mostly all the same with some random ones being different.
Here is some of the console print to give an idea:
Tile: Tile_0_0at position: (0, 0)
Tile: Tile_0_1at position: (0, 0)
Tile: Tile_0_2at position: (0, 0)
Tile: Tile_0_3at position: (0, 0)
Tile: Tile_0_4at position: (0, 0)
Tile: Tile_0_5at position: (0, 0)
Tile: Tile_0_6at position: (0, 0)
Tile: Tile_0_7at position: (0, 0)
Tile: Tile_1_0at position: (0, 0)
Tile: Tile_5_0at position: (320, 64)
Tile: Tile_5_1at position: (320, 128)
Tile: Tile_5_2at position: (320, 192)
Tile: Tile_5_3at position: (320, 256)
Tile: Tile_5_4at position: (320, 320)
Tile: Tile_5_5at position: (320, 384)
Tile: Tile_5_7at position: (0, 0)
Tile: Tile_6_0at position: (384, 64)
Am I missing something obvious here to make sure the GridContainer lays out the 64x64 Tiles to not only look good visually (see above picture) but are also clickable?