-
Notifications
You must be signed in to change notification settings - Fork 27
The XML Output
SteveDunn edited this page Jan 7, 2012
·
4 revisions
When saving a level, you'll end up with an XML
file. The XML looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Level>
<LevelProperties>
<Name>Root</Name>
<Id>0</Id>
<Visible>true</Visible>
<Position>
<X>0</X>
<Y>0</Y>
</Position>
<CustomProperties />
<ContentRootFolder>
<AbsolutePath>c:\</AbsolutePath>
</ContentRootFolder>
<NextItemNumber>5</NextItemNumber>
<CameraPosition>
<X>0</X>
<Y>0</Y>
</CameraPosition>
<Version>2.0.0.0</Version>
</LevelProperties>
<Layers>
<Layer Name="Layer_0">
<LayerProperties>
<Name>Layer_0</Name>
<Id>0</Id>
<Visible>true</Visible>
<Position>
<X>0</X>
<Y>0</Y>
</Position>
<CustomProperties />
<ScrollSpeed>
<X>1</X>
<Y>1</Y>
</ScrollSpeed>
</LayerProperties>
<Editors>
<Editor ClrTypeOfEditor="0" ClrTypeOfProperties="1" Name="Rectangle_1">
<RectangleItemProperties>
<Name>Rectangle_1</Name>
<Id>1325959345</Id>
<Visible>true</Visible>
<Position>
<X>-252</X>
<Y>-208</Y>
</Position>
<CustomProperties />
<Width>126</Width>
<Height>31</Height>
<FillColor>
<R>192</R>
<G>0</G>
<B>192</B>
<A>145</A>
<PackedValue>2445279424</PackedValue>
</FillColor>
<Rotation>0</Rotation>
</RectangleItemProperties>
</Editor>
<Editor ClrTypeOfEditor="0" ClrTypeOfProperties="1" Name="Rectangle_2">
<RectangleItemProperties>
<Name>Rectangle_2</Name>
<Id>1325959348</Id>
<Visible>true</Visible>
<Position>
<X>-50</X>
<Y>-202</Y>
</Position>
<CustomProperties />
<Width>64</Width>
<Height>158</Height>
<FillColor>
<R>192</R>
<G>0</G>
<B>192</B>
<A>145</A>
<PackedValue>2445279424</PackedValue>
</FillColor>
<Rotation>0</Rotation>
</RectangleItemProperties>
</Editor>
<Editor ClrTypeOfEditor="2" ClrTypeOfProperties="3" Name="Path_3">
<PathItemProperties>
<Name>Path_3</Name>
<Id>1325959355</Id>
<Visible>true</Visible>
<Position>
<X>78</X>
<Y>-189</Y>
</Position>
<CustomProperties />
<IsPolygon>false</IsPolygon>
<LineWidth>4</LineWidth>
<LineColor>
<R>192</R>
<G>0</G>
<B>192</B>
<A>145</A>
<PackedValue>2445279424</PackedValue>
</LineColor>
<LocalPoints>
<Vector2>
<X>0</X>
<Y>0</Y>
</Vector2>
<Vector2>
<X>58</X>
<Y>-18</Y>
</Vector2>
<Vector2>
<X>84</X>
<Y>35</Y>
</Vector2>
<Vector2>
<X>28</X>
<Y>61</Y>
</Vector2>
<Vector2>
<X>14</X>
<Y>31</Y>
</Vector2>
</LocalPoints>
<WorldPoints>
<Vector2>
<X>78</X>
<Y>-189</Y>
</Vector2>
<Vector2>
<X>136</X>
<Y>-207</Y>
</Vector2>
<Vector2>
<X>162</X>
<Y>-154</Y>
</Vector2>
<Vector2>
<X>106</X>
<Y>-128</Y>
</Vector2>
<Vector2>
<X>92</X>
<Y>-158</Y>
</Vector2>
</WorldPoints>
</PathItemProperties>
</Editor>
<Editor ClrTypeOfEditor="4" ClrTypeOfProperties="5" Name="Circle_4">
<CircleItemProperties>
<Name>Circle_4</Name>
<Id>1325959359</Id>
<Visible>true</Visible>
<Position>
<X>202</X>
<Y>-95</Y>
</Position>
<CustomProperties />
<Radius>30.4630928</Radius>
<FillColor>
<R>192</R>
<G>0</G>
<B>192</B>
<A>145</A>
<PackedValue>2445279424</PackedValue>
</FillColor>
</CircleItemProperties>
</Editor>
<Editor ClrTypeOfEditor="6" ClrTypeOfProperties="7" Name="Texture_5">
<TextureItemProperties>
<Name>Texture_5</Name>
<Id>1325959367</Id>
<Visible>true</Visible>
<Position>
<X>-46</X>
<Y>61</Y>
</Position>
<CustomProperties />
<Rotation>0</Rotation>
<Scale>
<X>1</X>
<Y>1</Y>
</Scale>
<TintColor>
<R>255</R>
<G>255</G>
<B>255</B>
<A>255</A>
<PackedValue>4294967295</PackedValue>
</TintColor>
<FlipHorizontally>false</FlipHorizontally>
<FlipVertically>false</FlipVertically>
<IsTemplate>false</IsTemplate>
<TexturePathRelativeToContentRoot>test.png</TexturePathRelativeToContentRoot>
<Origin>
<X>210</X>
<Y>171</Y>
</Origin>
</TextureItemProperties>
</Editor>
</Editors>
</Layer>
</Layers>
<TypeMap>
<Type Name="Gleed2D.Plugins.RectangleItemEditor, Gleed2D.Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="0" />
<Type Name="Gleed2D.InGame.RectangleItemProperties, Gleed2D.InGame.Windows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="1" />
<Type Name="Gleed2D.Plugins.PathItemEditor, Gleed2D.Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="2" />
<Type Name="Gleed2D.InGame.PathItemProperties, Gleed2D.InGame.Windows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="3" />
<Type Name="Gleed2D.Plugins.CircleItemEditor, Gleed2D.Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="4" />
<Type Name="Gleed2D.InGame.CircleItemProperties, Gleed2D.InGame.Windows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="5" />
<Type Name="Gleed2D.Plugins.TextureItemEditor, Gleed2D.Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="6" />
<Type Name="Gleed2D.InGame.TextureItemProperties, Gleed2D.InGame.Windows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Index="7" />
</TypeMap>
</Level>
As you can see, this XML describes the level's contents. Here there's a couple of rectangles, a circle, a path, and a texture.
The file contains information for the game and the editor. For example, for the texture, theres an Editor element with attributes that describe what type of editor (ClrTypeOfEditor
) for the Gleed 2D tool and what type of properties for the game (ClrTypeOfProperties
)
In your game, you can load the XML with the LevelLoader
type. You then get a hierarchy of things deriving from ItemProperties
which you can transform to your in-game objects. You also have the choice to parse the XML directly.