本文整理匯總了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)