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