Reputation: 510
This my way to deal with screens
I have class GameMain extends Game
I created instance of it in each screen so I can use something like this gameMain.setScreen()
My question is How to move properly from one screen to another ?
I have the following :
In GameMain I setScreen(new SplashScreen(this))
In splash screen I setScreen(new MenuScreen(this))
in hide()
of splash I call its dispose()
and so on as when player click play button in menu screen I setScreen()
to new playScreen I also call dispose()
in hide()
and when he returns to Menu I setScreen(new Menu)
Is what I am doing wrong ?
Upvotes: 0
Views: 36
Reputation: 569
What I normally do is I have in my main Game class a function for example called setPlayScreen(), and in that method I do something like:
public void setPlayScreen(params){
//Do something with params
setScreen(new PlayScreen())
}
If you have your dispose() inside your screens hide() method you shouldn't have any problems.
Upvotes: 1