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


Java XmlReader.parse方法代码示例

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


在下文中一共展示了XmlReader.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TiledObjectTypes

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的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

示例2: getDependencies

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的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;
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:22,代码来源:TrapLoader.java

示例3: getDependencies

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的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

示例4: getOwnerCharacterName

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
private String getOwnerCharacterName() {
	if (ownerCharacterName == null && s_ownerCharacterId != null) {
		try {
			GameObject go = GameState.getGameObjectById(s_ownerCharacterId);
			if (go instanceof GameCharacter) {
				ownerCharacterName =  ((GameCharacter) go).getName();
			} else {
				XmlReader xmlReader = new XmlReader();
				Element root = xmlReader.parse(Gdx.files
						.internal(Configuration.getFolderCharacters()
								+ s_ownerCharacterId + ".xml"));
				ownerCharacterName = root.getChildByName(
						XMLUtil.XML_PROPERTIES).get(
						XMLUtil.XML_ATTRIBUTE_NAME);
			}
		} catch (SerializationException e) {
			throw new GdxRuntimeException("Could not determine the owner with type "+s_ownerCharacterId, e);
		}
		if (ownerCharacterName == null) {
			throw new GdxRuntimeException("Could not determine the owner with type "+s_ownerCharacterId);
		}
	}
	return Strings.getString(ownerCharacterName);
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:25,代码来源:ItemOwner.java

示例5: loadFromXMLNoInit

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的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

示例6: getDependencies

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的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

示例7: GameOptions

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
private GameOptions(final FileHandle file) throws IOException {
	final XmlReader xmlReader = new XmlReader();
	final Element root = xmlReader.parse(file);
	XMLUtil.readPrimitiveMembers(this, root);
	Element keyBindingsElement = root.getChildByName(XML_KEY_BINDINGS);
	if (keyBindingsElement != null) {
		for (int i = 0; i < keyBindingsElement.getChildCount(); ++i) {
			Element bindingElement = keyBindingsElement.getChild(i);
			KeyBindings binding = KeyBindings.valueOf(bindingElement.getName().toUpperCase(Locale.ENGLISH));
			binding.getKeys().clear();
			Array<Integer> newKeys = new Array<Integer>();
			if (bindingElement.getText() != null) {
				for (String key : bindingElement.getText().split(",")) {
					newKeys.add(Integer.valueOf(key));
				}
			}
			binding.getKeys().addAll(newKeys);
		}
	}
}
 
开发者ID:mganzarcik,项目名称:fabulae,代码行数:21,代码来源:Configuration.java

示例8: QuestManager

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
public QuestManager()
{
	XmlReader reader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = reader.parse( Gdx.files.internal( "Quests/QuestList.xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	for (int i = 0; i < xml.getChildCount(); i++)
	{
		XmlReader.Element questEl = xml.getChild( i );
		Quest quest = Quest.load( questEl.getText() );
		availableQuests.add( quest );
	}
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:22,代码来源:QuestManager.java

示例9: load

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
public static Quest load(String name)
{
	Quest quest = new Quest();
	quest.path = name;

	XmlReader reader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = reader.parse( Gdx.files.internal( "Quests/" + name + ".xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	quest.parse( xml );

	return quest;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:22,代码来源:Quest.java

示例10: internalLoad

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
@Override
protected void internalLoad( String entity )
{
	XmlReader xml = new XmlReader();
	Element xmlElement = null;

	try
	{
		xmlElement = xml.parse( Gdx.files.internal( "Entities/" + entity + ".xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	internalLoad( xmlElement );
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:18,代码来源:GameEntity.java

示例11: LevelManager

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
public LevelManager()
{
	XmlReader xmlReader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = xmlReader.parse( Gdx.files.internal( "Levels/LevelGraph.xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	root = new LevelData( this );
	root.parse( xml );

	current = root;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:20,代码来源:LevelManager.java

示例12: TownCreator

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
public TownCreator()
{
	XmlReader reader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = reader.parse( Gdx.files.internal( "Levels/Town/BuildingList.xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	for (int i = 0; i < xml.getChildCount(); i++)
	{
		XmlReader.Element el = xml.getChild( i );

		buildings.add( new Building( el.getName(), el.getText() ) );
	}
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:22,代码来源:TownCreator.java

示例13: Building

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
public Building(String name, String key)
{
	this.name = name.toLowerCase();
	this.key = key != null ? key.toLowerCase() : null;

	XmlReader reader = new XmlReader();
	XmlReader.Element xml = null;

	try
	{
		xml = reader.parse( Gdx.files.internal( "Levels/Town/" + name + ".xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	XmlReader.Element roomsElement = xml.getChildByName( "Rooms" );
	for ( int i = 0; i < roomsElement.getChildCount(); i++ )
	{
		XmlReader.Element roomElement = roomsElement.getChild( i );
		DungeonFileParser.DFPRoom room = DungeonFileParser.DFPRoom.parse( roomElement );

		rooms.add( room );
	}
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:27,代码来源:TownCreator.java

示例14: load

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
public static DialogueManager load( String path )
{
	XmlReader xmlReader = new XmlReader();
	Element xml = null;

	try
	{
		xml = xmlReader.parse( Gdx.files.internal( path + ".xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	return load( xml );
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:17,代码来源:DialogueManager.java

示例15: internalLoad

import com.badlogic.gdx.utils.XmlReader; //导入方法依赖的package包/类
private void internalLoad( String name )
{
	XmlReader xml = new XmlReader();
	Element xmlElement = null;

	try
	{
		xmlElement = xml.parse( Gdx.files.internal( "Abilities/" + name + ".xml" ) );
	}
	catch ( IOException e )
	{
		e.printStackTrace();
	}

	internalLoad( xmlElement );
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:17,代码来源:ActiveAbility.java


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