本文整理汇总了Python中menu.Menu.update_event方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.update_event方法的具体用法?Python Menu.update_event怎么用?Python Menu.update_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menu.Menu
的用法示例。
在下文中一共展示了Menu.update_event方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import update_event [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 update_event [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 update_event [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: LevelsMenu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import update_event [as 别名]
class LevelsMenu(Scene):
def __init__(self, world, initial_option=0):
Scene.__init__(self, world)
items=[]
for name,level in levels.levels:
items.append( (name, runner(self.game, level) ) )
items.append( ("back", self.on_back) )
self.menu = Menu(self, items, initial_option)
def update(self, dt):
self.menu.update()
def update_event(self, event):
self.menu.update_event(event)
# Handlers
def on_back(self):
self.game.quit = True
示例5: Options
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import update_event [as 别名]
class Options(Scene):
def __init__(self, game, last_option_in_main):
Scene.__init__(self, game)
items = [
("Fullscreen", self.game.fullscreen),
("Return", self.on_return)
]
self.menu = Menu(self, items)
self.last_option_in_main = last_option_in_main
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.game.change_scene(MainMenu(self.game, self.last_option_in_main))
def on_return(self):
self.game.change_scene(MainMenu(self.game, self.last_option_in_main))
示例6: MainMenu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import update_event [as 别名]
class MainMenu(Scene):
def init(self):
self.menu = Menu(
font = pygame.font.Font("data/You Are Loved.ttf",40),
font_selected = pygame.font.Font("data/You Are Loved.ttf",60),
opts = ( ("Long Jump",self.long_jump),
("High Jump", self.high_jump),
("High Scores", self.high_scores),
("Credits", self.credits),
("Quit", self.end ) ),
margin = -38,
normal_color = (200,200,200),
normal_border_color = (128,128,128),
selected_color = (255,255,255),
selected_border_color = (50,255,50),
rectangle = Point2(640/2,180)
)
def render(self):
self.game.screen.blit(self.background, (0,0))
self.menu.blit(self.game.screen)
def long_jump( self ):
print "Long Jump selected"
def high_jump( self ):
print "High Jump selected"
def high_scores( self ):
print "high Scores"
def credits( self ):
print "credits"
def update_event(self, evt):
self.menu.update_event(evt)
def update( self, dt ):
pass
示例7: MainMenu
# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import update_event [as 别名]
class MainMenu(Scene):
def __init__(self, world, initial_option=0):
Scene.__init__(self, world)
items = [
("Start new game", self.on_new_game),
("Option", self.on_options),
("Credits", self.on_credits),
("Quit", self.on_quit),
]
self.menu = Menu(self, items, initial_option)
def update(self, dt):
self.menu.update()
def update_event(self, event):
self.menu.update_event(event)
# Handlers
def on_new_game(self):
self.game.change_scene(LevelsMenu(self.game)) #
def on_credits(self):
print "Ha seleccionado 'credits'"
def on_quit(self):
self.game.quit = True
def on_options(self):
from options import Options
self.game.change_scene(Options(self.game, self.menu.index))