It seems like adding code to map.gd anywhere lead to freeze of the map. Here is my code to the end of _ready()
extends Control
#warning-ignore:unused_class_variable
var mouse_in = false
#warning-
ignore:unused_class_variable
var dragging = false
onready var size = $TextureRect.get_size()
var
offset = Vector2()
var status = 'none'
var timer = 0
var currentloc = null
var newNode = find_node("sea").duplicate()
newNode.rect_position = Vector2(100,100)
newNode.name = "newZone"
find_node("roads").add_child(newNode)
func _ready():
for i in get_node("TextureRect/roads").get_children() +
get_node("TextureRect/towns").get_children():
i.connect
("mouse_entered",self,'showtooltip',[i])
i.connect
("mouse_exited",self,'hidetooltip')
func _input(event):
if self.is_visible_in_tree() == false:
return
if event.is_action_pressed("LMB"):
var eventpos =
event.global_position
var barpos = $TextureRect.get_global_position()
size =
$TextureRect.get_size()
var target_rect = Rect2(barpos.x, barpos.y, size.x, size.y)
if target_rect.has_point(eventpos):
status = 'clicked'
offset = barpos - eventpos
if event.is_action_released("LMB"):
status
= 'none'
if status == 'clicked' and event.is_class("InputEventMouseMotion"):
status = 'dragging'
#centermap('frostford')
if status == 'dragging':
$TextureRect.set_global_position(event.global_position+offset)