Level.cs file has a texture loading error?

Jul 18, 2011 at 3:25 PM

I am trying to load this level:

(three rectangles and a few textures for testing in farseer)

 

<?xml version="1.0"?>
<Level xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Level_01" Visible="true">
    <Layers>
        <Layer Name="Obsticles" Visible="true">
            <Items>
                <Item xsi:type="RectangleItem" Name="Rectangle_0012" Visible="true">
                    <Position>
                        <X>-1014</X>
                        <Y>58</Y>
                    </Position>
                    <CustomProperties />
                    <Width>2330</Width>
                    <Height>204</Height>
                    <FillColor>
                        <R>192</R>
                        <G>0</G>
                        <B>192</B>
                        <A>145</A>
                        <PackedValue>2445279424</PackedValue>
                    </FillColor>
                </Item>
                <Item xsi:type="RectangleItem" Name="Rectangle_0013" Visible="true">
                    <Position>
                        <X>-1046</X>
                        <Y>-384</Y>
                    </Position>
                    <CustomProperties />
                    <Width>260</Width>
                    <Height>442</Height>
                    <FillColor>
                        <R>192</R>
                        <G>0</G>
                        <B>192</B>
                        <A>145</A>
                        <PackedValue>2445279424</PackedValue>
                    </FillColor>
                </Item>
                <Item xsi:type="RectangleItem" Name="Rectangle_0014" Visible="true">
                    <Position>
                        <X>1248</X>
                        <Y>-521</Y>
                    </Position>
                    <CustomProperties />
                    <Width>134</Width>
                    <Height>580</Height>
                    <FillColor>
                        <R>192</R>
                        <G>0</G>
                        <B>192</B>
                        <A>145</A>
                        <PackedValue>2445279424</PackedValue>
                    </FillColor>
                </Item>
                <Item xsi:type="TextureItem" Name="Texture_0015" Visible="true">
                    <Position>
                        <X>-147</X>
                        <Y>-659</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>
                    <texture_filename>..\..\..\..\..\SamplesXNAContent\textures\texture7.png</texture_filename>
                    <asset_name>..\..\..\..\..\SamplesXNAContent\textures\texture7</asset_name>
                    <Origin>
                        <X>128</X>
                        <Y>128</Y>
                    </Origin>
                </Item>
                <Item xsi:type="TextureItem" Name="Texture_0016" Visible="true">
                    <Position>
                        <X>1032</X>
                        <Y>-364</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>
                    <texture_filename>..\..\..\..\..\SamplesXNAContent\textures\texture6.png</texture_filename>
                    <asset_name>..\..\..\..\..\SamplesXNAContent\textures\texture6</asset_name>
                    <Origin>
                        <X>128</X>
                        <Y>128</Y>
                    </Origin>
                </Item>
                <Item xsi:type="TextureItem" Name="Texture_0017" Visible="true">
                    <Position>
                        <X>97</X>
                        <Y>-119</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>
                    <texture_filename>..\..\..\..\..\SamplesXNAContent\textures\texture3.png</texture_filename>
                    <asset_name>..\..\..\..\..\SamplesXNAContent\textures\texture3</asset_name>
                    <Origin>
                        <X>128</X>
                        <Y>128</Y>
                    </Origin>
                </Item>
                <Item xsi:type="TextureItem" Name="Texture_0018" Visible="true">
                    <Position>
                        <X>-1557</X>
                        <Y>50</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>
                    <texture_filename>..\..\..\..\..\SamplesXNAContent\textures\texture9.png</texture_filename>
                    <asset_name>..\..\..\..\..\SamplesXNAContent\textures\texture9</asset_name>
                    <Origin>
                        <X>128</X>
                        <Y>128</Y>
                    </Origin>
                </Item>
                <Item xsi:type="TextureItem" Name="Texture_0019" Visible="true">
                    <Position>
                        <X>-1307</X>
                        <Y>409</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>
                    <texture_filename>..\..\..\..\..\SamplesXNAContent\textures\texture9.png</texture_filename>
                    <asset_name>..\..\..\..\..\SamplesXNAContent\textures\texture9</asset_name>
                    <Origin>
                        <X>128</X>
                        <Y>128</Y>
                    </Origin>
                </Item>
            </Items>
            <ScrollSpeed>
                <X>1</X>
                <Y>1</Y>
            </ScrollSpeed>
        </Layer>
    </Layers>
    <CustomProperties />
    <EditorRelated>
        <NextItemNumber>19</NextItemNumber>
        <ContentRootFolder>C:\Programming\Farseer\Samples XNA\Samples XNA\bin\x86\Debug\Content</ContentRootFolder>
        <CameraPosition>
            <X>0</X>
            <Y>0</Y>
        </CameraPosition>
        <Version>1.3.0.0</Version>
    </EditorRelated>
</Level>

The issue is that upon calling this:

Level.FromFile which calls this code in the Leve.cs

  
 public static Level FromFile(string filename, ContentManager cm)
        {
            FileStream stream = File.Open(filename, FileMode.Open);
            XmlSerializer serializer = new XmlSerializer(typeof(Level));
            Level level = (Level)serializer.Deserialize(stream);
            stream.Close();

            foreach (Layer layer in level.Layers)
            {
                foreach (Item item in layer.Items)
                {
                    item.CustomProperties.RestoreItemAssociations(level);
                    item.load(cm);
                }
            }

            return level;
        }

I can inspect the Level level file after its loaded and see that the asset_name and texture_filename are null. And its only loading or trying to load the not seeing the rest? almost like the deserialization of the XML file
 is silently failing. Anyone can nudge me a help here? Its a simple level not sure what im doing wrong. I will say the rectangle items load fine though.


 

Jul 18, 2011 at 4:00 PM

Answering this, but I think the:

  <Scale>
                        <X>1</X>
                        <Y>1</Y>
                    </Scale>

is bad and it expects the

<Scale> somevalue </Scale>

so something has changed and I probably just missed it int he change notes.