Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | pferft |
Hi everyone,
I have a function instancing a scene with a tween-animation:
func add_that_instanced_scene():
var scene_with_tween = preload("res://general-stuff/TheScene.tscn").instance()
add_child(scene_with_tween)
So there is only a sprite within that instanced scene which is being animated by a tween, starting the animation the moment it’s added. It queue_free()
s itself at the end of the animation.
I’m trying to find a way to „interrupt“ that animation, basically „cancelling“ the instance early under certain circumstances, say on a certain button press for example. Is it possible to „manually queue_free“ an instanced scene while it’s „still running“?
Tôi củng tùng bị như vậy nhưng có cách giải quyết
Kenhdautu | 2021-10-09 21:17
Well, we’re listening ; )
pferft | 2021-10-11 12:55
Edit:
Within the same script that instances the scene, I want it to “self destruct” immediately as soon as, in this case, focus_out()
happens, so it calls the function nowyouseemenot()
within:
func _focus_out():
scene_with_tween.nowyouseemenot()
So within scene_with_tween:
func nowyouseemenot():
print ("begone!")
queue_free()
“begone!” is being printed! But the scene is not being destroyed… I tried visible = false
as well and for the Child-Node (Sprite) $Sprite.queue_free()
… but nothing happens.
What am I missing?
I’d like to add another EDIT:
Pausing appears to fit in this as well. If I pause the game, everything “freezes” properly, except for the instanced scenes - they finish their “cycle” while everything else stands still. So obviously get_tree().paused = true
only applies to the scene containing a script with that line but does not apply to any currently instanced scene.
So the question is, how can a currently running instanced scene be integrated into a “pausing”? Any thought on this is much appreciated!
pferft | 2021-10-14 15:55