WIP: Base for Controller with switchable scene for everyone to work on it. #28

Closed
tonitch wants to merge 1 commits from GUI_Base into master
4 changed files with 43 additions and 9 deletions

View File

@ -4,25 +4,33 @@
package school_project;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import school_project.States.GameMain;
import school_project.States.GameMenu;
import school_project.States.GameState;
public class Controller extends Application {
public final static String PROGRAM_NAME = "Road to Master";
private Parent root;
private GameState gameState = GameState.InMenu;
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("test");
Button btn = new Button("test");
btn.setOnAction(event -> System.out.println("hey"));
primaryStage.setTitle(PROGRAM_NAME);
Group root = new Group();
root.getChildren().add(btn);
switch (gameState){
case InMenu:
root = new GameMenu();
break;
case InGame:
root = new GameMain();
break;
}
Scene scene = new Scene(root, 300,300);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}

View File

@ -0,0 +1,8 @@
package school_project.States;
import javafx.scene.layout.BorderPane;
public class GameMain extends BorderPane {
}

View File

@ -0,0 +1,12 @@
package school_project.States;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Text;
public class GameMenu extends GridPane {
Text txt = new Text("Here come the menu");
public GameMenu() {
super();
add(txt, 0, 0);
}
}

View File

@ -0,0 +1,6 @@
package school_project.States;
public enum GameState {
InMenu,
InGame
}