问题
I'm creating a game for Android phones and I need a player number from screen where I select it to another screen where I use it for something else. On screen where I select specific number, method for returning number of players works perfectly but when I use that method on another screen it returns zero. I select number (picture for specific number) from ScrollPane. When I change screen I clear screen and draw new one as usual. So my question is how can I save that value and return it even when screen has changed?
回答1:
Pass it through the constructor of the other screen
game.setScreen(new PlayScreen(var));
来源:https://stackoverflow.com/questions/42176696/libgdx-how-to-pass-a-variable-value-from-one-screen-to-another