Hey guys, I have a scene with Sprites I want to animate with Tweens, because what I'm trying to do is making a sprite appear off-screen,both Sprites slide to the right and the newly spawned sprite stops over where the last one was, then queue_free() the old sprite. Also the Sprites share the same name, except for the number at the end which is a variable called "menu", that way I can call both sprites for a different tween animation, and queue free() the old Sprite without any fear of deleting the wrong sprite.
add_child(img)
img.name = str("menu",previous_menu)
img.position.x = -1024
img.texture = preload("res://sprites/UI/Pause menu/template.png")
img.hframes = 4
img.frame = previous_menu - 1
tween.interpolate_property(img, "position:x", 0,1024,0.7, Tween.EASE_IN_OUT, Tween.TRANS_SINE)
tween.interpolate_property(img, "position:x", -1024, 0,0.7, Tween.EASE_IN_OUT, Tween.TRANS_SINE)
tween.start()
yield($Tween,"tween_all_completed")
After this code, the old Sprite queue_frees() and the variable menu is changed so that the new sprite now bears the name of str("menu",menu), so that I can repeat it
That's what's supposed to happen, but it either queue_free()s the newer sprite, or just crashes because it can't find a node with the name of str("menu",menu).
And some sprites can't spawn because it says "can't add child 'menu3' to 'pausemenu', already has a parent 'pausemenu' " .
Do any of you know why it's not working ? If so, thank you in advance, and sorry for making this such a long post!