本文整理汇总了Java中com.badlogic.gdx.utils.XmlReader.Element.getChildrenByName方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getChildrenByName方法的具体用法?Java Element.getChildrenByName怎么用?Java Element.getChildrenByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.XmlReader.Element
的用法示例。
在下文中一共展示了Element.getChildrenByName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDependencies
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle tmxFile,
com.badlogic.gdx.maps.tiled.AtlasTmxMapLoader.AtlasTiledMapLoaderParameters parameter) {
Array<AssetDescriptor> dependencies = new Array<AssetDescriptor>();
try {
root = xml.parse(tmxFile);
Element properties = root.getChildByName("properties");
if (properties != null) {
for (Element property : properties.getChildrenByName("property")) {
String name = property.getAttribute("name");
String value = property.getAttribute("value");
if (name.startsWith("atlas")) {
FileHandle atlasHandle = Gdx.files.internal(value);
dependencies.add(new AssetDescriptor(atlasHandle, TextureAtlas.class));
}
}
}
} catch (IOException e) {
throw new GdxRuntimeException("Unable to parse .tmx file.");
}
return dependencies;
}
示例2: 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;
}
示例3: TiledObjectTypes
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public TiledObjectTypes(String file) {
xml_reader = new XmlReader();
try {
root = xml_reader.parse(Gdx.files.internal(file));
} catch (IOException e) {
e.printStackTrace();
}
types = new ObjectMap<String, TiledObjectTypes.TiledObjectType>();
if(root == null)
throw new GdxRuntimeException(String.format("Unable to parse file %s. make sure it is the correct path.", file));
Array<Element> types = root.getChildrenByName("objecttype");
for (Element element : types) {
TiledObjectType tot = new TiledObjectType(element.get("name"));
Array<Element> properties = element.getChildrenByName("property");
for (int i = 0; i < properties.size; i++) {
Element element2 = properties.get(i);
TypeProperty property = new TypeProperty(element2.get("name"), element2.get("type"), element2.hasAttribute("default")?element2.get("default"):"");
tot.addProperty(property);
}
this.types.put(tot.name, tot);
}
}
示例4: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
@Override
public PCSelector loadFromXML(Element element) {
super.loadFromXML(element);
skills = new Array<Skill>();
if (skillsNames != null) {
Array<String> splitSkillNames = StringUtil.arrayFromDelimitedString(skillsNames, ",");
for (String skill : splitSkillNames) {
skills.add(Skill.valueOf(skill.toUpperCase(Locale.ENGLISH)));
}
}
Array<Element> children = element.getChildrenByName(XML_ELEMENT_NPCTTALK);
for (Element npcTalk : children) {
String id = npcTalk.getAttribute(XML_ATTRIBUTE_ID);
NPCTalk talk = getDialogue().getNPCTalk(id);
if (talk == null) {
talk = new NPCTalk(getDialogue());
talk.setId(id);
}
this.npcTalks.add(talk);
getDialogue().addNPCTalk(talk);
}
return this;
}
示例5: handleImports
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public static <T, P extends AssetLoaderParameters<T>> void handleImports(
AssetLoader<T, P> loader, P parameter,
@SuppressWarnings("rawtypes") Array<AssetDescriptor> dependencies, FileHandle parentFile,
Element root) throws IOException {
Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
for (Element singleImport : imports) {
String filename = singleImport.get(XMLUtil.XML_FILENAME);
FileHandle file = parentFile.parent().child(filename);
if (!file.exists()) {
throw new GdxRuntimeException("Import " + file.path()
+ " from import for " + parentFile.name()
+ " does not exist.");
}
dependencies.addAll(loader.getDependencies(filename, file, parameter));
}
}
示例6: readAllGameObjectsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private void readAllGameObjectsFromXML(Element root) {
Array<Element> gosElements = root.getChildrenByName(GameSaver.XML_GAME_OBJECTS);
for (Element gosElement : gosElements) {
String mapId = gosElement.getAttribute(GameSaver.XML_MAP, null);
GameMap map = mapId == null ? null : mapsById.get(mapId);
Array<GameObject> gosForMap = new Array<GameObject>();
if (map != null) {
gosToMaps.put(map, gosForMap);
}
for (int i = 0; i < gosElement.getChildCount(); ++i) {
Element goElement = gosElement.getChild(i);
GameObject go = (GameObject) createFromXML(gameState, goElement);
gosForMap.add(go);
}
}
}
示例7: loadFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public PCTalk loadFromXML(Element element) {
super.loadFromXML(element);
Array<Element> texts = element.getChildrenByName(XML_ELEMENT_TEXT);
roleSpecificTexts = new ObjectMap<String, String>();
for (Element textElement : texts) {
String role = textElement.getAttribute(XML_ATTRIBUTE_ROLE, ROLE_DEFAULT);
roleSpecificTexts.put(role, StringUtil.clearString(textElement.getText()));
}
conversationEnd = Boolean.valueOf(element.getAttribute(XML_ATTRIBUTE_CONVERSATION_END, "false"));
isYes = Boolean.valueOf(element.getAttribute(XML_ATTRIBUTE_IS_YES, "false"));
Array<Element> children = element.getChildrenByName(XML_ELEMENT_NPCTTALK);
for (Element npcTalk : children) {
String id = npcTalk.getAttribute(XML_ATTRIBUTE_ID);
NPCTalk talk = getDialogue().getNPCTalk(id);
if (talk == null) {
talk = new NPCTalk(getDialogue());
talk.setId(id);
}
this.npcTalks.add(talk);
getDialogue().addNPCTalk(talk);
}
return this;
}
示例8: 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);
for (ChatterType type : ChatterType.values()) {
Array<Element> typeElements = root.getChildrenByName(type.getXmlName());
for (Element typeElement : typeElements) {
ObjectMap<String, Array<String>> locationTexts = texts.get(type);
ObjectMap<String, Integer> locationChances = s_chanceToSay.get(type);
ObjectMap<String, Float> locationFrequencies = s_checkFrequency.get(type);
String location = typeElement.get(XML_LOCATION, NO_LOCATION_ID).toLowerCase(Locale.ENGLISH);
locationChances.put(location, typeElement.getInt(XML_CHANCE_TO_SAY, 0));
locationFrequencies.put(location, typeElement.getFloat(XML_CHECK_FREQUENCY, 0f));
Array<String> textArray = locationTexts.get(location);
if (textArray == null) {
textArray = new Array<String>();
locationTexts.put(location, textArray);
}
Array<Element> textElements = typeElement.getChildrenByName(XML_TEXT);
for (Element textElement : textElements) {
textArray.add(textElement.getText());
}
}
}
}
示例9: handleImports
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
public static void handleImports(XMLLoadable importable, FileHandle parentFile, Element root) throws IOException {
Array<Element> imports = root.getChildrenByName(XMLUtil.XML_IMPORT);
for (Element singleImport : imports) {
String filename = singleImport.get(XMLUtil.XML_FILENAME);
FileHandle file = parentFile.parent().child(filename);
if (!file.exists()) {
throw new GdxRuntimeException("Import " + file.path() + " from import for " + importable
+ " does not exist.");
}
importable.loadFromXMLNoInit(file);
}
}
示例10: readAllLocationsFromXML
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private void readAllLocationsFromXML(Element root) throws IOException {
Array<Element> locationsElements = root.getChildrenByName(GameSaver.XML_LOCATIONS);
for (Element locationsElement : locationsElements) {
String mapId = locationsElement.getAttribute(GameSaver.XML_MAP, null);
if (mapId == null) {
continue;
}
GameMap map = null;
for (int i = 0; i < locationsElement.getChildCount(); ++i) {
Element locElement = locationsElement.getChild(i);
GameLocation loc = (GameLocation) createFromXML(gameState, locElement);
// the first location is the map itself, the others are those that belong to it
// its okay if this dies on a class cast, since if this is not true, then everything is terrible
if (i == 0) {
map = (GameMap) loc;
} else {
loc.setMap(map);
// load any "master data" from the xml file
loc.loadFromXML(Gdx.files.internal(Configuration
.getFolderLocations() + loc.getType() + ".xml"));
// and then reload it from the savegame to override any changes
// TODO this currently means the savegame element is read twice, this should be optimized
loc.loadFromXML(locElement);
}
gameState.addLocation(loc);
}
}
}
示例11: loadTransitions
import com.badlogic.gdx.utils.XmlReader.Element; //导入方法依赖的package包/类
private void loadTransitions(Element stateElement) {
Array<Element> transitionElements = stateElement.getChildrenByName(XML_TRANSITION);
for (Element transitionElement : transitionElements) {
transitions.add(createTransition(transitionElement));
}
}