我目前正在尝试将我正在从XNA工作的游戏移植到Monogame,但是我在使用内容管道进行合作时遇到了一些麻烦.我的游戏使用许多XML文件作为XNB资产来表示游戏中的对象,我按照这里的说明创建了这些对象.但是,尝试将其逐字转换为Monogame会产生以下错误:
MonoGame.Framework.dll中发生未处理的"Microsoft.Xna.Framework.Content.ContentLoadException"类型异常
附加信息:无法将Parts\Window.xnb资产加载为非内容文件!
这是我用来定义XML文件内容的类:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace FileTypes
{
public class PartFile
{
public struct State
{
public Rectangle[] frames;
public int[] collision;
}
public Vector2 size;
public string image;
public string defaultState = "default";
public bool fillBG;
public int ticksPerFrame;
public Dictionary<string, State> states;
public string[] modules;
}
}
Run Code Online (Sandbox Code Playgroud)
这是项目中的一个XML文件:
<?xml version="1.0" encoding="utf-8" ?>
<XnaContent>
<Asset Type="FileTypes.PartFile">
<size>2 3</size>
<image>Computer</image>
<defaultState>default</defaultState>
<fillBG>false</fillBG>
<ticksPerFrame>7</ticksPerFrame> …Run Code Online (Sandbox Code Playgroud)