Creating multiple screens in pygame

2019-02-26 20:35发布

Is there any way way to create multiple screens in Pygame without redrawing to the screen every time. For example, if we want to create a splash screen, then a main menu with buttons. On clicking the 'Start Game' button, it would go to a new screen which is the actual game. What I mean is anything similar to the 'Form' on Visual Studio or the Activites on Android.

标签: python pygame
2条回答
你好瞎i
2楼-- · 2019-02-26 20:52

Depends on what you mean.

If you mean making multiple windows at the same time, no, you can't do that--it's a limitation of SDL (although you CAN fake it by using multiprocessing (not multithreading)).

If you mean changing one screen around, yes, you can do that, with multiple calls to pygame.display.set_mode(...). You can change the resolution, arguments, etc. If you're doing OpenGL stuff, that will remake the context too.

If you just mean drawing different things to the same window, of course! That's sorta the point of PyGame.

Other than that, you'll have to clarify.

查看更多
可以哭但决不认输i
3楼-- · 2019-02-26 20:54

Just fill the screen with white and then draw the second screen onto the main screen. Then when you need the other screen, just refill the screen with black and then continue. It would help if both of your screens a function and you used a key like tab to "switch" between screens.

查看更多
登录 后发表回答