Godot Version
4.2.2
Question
My question is quite complex, well, it is for me so I am hoping that seeing a code snippet from one of the functions and screenshot that things will become immediately apparent to someone more advanced than me (not very ). My mind is split a hundred different ways with things I need to fix, so, my mind cannot see what the problem might be. The code is following a tutorial that for some reason or another would not work the way it was, or, could not follow, so, was modified by me sometimes quite heavily.
The screenshot is this:
Now, the menu has been made to deliberately appear for testing purposes. Everything up to this point is fine. I can play the game albeit a bit hard with the menu , but, works. The Level Select Button really doesnāt do anything at this point. The quit button works fine, however, it is the Retry button doesnāt not work at all. I have marked out in the code with comments which code does NOT work.
this is the code:
#----------------------------------------------------------
# -- btn functions on user interface --
#----------------------------------------------------------
func retry_btn():
print("game manager - retry button");
game_over_menu.set_control(false); #does not work
await ui_fade.fade_to_black();
#do restart/retry we need to:
#1. unload the level
#2. reload the level with a variables stored in the File.data script
#first: is easy just queue.free() level1 from memory
level1.queue_free();
#second: Next reload same level
#what a novel idea
File.data.retry();
# turn 'resource' into a node that can be loaded into Godot
# aha now we change this and add the level we need
# level1 = load("res://Level/level_1-1.tscn").instantiate();
level1 = load("res://Level/level_"+ str(File.data.world) + "-" +str(File.data.level) + ".tscn").instantiate();
add_child(level1);
spawn_player();
#if I do this here: player can't be re-enabled below
player.set_enabled(false); # turn off player control so roger can't move
jolly_roger.roger_revive();# revive character - set w/ 3 lives (no it doesn't)
#added
ui.collect_coin(); #supposed to set UI coins, does not
ui.update_skulls(); #supposed to set UI lives, does not
await ui_fade.fade_to_clear();
#turn controls back on doesn not work
player.set_enabled(true);
#pass
So when I hit the retry button is hit it loads the level as specified, but, the UI/HUD does not update, the menu does not disappear and player movement is completely disabled, it doesnāt get re-enabled as per the code although the fades do work.
And should I hit the Retry button again the game crashes with this error:
So, Iām lost. Iām almost sure that the problem come with the loading of the level1, but, I do not know enough about this sort of thing.
Any help, any help at all would be greatly appreciated!
Regards.