【发布时间】:2011-11-10 07:47:07
【问题描述】:
所以我有一个名为 ScrollingBackgroundTexture 的 Texture2D 子类。我想用它来加载带有Content.Load<> 的纹理,但我似乎无法让它工作。
这是我的子类中的代码(到目前为止,它只是一个构造函数):
class ScrollingBackgroundTexture : Texture2D {
public ScrollingBackgroundTexture(GraphicsDevice graphicsDevice, int width, int height) : base(graphicsDevice, width, height) { }
}
这是我的主要课程中给我带来麻烦的代码:
test = Content.Load<ScrollingBackgroundTexture>("near stars");
错误告诉我该文件包含Texture2D,但我正在尝试将其加载为ScrollingBackgroundTexture。
我也试过
test = (ScrollingBackgroundTexture)Content.Load<Texture2D>("near stars");
但这只是给了我另一个错误。
【问题讨论】: