本文整理汇总了Python中menu.Menu.disable方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.disable方法的具体用法?Python Menu.disable怎么用?Python Menu.disable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.disable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import disable [as 别名]
class Options:
def __init__(self, scene, world):
self.scene = scene
items = [
("Fullscreen", world.fullscreen),
("Return", self.on_return)
]
self.menu = Menu(scene, items, 0)
def update(self, dt):
self.menu.update()
def update_event(self, event):
self.menu.update_event(event)
if event.type == KEYDOWN and event.key == K_ESCAPE:
self.on_return()
def enable( self ):
self.menu.enable()
def disable( self ):
self.menu.disable()
def on_return( self ):
self.scene.mainMenu.enable()
self.scene.mainMenuEnabled = True
self.scene.optionsMenu.disable()
self.scene.optionsMenuEnabled = False
示例2: LevelsMenu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import disable [as 别名]
class LevelsMenu(Scene):
def __init__(self, scene, world, initial_option=0):
self.scene = scene
items=[]
for level in levels.levels:
items.append( (level.name, runner(world, level) ) )
items.append( ("back", self.on_return) )
self.menu = Menu(scene, items, initial_option)
def update(self, dt):
self.menu.update()
def update_event(self, event):
self.menu.update_event(event)
if event.type == KEYDOWN and event.key == K_ESCAPE:
self.on_return()
def enable( self ):
self.menu.enable()
def disable( self ):
self.menu.disable()
# Handlers
def on_return(self):
self.scene.mainMenu.enable()
self.scene.mainMenuEnabled = True
self.scene.levelsMenu.disable()
self.scene.levelsMenuEnabled = False
示例3: __init__
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import disable [as 别名]
class MainMenu:
def __init__(self, scene, world, initial_option=0):
items = [
("Start new game", self.on_new_game),
("Options", self.on_options),
("Credits", self.on_credits),
("Quit", self.on_quit),
]
self.scene = scene
self.menu = Menu(scene, items, initial_option)
def update(self, dt):
self.menu.update()
def update_event(self, event):
self.menu.update_event(event)
if event.type == KEYDOWN and event.key == K_ESCAPE:
self.on_quit()
# Handlers
def on_new_game(self):
self.scene.mainMenu.disable()
self.scene.mainMenuEnabled = False
self.scene.levelsMenu.enable()
self.scene.levelsMenuEnabled = True
def on_credits(self):
import separador
self.scene.game.change_scene(separador.Credits( self.scene.game ) )
def on_quit(self):
self.scene.game.quit = True
def on_options(self):
self.scene.mainMenu.disable()
self.scene.mainMenuEnabled = False
self.scene.optionsMenu.enable()
self.scene.optionsMenuEnabled = True
def enable( self ):
self.menu.enable()
def disable( self ):
self.menu.disable()
示例4: Game
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import disable [as 别名]
class Game(Enableable, Completable, Inputable):
def __init__(self, levels):
super().__init__()
# --- Inits
os.environ["SDL_VIDEO_CENTERED"] = "1"
pygame.mixer.pre_init(44100, 16, 2, 4096)
pygame.init()
pygame.font.init()
pygame.display.set_caption(const.gameName)
self._surface = pygame.display.set_mode((const.screenSize[0] * const.res,
const.screenSize[1] * const.res))
self._clock = pygame.time.Clock()
self._levAttr = levels
self._world = None
self._paused = False
self._menu = Menu(surface=self._surface,
pos=(const.screenSize[0] * const.res / 2 - 50,
const.screenSize[1] * const.res / 2 - 100),
inputStream=self.getInputStream())
self._menu.addItem("resume", (0, 0, 100, 48), MColor((255, 0, 0), (0, 0, 255)),
MText("Resume", (0, 255, 0)), MAction(self._resume))
self._menu.addItem("start", (0, 50, 100, 48), MColor((255, 0, 0), (0, 0, 255)),
MText("Start", (0, 255, 0)), MAction(self.start))
self._menu.addItem("editor", (0, 100, 100, 48), MColor((255, 0, 0), (0, 0, 255)),
MText("Editor", (0, 255, 0)), MAction(self._editor))
self._menu.addItem("exit", (0, 150, 100, 48), MColor((255, 0, 0), (0, 0, 255)),
MText("Exit", (0, 255, 0)), MAction(self.setFinished))
self._input = Input(inputStream=self.getInputStream())
self._input.set(pygame.KEYDOWN, self._menuToggle, pygame.K_m)
self._input.set(pygame.KEYDOWN, self._pause, pygame.K_p)
def start(self):
self.enable()
self._world = World(self._surface, self._levAttr, inputStream=self.getInputStream())
self._world.nextLevel()
self._menu.disable()
def _pause(self):
self._paused = not self._paused
def _resume(self):
if self._world is not None and not self._world.isComplete():
self.enable()
else:
self.start()
self._menu.disable()
def _editor(self):
if self._world:
self._world.level.editor.enabled()
self._menu.disable()
def _menuToggle(self):
self._menu.toggleEnabled()
self.toggleEnabled()
def tick(self):
self.getEvents()
self._input()
if self._menu.enabled():
self._menu.tick()
self._menu.draw()
elif self.enabled:
if self._world.isComplete():
if self._world.isFinished():
self._win()
elif self._world.isLost():
self._gameOver()
else:
if not self._paused:
self._world.tick()
self.clearInputStream()
self._clock.tick(const.FPS)
pygame.display.flip()
def _win(self):
self._endGame("YOU WIN!")
def _gameOver(self):
self._endGame("GAME OVER!")
def _endGame(self, text):
try:
self.__gameOverCount += 1
except AttributeError:
self.__gameOverCount = 1
self.__goText = pygame.font.Font(None, 100).render(text, 1, (255, 0, 0))
self.__gameOverX = int(self._surface.get_width() / 2 - self.__goText.get_width() / 2)
self.__gameOverY = int(self._surface.get_height() / 2 - self.__goText.get_height() / 2)
if self.__gameOverCount < (const.FPS * 5):
self._surface.fill((0, 0, 0))
self._surface.blit(self.__goText, (self.__gameOverX, self.__gameOverY))
else:
#.........这里部分代码省略.........