Any function under _fixed_process will not be called if you call set_fixed_process(false).
Here's an example showing how it would work:
# NOTE: I added the hashtags so that white space is not lost. For some reason it removes all white space....
var number_of_calls = 0;
#
func _ready():
# This code is called on initialization!
set_fixed_process(true); # Fixed process will now be called
set_process(true) # Process will now be called
#
#
func _fixed_process(delta):
set_fixed_process(false); # Because we set it to false, this function will only be called once!
#
#
func _process(delta):
# This code will be called, regardless of _fixed_process.
number_of_calls += 1;
if (number_of_calls >= 10):
set_process(false); # After ten calls (ten frames, since _process is called every frame), this function will not be called again.
set_fixed_process(true); # Now fixed process will be called once more.
As far as the second problem, there are a few ways to do it.
You could have your brick objects inform the parent node when they are all deleted.
Another way you could do it is using the get_children() function, assuming that every child of that node is a brick.
Here's how I would do it:
extends Node2D;
#
#
var children_count = 0;
var all_children_destroyed = false;
#
func _ready():
child_count = get_child_count().size();
all_children_destroyed = false;
set_fixed_process(true);
#
#
func _fixed_process(delta):
child_count = get_child_count().size();
if (child_count <= 0):
if (all_children_destroyed == false):
all_children_destroyed = true;
print ("Hello! All children destroyed!")
The above code should work, but I haven't tested it. As long as you don't need to know exactly which bricks have been destroyed, and every child of the node is a brick, then this should work fairly well. There are several other ways of handling it, but that's the way I would do it if it was me.
No problem, happy to help! :smile: