本文整理汇总了Python中gui.Gui.setupMenu方法的典型用法代码示例。如果您正苦于以下问题:Python Gui.setupMenu方法的具体用法?Python Gui.setupMenu怎么用?Python Gui.setupMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gui.Gui
的用法示例。
在下文中一共展示了Gui.setupMenu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gui import Gui [as 别名]
# 或者: from gui.Gui import setupMenu [as 别名]
class Game:
world = 0
camera = 0
background = 0
gui = 0
mainbody = 0
gameResult = 0
currentLevel = 1
def __init__(self):
self.world = World()
self.camera = Camera()
def setupMenu(self):
self.gui = Gui()
self.gui.setupMenu(self)
self.setupBackground('levels/menu.xml')
def setupLevel(self, *largs):
print "CURRENT LEVEL %d"%self.currentLevel
levelstring = 'levels/level'
levelstring +=`self.currentLevel`.zfill(2)
levelstring +='.xml'
print levelstring
if os.path.isfile(levelstring):
self.camera.scale = 1.1
self.gui.messaging.reset()
self.gameResult = 0
self.setupWorld(levelstring)
self.setupBackground(levelstring)
self.setupShip(levelstring)
self.gui.messaging.displayText('Level %d'%(self.currentLevel),60)
else:
self.gui.messaging.reset()
self.mainbody = 0
self.setupWorld('levels/endgame.xml')
self.setupBackground('levels/endgame.xml')
self.gui.messaging.displayText('Congratulations ! !',-1)
def checkVictoryCondition(self):
if self.mainbody.isStable() == 0:
return 0
landingzone = self.world.getLandingzone()
if landingzone.checkBody(self.mainbody) == 1:
return 1
else :
return -1
def gameIsRunning(self):
if self.mainbody != 0 and self.gameResult == 0:
return 1
def setupBackground(self,filename):
self.background = Background()
domLevel = parse(filename)
backgroundNodes = domLevel.getElementsByTagName("background")
backgroundNode = backgroundNodes[0]
for node in backgroundNode.childNodes:
if node.localName == "layer":
texturename = 0
tilesizex = 0
tilesizey = 0
positionx = 0
positiony = 0
layersizex = 0
layersizey = 0
offsetx = 0
offsety = 0
for childnode in node.childNodes:
if childnode.localName == "texture":
texturename = childnode.getAttribute('value')
if childnode.localName == "tilesize":
values = childnode.getAttribute('value').split(',')
if values[0] == 'screenw':
tilesizex = Config.getint('graphics', 'width')
else:
tilesizex = float(values[0])
if values[1] == 'screenh':
tilesizey = Config.getint('graphics', 'height')
else:
tilesizey = float(values[1])
if childnode.localName == "position":
values = childnode.getAttribute('value').split(',')
if values[0] == 'screenw':
positionx = Config.getint('graphics', 'width')
else:
positionx = float(values[0])
if values[1] == 'screenh':
positiony = Config.getint('graphics', 'height')
else:
positiony = float(values[1])
if childnode.localName == "offset":
values = childnode.getAttribute('value').split(',')
if values[0] == 'screenw':
offsetx = Config.getint('graphics', 'width')
else:
offsetx = float(values[0])
if values[1] == 'screenh':
offsety = Config.getint('graphics', 'height')
else:
offsety = float(values[1])
if childnode.localName == "layersize":
values = childnode.getAttribute('value').split(',')
#.........这里部分代码省略.........