Java 类com.badlogic.gdx.utils.XmlReader 实例源码

项目:libgdx_ui_editor    文件:XmlUtils.java   
private static void readAttr(Group parentGroup, XmlReader.Element element){
    if (element.getName().equals("Stage")){
        XmlUtils.parseGenAttr(parentGroup,element);
        if (element.getChildCount()>0){
            for (int i = 0;i<element.getChildCount();i++){
                readAttr(parentGroup,element.getChild(i));
            }
        }
    }else if (element.getName().equals("Group")){
        Group group = new Group();
        XmlUtils.parseGenAttr(group,element);
        parentGroup.addActor(group);
        if (element.getChildCount()>0){
            for (int i = 0;i<element.getChildCount();i++){
                readAttr(group,element.getChild(i));
            }
        }
    }else {
        Actor actor = getActorByName(element.getName());
        parentGroup.addActor(actor);
        XmlUtils.parseGenAttr(actor,element);
        XmlUtils.parseUqAttr(actor,element);
    }

}
项目:KyperBox    文件:TiledObjectTypes.java   
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);
    }

}
项目:JavityEngine    文件:JXmlUi.java   
@Override
    public void awake() {
        if(skin == null) skin = new Skin(Gdx.files.internal(skinPath));
        XmlReader reader = new XmlReader();
        Element element = null;
        try {
            element = reader.parse(Gdx.files.internal(xmlPath));
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }

        Table table = new Table(skin);
        rootActor = table;

        parseTable(element, table);
        addChildrens(element, table);
        actorsMap.put(table.getName(), table);

//      Gdx.app.log("JXmlUi", "Parsing complete");

        actorComponent = new ActorComponent();
        actorComponent.setActor(rootActor);
        addNativeComponent(actorComponent);
    }
项目:fabulae    文件:ItemOwner.java   
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);
}
项目:fabulae    文件:WeatherProfile.java   
@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);
    }
}
项目:fabulae    文件:Configuration.java   
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);
        }
    }
}
项目:fabulae    文件:ProjectileTypeLoader.java   
@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;
}
项目:fabulae    文件:WeatherProfileLoader.java   
@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;
}
项目:fabulae    文件:TrapLoader.java   
@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;
}
项目:fabulae    文件:XMLUtil.java   
/**
 * 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);
    }
}
项目:Roguelike    文件:QuestManager.java   
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 );
    }
}
项目:Roguelike    文件:AbstractQuestInput.java   
public static AbstractQuestInput load( XmlReader.Element xml )
{
    Class<AbstractQuestInput> c = ClassMap.get( xml.getName().toUpperCase() );
    AbstractQuestInput type = null;

    try
    {
        type = ClassReflection.newInstance( c );
    }
    catch ( Exception e )
    {
        System.err.println(xml.getName());
        e.printStackTrace();
    }

    type.parse( xml );

    return type;
}
项目:Roguelike    文件:QuestOutput.java   
public void parse( XmlReader.Element xml )
{
    key = xml.getName().toLowerCase();
    data = xml.get( "Data", "true" ).toLowerCase();
    runFlag = xml.getBooleanAttribute( "RunFlag", false );
    defer = xml.getBooleanAttribute( "Defer", true );

    XmlReader.Element conditionsElement = xml.getChildByName( "Conditions" );
    if (conditionsElement != null)
    {
        for (int i = 0; i < conditionsElement.getChildCount(); i++ )
        {
            XmlReader.Element conditionElement = conditionsElement.getChild( i );
            AbstractQuestOutputCondition condition = AbstractQuestOutputCondition.load( conditionElement );
            conditions.add( condition );
        }
    }
}
项目:Roguelike    文件:AbstractQuestOutputCondition.java   
public static AbstractQuestOutputCondition load( XmlReader.Element xml )
{
    Class<AbstractQuestOutputCondition> c = ClassMap.get( xml.getName().toUpperCase() );
    AbstractQuestOutputCondition type = null;

    try
    {
        type = ClassReflection.newInstance( c );
    }
    catch ( Exception e )
    {
        System.err.println(xml.getName());
        e.printStackTrace();
    }

    type.parse( xml );

    return type;
}
项目:Roguelike    文件:Quest.java   
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;
}
项目:Roguelike    文件:AbstractActivationAction.java   
public static AbstractActivationAction load( XmlReader.Element xml )
{
    Class<AbstractActivationAction> c = ClassMap.get( xml.getName().toUpperCase() );
    AbstractActivationAction type = null;

    try
    {
        type = ClassReflection.newInstance( c );
    }
    catch ( Exception e )
    {
        System.err.println(xml.getName());
        e.printStackTrace();
    }

    type.parse( xml );

    return type;
}
项目:Roguelike    文件:AbstractActivationCondition.java   
public static AbstractActivationCondition load( XmlReader.Element xml )
{
    Class<AbstractActivationCondition> c = ClassMap.get( xml.getName().toUpperCase() );
    AbstractActivationCondition type = null;

    try
    {
        type = ClassReflection.newInstance( c );
    }
    catch ( Exception e )
    {
        System.err.println(xml.getName());
        e.printStackTrace();
    }

    type.parse( xml );

    return type;
}
项目:Roguelike    文件:ActivationActionSetPassable.java   
@Override
public void parse( XmlReader.Element xml )
{
    passableBy = Global.Passability.parse( xml.get( "Passable", "false" ) );

    if ( xml.get( "Opaque", null ) != null )
    {
        boolean opaque = xml.getBoolean( "Opaque", false );

        if ( opaque )
        {
            passableBy.clearBit( Global.Passability.LIGHT );
        }
        else
        {
            passableBy.setBit( Global.Passability.LIGHT );
        }
    }
}
项目:Roguelike    文件:GameEntity.java   
@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 );
}
项目:Roguelike    文件:AbstractOnHitEvent.java   
public static AbstractOnHitEvent load( XmlReader.Element xml )
{
    Class<AbstractOnHitEvent> c = ClassMap.get( xml.getName().toUpperCase() );
    AbstractOnHitEvent type = null;

    try
    {
        type = ClassReflection.newInstance( c );
    }
    catch ( Exception e )
    {
        System.err.println(xml.getName());
        e.printStackTrace();
    }

    type.parse( xml );

    return type;
}
项目:Roguelike    文件:AbstractOnExpireEvent.java   
public static AbstractOnExpireEvent load( XmlReader.Element xml )
{
    Class<AbstractOnExpireEvent> c = ClassMap.get( xml.getName().toUpperCase() );
    AbstractOnExpireEvent type = null;

    try
    {
        type = ClassReflection.newInstance( c );
    }
    catch ( Exception e )
    {
        System.err.println(xml.getName());
        e.printStackTrace();
    }

    type.parse( xml );

    return type;
}
项目:Roguelike    文件:LevelManager.java   
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;
}
项目:Roguelike    文件:AbstractTownEvent.java   
public static AbstractTownEvent load(XmlReader.Element xml )
{
    Class<AbstractTownEvent> c = ClassMap.get(xml.getName().toUpperCase());
    AbstractTownEvent type = null;

    try
    {
        type = (AbstractTownEvent) ClassReflection.newInstance( c );
    }
    catch (ReflectionException e)
    {
        e.printStackTrace();
    }

    type.parse(xml);

    return type;
}
项目:Roguelike    文件:EventList.java   
public EventList()
{
    XmlReader reader = new XmlReader();
    XmlReader.Element xml = null;

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

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

        flagEvents.add( new FlagEvent( el ) );
    }
}
项目:Roguelike    文件:TownCreator.java   
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() ) );
    }
}
项目:Roguelike    文件:TownCreator.java   
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 );
    }
}
项目:Roguelike    文件:DialogueManager.java   
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 );
}
项目:Roguelike    文件:AbstractHitType.java   
public static AbstractHitType load(XmlReader.Element xml )
{
    Class<AbstractHitType> c = ClassMap.get(xml.getName().toUpperCase());
    AbstractHitType type = null;

    try
    {
        type = (AbstractHitType) ClassReflection.newInstance( c );
    }
    catch (ReflectionException e)
    {
        e.printStackTrace();
    }

    type.parse(xml);

    return type;
}
项目:Roguelike    文件:ActiveAbility.java   
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 );
}
项目:Roguelike    文件:PassiveAbility.java   
private void internalLoad( String name )
{
    XmlReader xml = new XmlReader();
    Element xmlElement = null;

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

    internalLoad( xmlElement );
}
项目:Roguelike    文件:AbilityTree.java   
public AbilityTree( String treePath )
{
    this.treePath = treePath;

    XmlReader xmlReader = new XmlReader();
    XmlReader.Element treeElement = null;

    try
    {
        treeElement = xmlReader.parse( Gdx.files.internal( "Abilities/" + treePath + "/AbilityTree.xml" ) );
    }
    catch ( IOException e )
    {
        e.printStackTrace();
    }

    root = new AbilityStage( this, treeElement );
    current = root;
}
项目:Roguelike    文件:Item.java   
private void internalLoad( String name )
{
    XmlReader xml = new XmlReader();
    Element xmlElement = null;

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

    internalLoad( xmlElement );
}
项目:Roguelike    文件:StatusEffect.java   
private void internalLoad( String name )
{
    XmlReader xml = new XmlReader();
    Element xmlElement = null;

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

    internalLoad( xmlElement );
}
项目:ProjectRiddle    文件:Estado.java   
/**
 * Escoge la pista que te dará el personaje una vez acabado el puzzle
 * @param sigHab
 */

public void crearPista(String sigHab){
    XmlReader reader = new XmlReader();
    Element raiz = null;
    Array<Element> indicaciones;

    try {
        raiz = reader.parse(Gdx.files.internal("xml/indicaciones.xml"));
    } catch (IOException e) {}

    indicaciones = raiz.getChildrenByName("habitacion");

    for (Element child : indicaciones){ 
        if(sigHab.equals(child.getAttribute("nombre")))
            siguienteHabitacion = child.getAttribute("texto");
    }

    finalSinPista = agradecimiento + " "  + siguienteHabitacion;
    pistaPersonaje = agradecimiento + " " + pistaPersonaje + " " + siguienteHabitacion;
}
项目:absGDX    文件:TmxParser.java   
/**
 * Starts parsing of the TMX file.
 * Each found tile is redirected to the handleTile Method
 * 
 * @throws IOException
 * @throws DataFormatException
 * @throws TmxMapParsingException
 * @throws GdxRuntimeException 
 */
public void parse() throws IOException, DataFormatException, TmxMapParsingException, GdxRuntimeException {
    XmlReader xomBuilder = new XmlReader();

    Element mapElement = xomBuilder.parse(this.fileContent);

    int mapWidth = mapElement.getIntAttribute("width");
    int mapHeight = mapElement.getIntAttribute("height");

    Array<Element> layerList = mapElement.getChildrenByName("layer");
    for (int layerPos = 0; layerPos < layerList.size; layerPos++) {
        Element layer = layerList.get(layerPos);

        int layerWidth = Integer.parseInt(layer.getAttribute("width"));
        int layerHeight = Integer.parseInt(layer.getAttribute("height"));

        HashMap<String, String> propertiesMap = parseProperties(layer, layerPos, layerWidth, layerHeight, mapWidth, mapHeight);

        Element layerdata = layer.getChildByName("data");
        parseData(layerPos, layerdata, layerWidth, layerHeight, propertiesMap);
    }
}
项目:OneStory_VN_Engine    文件:OneStoryLoader.java   
@Override
public void loadResources() {
    XmlReader reader = new XmlReader();
    FileHandle sheetsFile = Gdx.files.internal("data/resources/sheets.xml");
    SpriteSheetService loader = SpriteSheetService.getInstance();
    Element sheets;
    try {
        sheets = reader.parse(sheetsFile);
        for(Element sheet:sheets.getChildrenByName("sheet")){
            loader.loadSpriteSheet(sheet.getText());
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:OneStory_VN_Engine    文件:StringManager.java   
/**
 * Loading the dictionnary
 */
private static void loadDictionnary(){
    stringDictionnary = new HashMap<String, String>();

    String filepath = dictionnariesDirectory + "lang-" + Language.toString(lang) + ".xml";
    XmlReader xml = new XmlReader();
    FileHandle file = Gdx.files.internal(filepath);

    try {
        Element data = xml.parse(file);
        //System.out.println("Loading dictionnary " + filepath);
        for(Element current:data.getChildrenByName("entry")){
            String key = current.getAttribute("key");
            String content = current.getAttribute("content");
            stringDictionnary.put(key, content);
            //System.out.println(key + " : " + content);
        }

    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:JavaLib    文件:SpriteSheet.java   
/**
 * Parses a SpriteSheet from an XML file.
 * @param xmlPath FileHandle of the XML file.
 * @return A fully initialized SpriteSheet.
 * @throws IOException
 */
public static SpriteSheet fromXML(FileHandle xmlHandle) throws IOException {
    XmlReader reader = new XmlReader();
    Element xml = reader.parse(xmlHandle);

    String texturePath = xml.getChildByName("texture").getText();

    SpriteSheet sheet = new SpriteSheet(new Texture(Gdx.files.internal(texturePath)));
    sheet.texturePath = texturePath;

    Rectangle rect = new Rectangle();
    for (Element child : xml.getChildrenByName("rect")) {
        String[] coords = child.getText().split(",");
        rect.x = Float.parseFloat(coords[0]);
        rect.y = Float.parseFloat(coords[1]);
        rect.width = Float.parseFloat(coords[2]);
        rect.height = Float.parseFloat(coords[3]);

        sheet.addRegion(child.getAttribute("key"), rect);
    }

    return sheet;
}
项目:liblol    文件:Svg.java   
/**
 * The main parse routine. We slurp the file into an XML DOM object, and then iterate over it,
 * finding the paths within the g, and processing their "d" attributes
 *
 * @param svgName The name of the file to parse
 */
void parse(String svgName) {
    XmlReader r = new XmlReader();
    try {
        Element root = r.parse(Gdx.files.internal(svgName));
        // get the <g> tags
        Array<Element> gs = root.getChildrenByName("g");
        for (Element g : gs) {
            // Get the g's transform attribute
            String transform = g.getAttribute("transform", "");
            if (!transform.equals(""))
                processTransform(transform);
            // get each g's paths
            Array<Element> paths = g.getChildrenByName("path");
            for (Element p : paths)
                processD(p.getAttribute("d"));
        }
    } catch (IOException e) {
        Lol.message(mLevel.mConfig, "SVG Error", "error parsing SVG file");
        e.printStackTrace();
    }
}
项目:RuinsOfRevenge    文件:ServerMaster.java   
public ServerMaster(String mapfile, String basePath) throws IOException {
    super(basePath);
    this.physics = new Physics(new Vector2(0, 0), true);
    if (RuinsOfRevenge.fileLocation == FileLocation.CLASSPATH)
        this.mapObjects = new TmxObjectsLoader(new XmlReader().parse(
                Thread.currentThread().getContextClassLoader().getResourceAsStream(mapfile)));
    else
        this.mapObjects = new TmxObjectsLoader(new XmlReader().parse(new FileHandle(mapfile)));
    this.connection = new ServerConnection(this, PORT_TCP, PORT_UDP);
    this.controllers = new EntityControllers();

    for (TmxObjectsLoader.TmxObjectGroup group : mapObjects.getObjectGroups()) {
        for (TmxObjectsLoader.TmxObject obj : group.objects) {
            if (!obj.name.equalsIgnoreCase("spawnpoint")) {
                mapObjects.loadToPhysics(obj, physics);
            } else {
                System.out.println("spawnpoint found: " + obj.name);
            }
        }
    }
}