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


Python Menu.activate方法代码示例

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


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

示例1: main

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import activate [as 别名]
def main():
    # pygame initialization
    pygame.init()
    pygame.mixer.music.load('sounds/menu.mp3')
    pygame.mixer.music.play(-1)

    pygame.display.set_caption('PyFighters')
    pygame.mouse.set_visible(1)
    clock = pygame.time.Clock()
    
    
    
    
    # code for our menu 
    ourMenu = ("Play Online",
               "How to play",
               "Statistics",
               "Exit")
    myMenu = Menu(ourMenu)
    myMenu.drawMenu()
    pygame.display.flip()
    # main loop for event handling and drawing
    while 1:
        clock.tick(60)

    # Handle Input Events
        for event in pygame.event.get():
            myMenu.handleEvent(event)
            # quit the game if escape is pressed
            if event.type == QUIT:
                sys.exit(0)
            elif event.type == Menu.MENUCLICKEDEVENT:    
                if event.text == "Play Online":
                    time.sleep(1)
                    character = CharSelect.charselect()
                    print "Just Waiting..."
                    InitScript.main(socketInit(), character)
                elif event.text == "How to play":
                    Settings.settings()
                elif event.text == "Local Play":
                    Script.main()
                elif event.text == "Exit":
                    sys.exit(0)
            elif event.type == KEYDOWN and event.key == K_ESCAPE:
                myMenu.activate()
                sys.exit(0)

                
        if myMenu.isActive():
            myMenu.drawMenu()
               
        
        pygame.display.flip()
开发者ID:dieg08,项目名称:PyFighters-,代码行数:55,代码来源:Menu.py

示例2: main

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import activate [as 别名]
def main():

	width = 1024
	height = 768
	pygame.display.init
	menu_screen = pygame.display.set_mode((width,height))
	
	# Background
	background = pygame.image.load(os.path.join('', 'images', 'menu_bg.jpg'))
	background = background.convert()
	
	# Cursor
	pygame.mouse.set_visible(False)
	cursor = Cursor(16,16,'images/cursor.png')
	
	#Options in menu
	new_game = Option(200,200,173,89,'images/little.png','images/big.png',new_game_function, 1.42)

	# Menu
	menu = Menu()
	menu.append(new_game)
	
	menu_screen.blit(background, (0, 0))
	cursor.draw(menu_screen)
	menu.draw(menu_screen)
	pygame.display.flip()
	
	# Event loop
	while 1:
		menu.update(cursor)
		for event in pygame.event.get():
			if event.type == QUIT:
				pygame.display.quit
				sys.exit()
			if event.type == KEYDOWN and event.key == K_ESCAPE:
				running = False
				return
			elif event.type == MOUSEMOTION:
				pygame.mouse.get_pos()
				cursor.update()
			elif event.type == MOUSEBUTTONDOWN:
				menu.activate()

		menu_screen.blit(background, (0, 0))
		menu.draw(menu_screen)
		cursor.draw(menu_screen)
		pygame.display.flip()
开发者ID:r0qs,项目名称:chubby,代码行数:49,代码来源:Menu_example.py


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