Godot Version
4.4.dev3
Question
So I have a scene in which I have a bunch of pictures with hierarchy like this -
Pic / Node2d
Picture / Sprite2d
Border / Sprite2d
area / Aread2d
CollisionShape2d
in gdscipt I change Picture’s texture depending on what is the value of one specific variable - 1, 2 or 3 and path to new texture is created using this value converted to string and added to path.
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
clicked_on_input[input_number] = true
elif clicked_on_input[input_number]:
clicked_on_input[input_number] = false
var scene_name = get_tree().current_scene.name
var parts = scene_name.split("_")
get_tree().paused = false
var pgs_key = str(parts[1])+str(input_number)
if Global.default_progress[pgs_key] == 1:
MusicPlayer.get_node("AudioStreamPlayer").stream_paused = true
get_tree().change_scene_to_file("res://scenes/Level_"+str(parts[1])+"_"+str(input_number)+".tscn")
elif Global.default_progress[pgs_key] == 2:
var new_texture = load("res://art/lvl1/picture"+str(parts[1])+"/big"+str(input_number)+".png")
stop_monitoring()
grey_2.texture = new_texture
grey_2.visible = true
big_image.visible = true
big_image.visible = true
await get_tree().process_frame
big_area.monitoring = true
big_area.monitorable = true
Also Border’s texture is also changed from code but with no dynamic path creation - simple _on_mouse_entered/exited functions for Area2d(but I connect this functions from code, so I can use areas in functions)
for area in get_tree().get_nodes_in_group("hover_areas"):
area.mouse_entered.connect(_on_mouse_entered.bind(area))
area.mouse_exited.connect(_on_mouse_exited.bind(area))
where I change it it to one of two preloaded const variables.
func _on_mouse_entered(area: Area2D):
if area.is_in_group("big_area"):
var pic_node = area.get_parent()
var border = pic_node.get_node("border") as Sprite2D
border.texture = BORDER_HOVER_BIG
else:
var pic_node = area.get_parent()
var border = pic_node.get_node("border") as Sprite2D
border.texture = BORDER_HOVER
It works great when I start it from editor, but as soon as I export the project as Windows exe everything breaks. I tried “Export all resources”, even in filters used “res://**” but nothing worked. Maybe someone had same problem and knows what to do?