简体   繁体   中英

Libgdx - How to pass a variable value from one screen to another?

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?

将其传递给另一个屏幕的构造函数

game.setScreen(new PlayScreen(var));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM