【发布时间】:2020-01-11 13:33:06
【问题描述】:
我只想在我的 c# monogame 主菜单中添加背景图像。我已经有一个带有按钮和一个工作游戏的主菜单。只是背景不见了。 这是我的代码的一部分:
public void LoadAssets()
{
background = ScreenManager.Texture("background");
[...] //unimportant stuff for this problem
}
public void Draw(GameTime gameTime)
{
SpriteBatch spriteBatch= new SpriteBatch();
spriteBatch.Begin();
spriteBatch.Draw(background, new Rectangle(0, 0, 800, 480), Color.White);
spriteBatch.End();
foreach (var button in mButtons)
{
button.Draw(ScreenManager.mSprites);
}
}
我收到以下错误 CS7036 C# 没有给出与“SpriteBatch.SpriteBatch(GraphicsDevice)”中所需的“graphicsDevice”形式参数相对应的参数。
我在内容中包含了图片。我不知道我的错误在哪里。 谢谢,帮忙!
【问题讨论】:
-
阅读文档 ..
SpriteBatch类没有无参数构造函数 -
是的,但我不知道应该添加哪个参数
-
我无法使用 GraphicsDevice。
-
阅读文档。这不需要对 SO 提出问题,这是非常基本的东西。查一些例子。另外你的意思是,你不能使用 GraphicsDevice ?
标签: c# graphics arguments monogame