本文整理汇总了Python中Physics.addChild方法的典型用法代码示例。如果您正苦于以下问题:Python Physics.addChild方法的具体用法?Python Physics.addChild怎么用?Python Physics.addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics.addChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SpaceDominationMain
# 需要导入模块: import Physics [as 别名]
# 或者: from Physics import addChild [as 别名]
#.........这里部分代码省略.........
if self.shipList[spawn.id].hard_points:
tempShip = StationShip(spawn.x, spawn.y, proto = self.shipList[spawn.id], context = self)
for pt in self.shipList[spawn.id].hard_points:
hpt = AIShip(spawn.x + pt['x'], spawn.y + pt['y'], spawn.r + pt['rot'], proto = self.shipList[pt['id']], parent = tempShip, context = self)
hpt.team = tempShip.team
tempShip.hard_points.append(hpt)
else:
tempShip = AIShip(spawn.x, spawn.y, spawn.r, proto = self.shipList[spawn.id], context = self)
tempShip.team = spawn.team
self.linkTriggers(spawn, tempShip)
elif spawn.id == -1:
if spawn.hard_points:
tempShip = StationShip(spawn.x, spawn.y, spawn.r, proto = spawn.proto, context = self)
for pt in spawn.hard_points:
if pt.id >= 0 and pt.id < len(self.shipList):
hpt = AIShip(spawn.x + pt.x, spawn.y + pt.y, spawn.r + pt.r, proto = self.shipList[pt.id], parent = tempShip, context = self)
hpt.team = tempShip.team
tempShip.hard_points.append(hpt)
else:
tempShip = AIShip(spawn.x, spawn.y, spawn.r, proto = spawn.proto, context = self)
tempShip.team = spawn.team
self.linkTriggers(spawn, tempShip)
if spawn.squad:
spawn.squad.append(tempShip)
tempShip.squad = spawn.squad
self.shipSpriteGroup.add(tempShip)
self.foregroundSpriteGroup.add(tempShip.hard_points)
self.physics.addChild(tempShip)
tempShip.set_position(spawn.x, spawn.y)
tempShip.set_rotation(spawn.r)
tempShip.tag = spawn.tag
tempShip.spawn = spawn
tempShip.apply_upgrade(spawn.upgrade)
# first, set up any auto-backgrounds
if mission.background_style == 'tiled':
# set up a tiled background using background_file and width, height
x = 0
y = 0
mission.background_image, dfrect = Utils.load_image(mission.background_file)
#convert bglist to backgrounds
for bg in mission.backgroundList:
tempBg = pygame.sprite.Sprite()
tempBg.image, tempBg.rect = Utils.load_image(bg.filename)
tempBg.rect.topleft = (bg.x, bg.y)
self.backgroundSpriteGroup.add(tempBg)
self.updateTriggers()
def endMission(self):
self.gameState = self.GAMESTATE_GAMEOVER
#self.menuManager.main_menu_click()
# put together the results for the mission results menu
destroyedSpawns = self.currentMission.get_losses(self.destroyedSpriteGroup)
destroyedLabels = {'ally': {}, 'enemy': {}}