当前位置: 首页>>代码示例>>Java>>正文


Java Element类代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.XmlReader.Element的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Element类属于com.badlogic.gdx.utils.XmlReader包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:25,代码来源:KyperMapLoader.java

示例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;
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:25,代码来源:KyperMapLoader.java

示例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);
	}
	
}
 
开发者ID:kyperbelt,项目名称:KyperBox,代码行数:25,代码来源:TiledObjectTypes.java

示例4: addList

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
private void addList(Table table, Element element) {
	Gdx.app.log("JXmlUi", "addList");
	ObjectMap<String, String> atrributes = element.getAttributes();
	if (atrributes == null)
		atrributes = new ObjectMap<String, String>();

	List<String> list = new List<String>(skin);
	list.getSelection().setMultiple(false);

	ScrollPane scrollPane = new ScrollPane(list, skin);

	Cell<ScrollPane> cell = table.add(scrollPane);
	for (String key : atrributes.keys()) {
		if (key.equalsIgnoreCase("name")) {
			list.setName(atrributes.get(key));
			scrollPane.setName(atrributes.get(key) + "-scroll-panel");
		}
	}
	cellPrepare(cell, atrributes);

	actorsMap.put(list.getName(), list);
	actorsMap.put(scrollPane.getName(), scrollPane);

	addElementsInList(element, list);
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:26,代码来源:JXmlUi.java

示例5: addElementsInList

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
private void addElementsInList(Element element, List list) {
	Array<String> items = new Array<String>();

	int childCount = element.getChildCount();
	for (int x = 0; x < childCount; x++) {
		Element child = element.getChild(x);
		if (!child.getName().equalsIgnoreCase("list-element"))
			continue;
		// Gdx.app.log("JXmlUi", "addListElement");
		String text = child.getAttribute("text");
		items.add(text);

	}

	list.setItems(items);
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:17,代码来源:JXmlUi.java

示例6: addButton

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
private void addButton(Table table, Element element) {
	TextButton button = new TextButton("", skin);
	Cell<TextButton> cell = table.add(button);

	ObjectMap<String, String> atrributes = element.getAttributes();
	for (String key : atrributes.keys()) {
		if (key.equalsIgnoreCase("text")) {
			button.setText(atrributes.get(key));
		} else if (key.equalsIgnoreCase("checked")) {
			button.setChecked(Boolean.parseBoolean(atrributes.get(key)));
		} else if (key.equalsIgnoreCase("visible")) {
			button.setVisible(Boolean.parseBoolean(atrributes.get(key)));
		} else if (key.equalsIgnoreCase("enable")) {
			button.setDisabled(!Boolean.parseBoolean(atrributes.get(key)));
		} else if (key.equalsIgnoreCase("name")) {
			button.setName(atrributes.get(key));
		}
	}
	cellPrepare(cell, atrributes);

	// System.out.println("Dodaje button: " + button.getName());
	actorsMap.put(button.getName(), button);
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:24,代码来源:JXmlUi.java

示例7: readStates

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
private void readStates(Element root) {
	for (int i = 0; i < root.getChildCount(); ++i) {
		Element stateElement = root.getChild(i);
		if (!XML_STATE.equalsIgnoreCase(stateElement.getName())) {
			continue;
		}
		S newState = createState(stateElement);
		newState.loadFromXML(stateElement);
		states.put(newState.getId(), newState);
	}
	
	String currentStateId = root.get(XML_CURRENT_STATE, null);
	if (currentStateId != null) {
		currentState = getStateForId(currentStateId);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:17,代码来源:StateMachine.java

示例8: 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();  
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:25,代码来源:Effect.java

示例9: 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);
	
	isModifier = root.getName().endsWith(MODIFIER_SUFFIX);
	XMLUtil.readPrimitiveMembers(this,
			root);
	createPools();
	Element weatherEffects = root.getChildByName(XML_WEATHER_EFFECTS);
	if (weatherEffects != null) {
		readAllSounds(weatherEffects.getChildByName(XML_RAIN), continuousSoundsRain, randomSoundsRain);
		readAllSounds(weatherEffects.getChildByName(XML_SNOW), continuousSoundsSnow, randomSoundsSnow);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:17,代码来源:WeatherProfile.java

示例10: 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);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:26,代码来源:Quest.java

示例11: getDependencies

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, ProjectileTypeParameter parameter) {
	XmlReader xmlReader = new XmlReader();
	try {
		Array<AssetDescriptor>  returnValue = new Array<AssetDescriptor>();
		Element root = xmlReader.parse(file);
		LoaderUtil.handleImports(this, parameter, returnValue, file, root);
		String animationFile = root.get(ProjectileType.XML_ANIMATION_FILE, null);
		if (animationFile != null) {
			returnValue.add(new AssetDescriptor<Texture>(Configuration.addModulePath(animationFile), Texture.class));
		}
		Element soundsElement = root.getChildByName(XMLUtil.XML_SOUNDS);
		if (soundsElement != null) {
			addSoundDependency(soundsElement, ProjectileType.XML_ON_START, returnValue);
			addSoundDependency(soundsElement, ProjectileType.XML_ON_HIT, returnValue);
			addSoundDependency(soundsElement, ProjectileType.XML_DURING, returnValue);
		}
		if (returnValue.size > 0) {
			return returnValue;
		}
	} catch (IOException e) {
		throw new GdxRuntimeException(e);
	}
	return null;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:27,代码来源:ProjectileTypeLoader.java

示例12: parseNonCLosing

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
/**
 * Parses the supplied InputStream without closing it at the end using the
 * supplied XmlReader.
 * 
 * @param inStream
 * @return
 */
public static Element parseNonCLosing(XmlReader parser, InputStream inStream) {
	try {
		InputStreamReader inReader = new InputStreamReader(inStream, "UTF-8");
		char[] data = new char[1024];
		int offset = 0;
		while (true) {
			int length = inReader.read(data, offset, data.length - offset);
			if (length == -1)
				break;
			if (length == 0) {
				char[] newData = new char[data.length * 2];
				System.arraycopy(data, 0, newData, 0, data.length);
				data = newData;
			} else
				offset += length;
		}
		return parser.parse(data, 0, offset);
	} catch (IOException ex) {
		throw new SerializationException(ex);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:29,代码来源:XMLUtil.java

示例13: 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);
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:26,代码来源:ProjectileType.java

示例14: loadFromXML

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
@Override
public void loadFromXML(Element root) throws IOException {
	Element formationElement = root.getChildByName(XML_FORMATION);
	if (formationElement == null) {
		return;
	}
	orientation = Orientation.valueOf(formationElement.getAttribute(XML_FORMATION_ORIENTATION, "UP"));
	for (int i = 0; i <formationElement.getChildCount(); ++i) {
		Element memberElement = formationElement.getChild(i);
		Integer index = Integer.valueOf(memberElement.getAttribute(XML_ATTRIBUTE_INDEX));
		int xOffset = Integer.parseInt(memberElement.getAttribute(XML_ATTRIBUTE_XOFFSET, "0"));
		int yOffset = Integer.parseInt(memberElement.getAttribute(XML_ATTRIBUTE_YOFFSET, "0"));
		formation.put(index, new Tile(xOffset,yOffset));
	}
	recalculateOrthoFormation();
	recalculateIsoFormation();
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:18,代码来源:Formation.java

示例15: getDependencies

import com.badlogic.gdx.utils.XmlReader.Element; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, WeatherProfileParameter parameter) {
	Array<AssetDescriptor> returnValue = new Array<AssetDescriptor>();
	try {
		XmlReader xmlReader = new XmlReader();
		Element root = xmlReader.parse(file);
		LoaderUtil.handleImports(this, parameter, returnValue, file, root);
		Array<Element> trackElements = root.getChildrenByNameRecursively(WeatherProfile.XML_TRACK);
		for (Element trackElement : trackElements) {
			String trackFileName = Configuration.addModulePath(trackElement.get(XMLUtil.XML_ATTRIBUTE_FILENAME));
			returnValue.add(new AssetDescriptor(trackFileName, WeatherProfile.XML_CONTINOUS.equalsIgnoreCase(trackElement.getParent().getName()) ? Music.class : Sound.class)); 
		}
	} catch (IOException e) {
		throw new GdxRuntimeException(e);
	}
	
	return returnValue;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:20,代码来源:WeatherProfileLoader.java


注:本文中的com.badlogic.gdx.utils.XmlReader.Element类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。