本文整理汇总了Java中com.badlogic.gdx.utils.XmlReader.Element.getChildByName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getChildByName方法的具体用法?Java Element.getChildByName怎么用?Java Element.getChildByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.XmlReader.Element
的用法示例。
在下文中一共展示了Element.getChildByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadAtlas
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
/** May return null. */
protected FileHandle loadAtlas(Element root, FileHandle tmxFile) throws IOException {
Element e = root.getChildByName("properties");
if (e != null) {
for (Element property : e.getChildrenByName("property")) {
String name = property.getAttribute("name", null);
String value = property.getAttribute("value", null);
if (name.equals("atlas")) {
if (value == null) {
value = property.getText();
}
if (value == null || value.length() == 0) {
// keep trying until there are no more atlas properties
continue;
}
return Gdx.files.internal(value);
}
}
}
FileHandle atlasFile = tmxFile.sibling(tmxFile.nameWithoutExtension() + ".atlas");
return atlasFile.exists() ? atlasFile : null;
}
示例2: getDependencies
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, TrapParameter parameter) {
XmlReader xmlReader = new XmlReader();
try {
Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
Element root = xmlReader.parse(file);
LoaderUtil.handleImports(this, parameter, returnValue, file, root);
Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
if (soundsElement != null) {
addSoundDependency(soundsElement, TrapType.XML_DISARMED, returnValue);
addSoundDependency(soundsElement, TrapType.XML_SPRUNG, returnValue);
}
if (returnValue.size > 0) {
return returnValue;
}
} catch (IOException e) {
throw new GdxRuntimeException(e);
}
return null;
}
示例3: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXML(Element root) throws IOException {
super.loadFromXML(root);
story = new Array<QuestState>();
storyTimes = new Array<GameCalendarDate>();
if (isFinished()) {
finishedQuests.add(this);
} else if (isStarted()) {
activeQuests.add(this);
}
variables = new Variables();
variables.loadFromXML(root);
Element storyElement = root.getChildByName(XML_STORY);
if (storyElement != null) {
for (int i = 0; i < storyElement.getChildCount(); ++i) {
Element storyStateElement = storyElement.getChild(i);
story.add(getStateForId(storyStateElement.getAttribute(XMLUtil.XML_ATTRIBUTE_ID)));
GameCalendarDate date = new GameCalendarDate(GameState.getCurrentGameDate().getCalendar());
date.readFromXML(storyStateElement.getChildByName(XML_TIME));
storyTimes.add(date);
}
}
}
示例4: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXML(Element root) throws IOException {
XMLUtil.readPrimitiveMembers(this, root);
Element dateElement = root.getChildByName(XMLUtil.XML_END_DATE);
if (dateElement != null) {
dateToEnd = new GameCalendarDate(GameState.getCurrentGameDate());
dateToEnd.readFromXML(dateElement);
}
Element paramsElement = root.getChildByName(XMLUtil.XML_PARAMETERS);
parameters = new Array<EffectParameter>();
for (int i = 0; i < paramsElement.getChildCount(); ++i) {
parameters.add(new EffectParameter(paramsElement.getChild(i)));
}
paramsElement = root.getChildByName(XML_DESCRIPTION_PARAMETERS);
descriptionParameters= new Object[paramsElement.getChildCount()];
for (int i = 0; i < paramsElement.getChildCount(); ++i) {
// this will convert everything into strings, but this should be okay as long
// as no special formatting is used in the message format of the description
descriptionParameters[i] = paramsElement.getChild(i).getText();
}
}
示例5: getDottedValue
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public static String getDottedValue(Element element, String fieldPath) {
if (fieldPath.contains(".")) {
String childElementName = fieldPath.substring(0, fieldPath.indexOf("."));
String childNames[] = getLowerAndCapitalStart(childElementName);
Element child = element.getChildByName(childNames[0]);
if (child == null) {
element.getChildByName(childNames[1]);
}
if (child != null) {
return getDottedValue(child, fieldPath.substring(fieldPath.indexOf(".") + 1, fieldPath.length()));
} else {
return null;
}
} else {
String attributeName[] = getLowerAndCapitalStart(fieldPath);
String xmlValue = element.get(attributeName[0], null);
if (xmlValue == null) {
xmlValue = element.get(attributeName[1], null);
}
return xmlValue;
}
}
示例6: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public void loadFromXML(Element root) throws IOException {
XMLUtil.readPrimitiveMembers(this, root);
Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
if (soundsElement != null) {
onStartSounds = XMLUtil.readSounds(soundsElement, ProjectileType.XML_ON_START);
onHitSounds = XMLUtil.readSounds(soundsElement, ProjectileType.XML_ON_HIT);
duringSounds = XMLUtil.readSounds(soundsElement, ProjectileType.XML_DURING);
} else {
onStartSounds = new Array<Sound>();
onHitSounds = new Array<Sound>();
duringSounds = new Array<Sound>();
}
try {
if (s_animationFile != null && s_animationInfoFile != null) {
s_animationFile = Configuration.addModulePath(s_animationFile);
s_animationInfoFile = Configuration.addModulePath(s_animationInfoFile);
animations = new OrientationAnimationMap(s_animationFile,
Gdx.files.internal(s_animationInfoFile));
}
} catch (IOException e) {
throw new GdxRuntimeException("Problem loading animation for projectile type "+getId(),e);
}
}
示例7: addTemplate
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public void addTemplate(String template) {
XmlReader xml = types.getXmlReader();
Element root = null;
try {
root = xml.parse(Gdx.files.internal(template_folder+template));
} catch (IOException e) {
e.printStackTrace();
}
if(root == null) {
throw new GdxRuntimeException("Unable to parse template ["+template+"]. Make sure it exists or that you have the correct template folder set.");
}
Element object = root.getChildByName("object");
if(object!=null) {
String parent_type = object.getAttribute("type");
TiledTemplate t = new TiledTemplate(template,object.getAttribute("name"), types.get(parent_type));
t.setWidth(object.getInt("width", 0));
t.setHeight(object.getInt("height",0));
t.setGid(object.getAttribute("gid",null));
t.setRotation(object.getFloat("rotation",0f));
if(object.hasChild("properties")) {
Array<Element> properties = object.getChildByName("properties").getChildrenByName("property");
for (Element property : properties) {
t.getTemplateType().addProperty(property.get("name"), property.hasAttribute("type")?property.get("type"):TypeProperty.STRING, property.get("value"));
}
}
Gdx.app.log(getClass().getName(), "template ["+template+"] has been added");
templates.put(template, t);
}
}
示例8: readQuestsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private static void readQuestsFromXML(Element root) throws IOException {
Element questsElement = root.getChildByName(GameSaver.XML_QUESTS);
for (int i = 0; i < questsElement.getChildCount(); ++i) {
Element questElement = questsElement.getChild(i);
Quest quest = Quest.getQuest(questElement.getName());
quest.loadFromXML(questElement);
}
}
示例9: StoryPage
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public StoryPage(Element screenElement) {
XMLUtil.readPrimitiveMembers(this, screenElement);
if (image != null) {
image = Configuration.addModulePath(image);
}
Element conditionElement = screenElement.getChildByName(XMLUtil.XML_CONDITION);
if (conditionElement != null && conditionElement.getChildCount() == 1) {
condition = Condition.getCondition(conditionElement.getChild(0));
}
}
示例10: addSoundDependency
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private void addSoundDependency(Element soundsElement, String soundElementName, Array<AssetDescriptor> dependencies) {
Element soundElement = soundsElement.getChildByName(soundElementName);
if (soundElement != null && soundElement.getChildCount() > 0) {
for (int i = 0; i < soundElement.getChildCount(); ++i) {
dependencies.add(new AssetDescriptor<Sound>(Configuration.addModulePath(soundElement.getChild(i).get(XMLUtil.XML_FILENAME)), Sound.class));
}
}
}
示例11: loadFromXMLNoInit
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXMLNoInit(FileHandle file) throws IOException {
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(file);
XMLUtil.handleImports(this, file, root);
XMLUtil.readPrimitiveMembers(this, root);
Element racesElement = root.getChildByName(XML_RACES);
if (racesElement != null) {
String[] races = racesElement.getText().split(",");
for (String race : races) {
this.races.add(Race.getRace(race.trim()));
}
}
Element gendersElement = root.getChildByName(XML_GENDERS);
if (gendersElement != null) {
String[] genders = gendersElement.getText().split(",");
for (String gender: genders) {
gender = gender.trim();
for (Gender g : Gender.values()) {
if (!this.genders.contains(g, true)
&& g.name().toLowerCase(Locale.ENGLISH)
.equals(gender)) {
this.genders.add(g);
}
}
}
}
}
示例12: loadFromXMLNoInit
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXMLNoInit(FileHandle file) throws IOException {
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(file);
XMLUtil.handleImports(this, file, root);
XMLUtil.readPrimitiveMembers(this, root);
Element indicatorElement = root.getChildByName(XML_INDICATOR);
if (indicatorElement != null) {
indicator = new ParticleEffectDescriptor(indicatorElement);
indicatorNoDelay = new ParticleEffectDescriptor(indicator.getEffectId(), 0, indicator.getXOffset(), indicator.getYOffset());
}
onHitScript = XMLUtil.readScript(id, root.getChildByName(XML_ON_HIT), onHitScript);
durationScript = XMLUtil.readScript(id, root.getChildByName(XML_DURATION), durationScript);
onEndScript = XMLUtil.readScript(id, root.getChildByName(XML_ON_END), onEndScript);
persistentScript = XMLUtil.readScript(id, root.getChildByName(XML_PERSISTENT), persistentScript);
conditionScript = XMLUtil.readScript(id, root.getChildByName(XML_CONDITION), conditionScript);
Element descriptionElement = root.getChildByName(XML_DESCRIPTION);
if (descriptionElement != null) {
descriptionParamsScript = XMLUtil.readScript(id, descriptionElement.getChildByName(XML_EXTRA_PARAMETERS), descriptionParamsScript);
}
Element parametersElement = root.getChildByName(XMLUtil.XML_PARAMETERS);
if (parametersElement != null) {
for (int i = 0; i < parametersElement.getChildCount(); ++i) {
Element parameterElement = parametersElement.getChild(i);
parameters.add(EffectParameterDefinition.readFromXML(parameterElement));
}
}
Element typesElement = root.getChildByName(XML_TYPE);
if (typesElement != null && !typesElement.getText().isEmpty()) {
String[] types = typesElement.getText().split(",");
for (String type : types) {
this.types.add(type.trim().toUpperCase(Locale.ENGLISH));
}
}
}
示例13: readFactionsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private static void readFactionsFromXML(Element root) throws IOException {
Element factionsElement = root.getChildByName(GameSaver.XML_FACTIONS);
for (int i = 0; i < factionsElement.getChildCount(); ++i) {
Element factionElement = factionsElement.getChild(i);
Faction faction = Faction.getFaction(factionElement.getName());
faction.loadFromXML(factionElement);
}
}
示例14: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
/**
* Read the skills from the suppled XML element and loads them
* into the supplied NonPlayerCharacter.
*
* The XML element should contain children in the following format:
* <pre>
* <Skill name="skillName" value="skillValue" />
* </pre>
* @param skillsContainer
* @param skillsElement
*/
@Override
public void loadFromXML(Element root) throws IOException {
super.loadFromXML(root);
Element skillsElement = root.getChildByName(getXMLElementName());
if (skillsElement != null) {
for (int i = 0; i< skillsElement.getChildCount(); ++i) {
Element variable = skillsElement.getChild(i);
setSkillRank(variable.getAttribute(XMLUtil.XML_ATTRIBUTE_ID).toUpperCase(Locale.ENGLISH),Integer.parseInt(variable.getAttribute(XMLUtil.XML_ATTRIBUTE_VALUE)));
}
}
}
示例15: loadFromXMLNoInit
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public void loadFromXMLNoInit(FileHandle file) throws IOException {
XmlReader xmlReader = new XmlReader();
Element root = xmlReader.parse(file);
XMLUtil.handleImports(this, file, root);
Element stateMachineElement = root.getChildByName(XML_STATE_MACHINE);
if (stateMachineElement != null) {
super.loadFromXML(stateMachineElement);
}
}