I have Scene1 → Scene2 → Scene3 for android. Scene2 and Scene3 have function below:
func _notification(what):
if what == NOTIFICATION_WM_GO_BACK_REQUEST:
_on_back_scn_btn_pressed()
The problem is when i press back button on Scene3, Scene2’s above method is also triggered which causes Scene3 to go to Scene1 bypassing Scene2 (which is absurd!!) How can i prevent unnecessary trigger? I dont want to create variables just to handle this situation, it seems anti pattern.
If Scene2 is being triggered then it means that the node is in the scene tree. If that’s intended then you’ll need to keep track of the current scene stack in code. If that’s not intended then you’ll need to, at least, remove Scene2 from the scene tree.
No it is not, for my every scene, i use node.free(). I checked remote view and that scene was not in tree. They are major scenes, i load them everytime i use back pressed and free them when i am done.