I want to write a game that includes these classes:
--Game extends Application(pass its stage to below classes) --StartUp extends Application(has stackpane that added to scene and scene added to stage) --Menu extends Application --GamePly extends Application
I want all of these classes use on stage. First of all, I start startUp class and after a few seconds I want to remove startUp stackpane and change the scene (for example read from an fxml file) but I'm a noob in javafx. Any ideas?
I believe THIS is what you are looking for. A member here posted this code awhile ago. If you want to change the entire scene, add another class that holds a static stage and set it in your main. You can use that to stage.setScene(Menu).
To remove the scene, you could create the scene directly in the stage.setScene(new Scene())
When you set a new scene, the old one will lose it's reference and the garbage collector will take care of it.