本文整理汇总了Python中Scene.Scene.addCharacter方法的典型用法代码示例。如果您正苦于以下问题:Python Scene.addCharacter方法的具体用法?Python Scene.addCharacter怎么用?Python Scene.addCharacter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scene.Scene
的用法示例。
在下文中一共展示了Scene.addCharacter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseScenes
# 需要导入模块: from Scene import Scene [as 别名]
# 或者: from Scene.Scene import addCharacter [as 别名]
def parseScenes(self, storyPath):
dom = xml.dom.minidom.parse(storyPath)
scenes = dom.getElementsByTagName("scene")
for x in scenes:
idscene = x.getAttribute("id")
fondo = x.getElementsByTagName("background")[0]
background = fondo.getAttribute("value")
if len(x.getElementsByTagName("escena_opcion1")) != 0:
escena_opcion1 = x.getElementsByTagName("escena_opcion1")[0].getAttribute("value")
if len(x.getElementsByTagName("escena_opcion2")) != 0:
escena_opcion2 = x.getElementsByTagName("escena_opcion2")[0].getAttribute("value")
if len(x.getElementsByTagName("escena_opcion3")) != 0:
escena_opcion3 = x.getElementsByTagName("escena_opcion3")[0].getAttribute("value")
audio = x.getElementsByTagName("audio")[0].getAttribute("value")
relato = x.getElementsByTagName("relato")[0].getAttribute("value")
opciones = x.getElementsByTagName("option")
parsedOptions = []
for opcion in opciones:
print "parsing option"
optionId = opcion.getAttribute("id")
optionImage = opcion.getElementsByTagName("image")[0].getAttribute("value")
optionPosX = opcion.getElementsByTagName("position")[0].getAttribute("x")
optionPosY = opcion.getElementsByTagName("position")[0].getAttribute("y")
action_verb = opcion.getElementsByTagName("action")[0].getAttribute("verb")
action_resource = opcion.getElementsByTagName("action")[0].getAttribute("resource")
action_x = opcion.getElementsByTagName("action")[0].getAttribute("x")
action_y = opcion.getElementsByTagName("action")[0].getAttribute("y")
action_speed = opcion.getElementsByTagName("action")[0].getAttribute("x")
personajeId = opcion.getElementsByTagName("character")[0].getAttribute("charid")
act = Action(action_verb,action_resource,action_x,action_y,action_speed)
newOpt = Option(optionId,optionImage,optionPosX, optionPosY,act,personajeId)
parsedOptions.append(newOpt)
scene = Scene(self._surf_display, background, escena_opcion1 , escena_opcion2, escena_opcion3, audio, relato, parsedOptions)
characters_xml = x.getElementsByTagName("scene_character")
print "personajes " + str(len(characters_xml))
for charxml in characters_xml:
charid = charxml.getAttribute("id")
print "IdEscena= " + idscene + ". Personaje " + charid
charx = charxml.getElementsByTagName("position")[0].getAttribute("x")
chary = charxml.getElementsByTagName("position")[0].getAttribute("y")
if charid != "guzman":
toAdd = Character(charid, self.character_sprites[charid], charx, chary)
scene.addCharacter(toAdd)
print "[Main] se agrego un personaje a la escena. Personaje " + charid
print "se creo escena con" + str(len(parsedOptions)) + " opciones"
self.scenes[idscene] = scene
self.scenes[self.current_scene].setearDatos(self._surf_display, self.current_scene)
self.imprimir.setearDatos(self._surf_display)