Reputation: 1
I want to call my login screen first so that the uer can have an account before playing the game. However i do not know where to call the login screen without having it interfere with the game:
So essentially every time the game wants to start it obviously opens the login screen first because they are all within the constructor. Anyone know how i can seperate the two different processes?
currently the set up looks like this:
private LoginScreen log;
public FlappyBird() {
//call login screen so that an account can be created
log= new LoginScreen();
log.setVisible(decision);
Timer timer = new Timer(20, this);// used to ensure it repaints throught a schedule timer
render = new FlappyBirdUI1();
jframe = new JFrame();
jframe.add(render);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jframe.setResizable(false);
jframe.setSize(new java.awt.Dimension(WIDTH, HEIGHT));
jframe.setLocationRelativeTo(null);
jframe.addMouseListener(this);
// set game screen to only be visible if the game button on home screen is clicked
jframe.setVisible(true);
//using a rectangle as the "bird"
bird = new Rectangle(WIDTH / 2 - 10, HEIGHT / 2 - 10, 20, 20);
pipes = new ArrayList<Rectangle>();
addpipe(true);
addpipe(true);
addpipe(true);
addpipe(true);
// gsettings.setBounds(0, HEIGHT, 30, 25);
timer.start();
}
Upvotes: 0
Views: 21