Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | potatobanana |
hi everyone,
i want some of my tile hover when mouse at top of them,for exmple id = 0 tile, how should i do it?
something like this
this my code so far
extends TileMap
export (PackedScene) var tower_1
func _unhandled_input(event: InputEvent) -> void:
var mouse_pos = get_viewport().get_mouse_position()
var tile_pos = world_to_map(mouse_pos)
var tile_cell_at_mouse_pos = get_cellv(tile_pos)
if event.is_action_pressed("Lclick"):
####################################################################################################
if tile_cell_at_mouse_pos != INVALID_CELL: # if tile cell is full with tile
if tile_cell_at_mouse_pos == 0:# transform normal grass tile to dirt tile
if global_data.hoe > 0:
global_data.hoe -= 1
set_cellv(tile_pos,randi() % 2 + 1)
else:
print("need hoe")
if tile_cell_at_mouse_pos == 2:
if global_data.pickaxe >0:
global_data.pickaxe -= 1
set_cellv(tile_pos,1)
else:
print("need pickaxe")