Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | GrafEisen |
Hello,
I’m using Godot v3.2 and there are a couple of sprites that I instance with the Sprite.new() function, but when I change their z_index and then I call the change_scene() function they are not removed, the Sprites just stay there over the viewport for the next scene.
Is this expected behaviour? The sprites are removed when I don’t change their z_index.
Is there a better way to get rid of them instead of calling queue_free() before change_scene()?
edit: add script sample
Script running on HSplitContainer to create sprite when TextureButton is clicked:
func _on_TextureButton_pressed():
var spr = Sprite.new()
image = spr
spr.texture = load("res://Images/animation.png")
spr.hframes = 2
spr.frame = 0
spr.z_index = 2
get_tree().get_root().add_child(spr)
spr.scale = Vector2(0.5,0.5)
spr.position = get_tree().get_current_scene().get_node("spriteSpawn").position
Script running on scene root to start next scene:
func _on_BattleButton_pressed():
get_tree().change_scene("res://Scenes/Battle.tscn")
could you provide your script to debug
Thakee Nathees | 2020-04-11 07:42