1

我想从我用 Texture Packer 创建的 XML 文件中读取几个图像并将它们添加到集合视图中。XML 如下所示:

<TextureAtlas imagePath="Level1TextureAtlas.png" width="1024" height="512">
    <sprite n="bild0" x="2" y="424" w="128" h="86"/>

    <sprite n="bild1" x="273" y="135" w="131" h="131"/>
    <sprite n="bild10" x="406" y="106" w="128" h="65"/>
    <sprite n="bild11" x="436" y="303" w="128" h="40"/>
    <sprite n="bild12" x="383" y="414" w="128" h="66"/>
    <sprite n="bild13" x="524" y="2" w="65" h="65"/>
    <sprite n="bild14" x="2" y="149" w="136" h="136"/>
    <sprite n="bild15" x="300" y="346" w="153" h="66"/>
    <sprite n="bild16" x="455" y="345" w="163" h="46"/>
    <sprite n="bild17" x="557" y="69" w="111" h="30"/>
    <sprite n="bild18" x="216" y="415" w="165" h="87"/>
    <sprite n="bild19" x="300" y="268" w="134" h="76"/>
    <sprite n="bild2" x="2" y="287" w="163" h="135"/>
    <sprite n="bild20" x="591" y="2" w="64" h="30"/>
    <sprite n="bild21" x="265" y="2" w="131" h="131"/>
    <sprite n="bild22" x="406" y="173" w="65" h="65"/>
    <sprite n="bild23" x="524" y="69" w="31" h="31"/>
    <sprite n="bild24" x="398" y="2" w="124" h="102"/>
    <sprite n="bild3" x="167" y="282" w="131" h="131"/>
    <sprite n="bild4" x="536" y="102" w="115" h="42"/>
    <sprite n="bild5" x="473" y="173" w="145" h="55"/>
    <sprite n="bild6" x="140" y="149" w="131" h="131"/>
    <sprite n="bild7" x="2" y="2" w="261" h="145"/>
    <sprite n="bild8" x="436" y="240" w="61" h="61"/>
    <sprite n="bild9" x="132" y="424" w="82" h="82"/>
</TextureAtlas>

我在整个网络上搜索了这个,但我找不到任何帮助。谁能告诉我如何遍历 XML 并将图像保存在数组中?

4

0 回答 0