開発中のXNA-Silverlightプロジェクトがあり、XMLコンテンツを追加しようとしています。私は画像を持っていた XNA-Silverlight WP7プロジェクトのXMLコンテンツを逆シリアル化できません
参照XNAゲームライブラリ - - コンテンツプロジェクト
- コンテンツプロジェクト
- XNAゲームライブラリ:この前に、私は次のセットアップを持っていましたコンテンツプロジェクトを作成し、Silverlightコードからコンパイルしてロードすることができます。今度はコンテンツプロジェクトにXMLコンテンツを追加しようとしていますが、それを記述するゲームライブラリにコードを記述しようとしていますが、次のエラーが発生するため、何か間違っている必要があります。中間XMLをデシリアライズする際にエラーが発生しました。それから私は、XNAに以下のクラスを持っている
<?xml version="1.0" encoding="utf-8"?> <XnaContent> <Asset Type="CrystalLib.Map"> <TileSetFile>grassland</TileSetFile> <Dimensions>500 250</Dimensions> <Tiles> ... Lots of integers (500 x 250) </Tiles> </Asset> </XnaContent>
:私はマップと呼ばれるフォルダがあり、その下に、私は次のXMLファイルを持っているコンテンツプロジェクトでタイプ「CrystalLib.Map」を
を見つけることができませんゲームプロジェクト(Map.cs):
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Content; namespace CrystalLib { /// Represents the data stored in a map file class Map { /// The name of tile set file private string tileSetFile; /// The name of tile set file public string TileSetFile { get { return tileSetFile; } set { tileSetFile = value; } } /// The dimensions of the map, in tiles. private Point dimensions; /// The dimensions of the map, in tiles. public Point Dimensions { get { return dimensions; } set { dimensions = value; } } /// Spatial array for the tiles for this map. private int[] tiles; /// Spatial array for the tiles for this map. public int[] Tiles { get { return tiles; } set { tiles = value; } } /// Retrieves the base layer value for the given map position. public int GetTile(int x, int y) { return tiles[y * dimensions.X + x]; } /// Read a Map object from the content pipeline. public class MapReader : ContentTypeReader<Map> { protected override Map Read(ContentReader input, Map existingInstance) { Map map = existingInstance; if (map == null) { map = new Map(); } map.TileSetFile = input.ReadString(); map.Dimensions = input.ReadObject<Point>(); map.Tiles = input.ReadObject<int[]>(); return map; } } } }
他に何が必要ですか?
XMLファイルはコンテンツプロジェクトの一部ですか?もしそうなら、Content ImporterとContent Processorには何が設定されていますか? –