【发布时间】:2015-08-26 19:52:58
【问题描述】:
我刚开始使用 Monogame,我正在尝试制作一个简单的精灵,后来它是一个按钮。我已经四处搜索并完成了几个教程,但我无法使其工作。我只是不断得到空白,蓝屏。这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
namespace Test_Game
{
class Main_Menu
{
//setting the variables
public Texture2D button1;
public Vector2 button1Pos;
public GraphicsDevice graphicsDevice;
GraphicsDeviceManager graphics;
public void initialize(Texture2D texture, Vector2 position, ContentManager Content)
{
//Getting the initialized stuff
button1 = Content.Load<Texture2D>("button_temp");
button1Pos.X = 30;
button1Pos.Y = 30;
}
public void Draw(SpriteBatch spriteBatch)
{
graphics.GraphicsDevice.Clear(Color.Black);
spriteBatch = new SpriteBatch(graphicsDevice);
//Just drawing the Sprite
spriteBatch.Begin();
spriteBatch.Draw(button1, new Rectangle(30, 30, 214, 101), Color.White);
spriteBatch.End();
}
}
}
希望你能找到答案。
【问题讨论】:
-
空白蓝屏 - 但在您的绘图中,您将其设置为黑色。你是从你的主“game1”类中调用你的draw方法吗?