문제

I currently have an xml with the following code:

<Level>
    <!--Loads the animals for the Level-->
    <Animal>
        <Texture>panda.png</Texture>
        <PositionX>100</PositionX>
        <PositionY>50</PositionY>
        <Type>Panda</Type>
    </Animal>
    <Animal>
        <Texture>tiger.png</Texture>
        <PositionX>200</PositionX>
        <PositionY>150</PositionY>
        <Type>Tiger</Type>
    </Animal>
    <Animal>
        <Texture>monkey.png</Texture>
        <PositionX>300</PositionX>
        <PositionY>250</PositionY>
        <Type>Monkey</Type>
    </Animal>
</Level>

What I want is to get rid of positionX and positionY and replace it with a CGPoint variable. This will make it much easier for other items that I will add later down the line that will contain multiple positions.

I've searched the internet and not been able to find any documentation for GDataXML.

To get my strings and ints I'm using .stringValue and .intValue on my GDataXMLElement.

My question is, is it possible for GDataXML to get a CGPoint value from an xml file or am I going to have to do it as separate ints like I currently have it?

도움이 되었습니까?

해결책

Did you miss How to Read and Write XML Data with GDataXML?

As for CGPoint, I think you could encode it however you like. However, since a single point is made up of two separate values, it makes sense to encode those separately, perhaps inside another tag, like this:

<Point x:30 y:100 />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top