The Nodes within Tile
look like this:
- Tile (Node2D)
- Textures (Node2D)
- WireMesh (Node2D)
- Area2D
- BorderLines (Node2D)
(... the linespacing looks really wrong in the list above, but not sure if its this Donut Theme or if my Markdown is wrong)
I have this code in TileGrid._ready()
:
for grid_y in grid_size_y:
for grid_x in grid_size_x:
hex_tile_node = hex_tile_scene.instance()
hex_tile_node.grid_location.x = grid_x
hex_tile_node.grid_location.y = grid_y
hex_tile_node.position.x = (grid_x * row_offset.x) + (grid_y * column_offset.x)
hex_tile_node.position.y = (grid_x * row_offset.y) + (grid_y * column_offset.y)
add_child(hex_tile_node)
for grid_x in grid_size_x:
grid_tiles.append([])
for grid_yy in grid_size_y:
grid_tiles[grid_x].append(0)
for child in self.get_children():
if child.is_in_group('TILES'):
grid_tiles[child.grid_location.x][child.grid_location.y] = {'node': child, 'grid_x': child.grid_location.x, 'grid_y': child.grid_location.y, 'material': '_EMPTY'}
var new_z = 10000
for y in grid_size_y:
for x in grid_size_x:
grid_tiles[x][y].z_index = new_z
grid_tiles[x][y].node.update_z_index(new_z)
grid_tiles[x][y].node.z_index = new_z
new_z -= 1
I added a .update_z_index()
function to Tile
... but that doesn't work either. It does, however, print the current .z_index
for the selected Tile... and it is always 0.
Now, as for getting Z-Index to work with hover:
You'll see that I have a CollisionPolygon2D inside the Tile
objects; if I go to their _on_Area2D_mouse_entered()
function and add:
z_index += 10
then when I put my mouse over the Tile lo; it pops up above all the other Tiles and I can see in the console (courtesy of print(z_index)
) that the Z-Index has risen.
I don't seem to be able to use the Remote Scene Tree to investigate, as there are no Tiles actually in the Scene until TileGrid._ready()
executes and spawns them.