I solved this problem, I forgot that the input does not work on top of the gui
i am trying to connect these signals but they are not being called
this script is the parent script of another script that connected to the node
extends Area2D
var is_drag := false
var mouse_entered := false
func _ready() -> void:
utils.assert(connect('mouse_entered', self, '_on_mouse_entered') == OK)
utils.assert(connect('mouse_exited', self, '_on_mouse_exited') == OK)
func _on_mouse_entered() -> void:
mouse_entered = true
func _on_mouse_exited() -> void:
mouse_entered = false
func _unhandled_input(event):
if event is InputEventMouseButton and mouse_entered:
if event.is_pressed():
is_drag = true
raise()
else:
is_drag = false
get_tree().set_input_as_handled()
func _physic_process(_delta: float) -> void:
if is_drag:
position = get_global_mouse_position()
child script:
extends 'res://parent_scripts/equipment.gd'
var physical_defence := [0, 1]
var magic_defence := [0, 1]
func init(init_name, init_min_physical_defence, init_max_physical_defence, init_min_magic_defence, init_max_magic_defence) -> void:
name = init_name
physical_defence[0] = init_min_physical_defence
physical_defence[1] = init_max_physical_defence
magic_defence[0] = init_min_magic_defence
magic_defence[1] = init_max_magic_defence
$Sprite.set_texture(load('res://sprites/%s.png' % name))
$CollisionShape2D.set_shape(CircleShape2D.new())
$CollisionShape2D.shape.set_radius($Sprite.texture.get_width() / 2)
func get_passing_damage(input_physical_damage: int, input_magic_damage: int) -> Array:
var physical_passing_damage := input_physical_damage - global.get_random_int(physical_defence[0], physical_defence[1]) as int
if physical_passing_damage < 0:
physical_passing_damage = 0
var magic_passing_damage := input_magic_damage - global.get_random_int(magic_defence[0], magic_defence[1]) as int
if magic_passing_damage < 0:
magic_passing_damage = 0
return [physical_passing_damage, magic_passing_damage]
func _physics_process(delta):
._physic_process(delta)
through this script, the script connects to the node
extends Panel
var item
func _ready() -> void:
var child := load("res://objects/item.tscn").instance() as Object
child.set_script(load("res://scripts/shields.gd"))
child.init('shield', 2, 5, 0, 0)
child.position = Vector2(50, 50)
add_child(child)