Bugfix: Use actual atlas source id instead of a fixed static integer value

This commit is contained in:
Torsten 2025-11-05 05:29:07 +01:00
parent 0ada26f6a1
commit ff49c10c8f

View file

@ -4,6 +4,7 @@ signal hex_clicked(cell_pos:Vector2, atlas_coords:Vector2)
func _ready(): func _ready():
print("TileMapLayer is alive") print("TileMapLayer is alive")
func _input(event: InputEvent): func _input(event: InputEvent):
#print("Unhandled input") #print("Unhandled input")
@ -21,10 +22,9 @@ func _input(event: InputEvent):
#Example: Place/erase tile on click #Example: Place/erase tile on click
if event.button_index == MOUSE_BUTTON_LEFT: if event.button_index == MOUSE_BUTTON_LEFT:
print("Click left") print("Click left")
#pass var atlas_source_id = self.tile_set.get_source_id(0) # source id of first atlas in TileMapLayer
#set_cell(cell_pos, 51, Vector2i(6, 1)) # Place tile set_cell(cell_pos, atlas_source_id, Vector2i(1, 2)) # Place tile
set_cell(cell_pos, 0, Vector2i(1, 2)) # Place tile
elif event.button_index == MOUSE_BUTTON_RIGHT: elif event.button_index == MOUSE_BUTTON_RIGHT:
print("Click right") print("Click right")
set_cell(cell_pos, -1) # Erase tile set_cell(cell_pos, -1) # Erase tile