本文整理汇总了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()
示例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()