Is there a way to stretch the whole display image to fit a given resolution?

余生长醉 提交于 2019-12-13 19:05:55

问题


I've been using pygame to make a game recently, and have ran into a little problem...

Basically, I would like to be able to stretch the whole image that is on the screen (all the things that I have blitted to it) into the resolution which the user has resized the window to. I've searched a lot on the documentation for pygame and on stack overflow and I can't seem to find an answer... Is it even possible? The source code for my game is pretty big atm, if anyone needs it I'll be willing to post it. Sorry if I made my question a little unclear :)


回答1:


Blit everything to a separate surface (not directly to the screen), let's call it main_surface. Then blit the main_surface to the screen. Call pygame.transform.scale(main_surface, (width, height) with the new width and height that you get from the VIDEORESIZE event to scale the main_surface and everything in it to the new window dimensions.



来源:https://stackoverflow.com/questions/18835940/is-there-a-way-to-stretch-the-whole-display-image-to-fit-a-given-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!