读取 pygame 显示器的当前标志(全屏等)
Reading pygame display's current flags (FULLSCREEN etc.)
是否可以读取显示已给出的当前标志?所以当有人打电话给 pygame.display.set_mode(resolution, FLAGS)
时,我很乐意在之后阅读它们。
例如,我想要一个 is_fullscreen()
函数。
您正在寻找 pygame.Surface.get_flags
方法。
Returns a set of current Surface features. Each feature is a bit in the flags bitmask.
pygame.display.set_mode
returns一个pygame.Surface。所以调用显示的 get_flags 方法并使用特定标志按位与它。
def is_fullscreen(display):
return bool(display.get_flags() & pygame.FULLSCREEN)
是否可以读取显示已给出的当前标志?所以当有人打电话给 pygame.display.set_mode(resolution, FLAGS)
时,我很乐意在之后阅读它们。
例如,我想要一个 is_fullscreen()
函数。
您正在寻找 pygame.Surface.get_flags
方法。
Returns a set of current Surface features. Each feature is a bit in the flags bitmask.
pygame.display.set_mode
returns一个pygame.Surface。所以调用显示的 get_flags 方法并使用特定标志按位与它。
def is_fullscreen(display):
return bool(display.get_flags() & pygame.FULLSCREEN)