当前位置: 首页>>代码示例>>Python>>正文


Python Menu.enable方法代码示例

本文整理汇总了Python中menu.Menu.enable方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.enable方法的具体用法?Python Menu.enable怎么用?Python Menu.enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在menu.Menu的用法示例。


在下文中一共展示了Menu.enable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import enable [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
开发者ID:italomaia,项目名称:turtle-linux,代码行数:31,代码来源:options.py

示例2: LevelsMenu

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import enable [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
开发者ID:italomaia,项目名称:turtle-linux,代码行数:31,代码来源:main_menu.py

示例3: __init__

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import enable [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()
开发者ID:italomaia,项目名称:turtle-linux,代码行数:49,代码来源:main_menu.py

示例4: initGame

# 需要导入模块: from menu import Menu [as 别名]
# 或者: from menu.Menu import enable [as 别名]

#.........这里部分代码省略.........

    # All the balls in the pool
    b_whitey   = BilliardBall([triEdge,0],[0.0,0.0], BBallType.whitey)
    # First row
    striped_9  = BilliardBall([-triEdge,0],[0.0,0.0], BBallType.striped, steel_red)
    # Second row
    solid_7    = BilliardBall([-(triEdge+height),-(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, steel_yellow)
    striped_12 = BilliardBall([-(triEdge+height),(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.striped, steel_red)
    # Third row
    striped_15 = BilliardBall([-(triEdge+2*height),-2*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.striped, steel_red)
    b_black    = BilliardBall([-(triEdge+2*height),0],[0.0,0.0], BBallType.black)
    solid_1    = BilliardBall([-(triEdge+2*height),2*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, steel_orange)
    # Fourth row
    solid_6    = BilliardBall([-(triEdge+3*height),-3*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, steel_yellow)
    striped_10 = BilliardBall([-(triEdge+3*height),-(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.striped, steel_yellow)
    solid_3    = BilliardBall([-(triEdge+3*height),(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, black)
    striped_14 = BilliardBall([-(triEdge+3*height),3*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.striped, steel_red)
    # Fifth row
    striped_11 = BilliardBall([-(triEdge+4*height),-4*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.striped, steel_orange)
    solid_2    = BilliardBall([-(triEdge+4*height),-2*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, steel_green)
    striped_13 = BilliardBall([-(triEdge+4*height),0],[0.0,0.0], BBallType.striped, steel_red)
    solid_4    = BilliardBall([-(triEdge+4*height),2*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, steel_yellow)
    solid_5    = BilliardBall([-(triEdge+4*height),4*(corrector+BALL_RADIUS)],[0.0,0.0], BBallType.solid, steel_yellow)

    b_balls = [striped_9, striped_10, striped_11, striped_12, striped_13, striped_14, striped_15, solid_1, solid_2, solid_3, solid_4, solid_5, solid_6, solid_7, b_whitey, b_black]

    # Creates and activate the loader
    loader = primitives.Loader([200.0,200.0])
    loader.activate()
    force_line = ForceLine(b_whitey)

    shoot_mode = False

    prev_num_hands = 0

    #Tutorial screens
    tutorial01_screen = Screen("./Screenshots/tutorial01.png")#, [tutorial_to_02_button])
    tutorial02_screen = Screen("./Screenshots/tutorial02.png")#, [tutorial_to_03_button])
    tutorial03_screen = Screen("./Screenshots/tutorial03.png")#, [tutorial_to_04_button])
    tutorial04_screen = Screen("./Screenshots/tutorial04.png")#, [tutorial_to_05_button])
    tutorial05_screen = Screen("./Screenshots/tutorial05.png")#, [tutorial_to_06_button])
    tutorial06_screen = Screen("./Screenshots/tutorial06.png")#, [tutorial_to_07_button])
    tutorial07_screen = Screen("./Screenshots/tutorial07.png")#, [tutorial_to_08_button])
    tutorial08_screen = Screen("./Screenshots/tutorial08.png")#, [tutorial_start_button])

    #Tutorial buttons
    tutorial_to_02_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial02_screen)
    tutorial_to_03_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial03_screen)
    tutorial_to_04_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial04_screen)
    tutorial_to_05_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial05_screen)
    tutorial_to_06_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial06_screen)
    tutorial_to_07_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial07_screen)
    tutorial_to_08_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], tutorial08_screen)
    tutorial_start_button = ActionButton([[1024-661,800-749],[1024-363,800-451]], disableTutorial)

    # Bind tutorial buttons to tutorial screens
    tutorial01_screen.buttons = [tutorial_to_02_button]
    tutorial02_screen.buttons = [tutorial_to_03_button]
    tutorial03_screen.buttons = [tutorial_to_04_button]
    tutorial04_screen.buttons = [tutorial_to_05_button]
    tutorial05_screen.buttons = [tutorial_to_06_button]
    tutorial06_screen.buttons = [tutorial_to_07_button]
    tutorial07_screen.buttons = [tutorial_to_08_button]
    tutorial08_screen.buttons = [tutorial_start_button]

    #Menu screens
    menu_start_screen = Screen("./Screenshots/menu01_start.png")#, [to_opt_button, quit_menu_button, quit_game_button])
    menu_general_opt_screen = Screen("./Screenshots/menu02_options.png")#, [to_ball_opt_button, to_hand_opt_button, back_to_first_button])
    menu_ball_opt_screen = Screen("./Screenshots/menu03_balls.png")#, [red_ball_button, orange_ball_button, back_to_opt_button])
    menu_hand_opt_screen = Screen("./Screenshots/menu04_hands.png")#, [red_hand_button, green_hand_button, back_to_opt_button])

    #First screen buttons
    menu_to_opt_button = NavigationalButton([[1024-977,800-475],[1024-559,800-57]], menu_general_opt_screen)
    menu_quit_menu_button = ActionButton([[1024-465,800-475],[1024-47,800-57]], disableMenu)
    menu_quit_game_button = ActionButton([[1024-661,800-749],[1024-363,800-451]], quitGame)

    #General options screen buttons
    menu_to_ball_opt_button = NavigationalButton([[1024-977,800-475],[1024-559,800-57]], menu_ball_opt_screen)
    menu_to_hand_opt_button = NavigationalButton([[1024-465,800-475],[1024-47,800-57]], menu_hand_opt_screen)
    menu_back_to_first_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], menu_start_screen)

    #Ball options screen buttons
    menu_orange_ball_button = ActionButton([[1024-977,800-475],[1024-559,800-57]], setBallsToOrangeYellow)
    menu_red_ball_button = ActionButton([[1024-465,800-475],[1024-47,800-57]], setBallsToRedGreen)
    menu_back_to_opt_button = NavigationalButton([[1024-661,800-749],[1024-363,800-451]], menu_general_opt_screen)

    #Hand options screen buttons
    menu_red_hand_button = ActionButton([[1024-977,800-475],[1024-559,800-57]], setHandToRed)
    menu_green_hand_button = ActionButton([[1024-465,800-475],[1024-47,800-57]], setHandToGreen)

    # Bind buttons to screens
    menu_start_screen.buttons = [menu_to_opt_button, menu_quit_menu_button, menu_quit_game_button]
    menu_general_opt_screen.buttons = [menu_to_ball_opt_button, menu_to_hand_opt_button, menu_back_to_first_button]
    menu_ball_opt_screen.buttons = [menu_red_ball_button, menu_orange_ball_button, menu_back_to_opt_button]
    menu_hand_opt_screen.buttons = [menu_red_hand_button, menu_green_hand_button, menu_back_to_opt_button]

    tutorial = Menu(tutorial01_screen,loader)
    tutorial.enable()

    menu = Menu(menu_start_screen,loader)
开发者ID:agarciamontoro,项目名称:leap-motion-project,代码行数:104,代码来源:game.py


注:本文中的menu.Menu.enable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。