I created a simple game in LibGDX that has multiple screens. I want to restart a certain screen after touching a restart button but I\'m not sure how to do that. I made some res
show() is called automatically when the screen is first shown.
The init() method is one you create yourself. You can call it whatever you want. You should not load all the assets in init() just set everything up, score = 0, player.setPosition(0,0) etc.
So when you first call init() you set all variables. When you call init() again you set them again. (reset)
Efter edit of question:
In the methods called from GameInit() you load files that are already loaded and add actors to stages where those actors are already there and therefore now overlapping. You also add actions and create objects already created.
All GameInit() should do is set values for those already created objects. So basically:
private void GameInit(){
AntAnimate.get(1).setPosition(x,y);
AntAnimate.get(2).setPosition(x,y);
AntAnimate.get(3).setPosition(x,y);
levelOneImage.setPosition(0,0);
scoreInt = 0;
coinInt = 0;
}
Loading and creation of objects should not be done more than once. Try just adding my GameInit() method, call it GameReset() and call it from your reset button.