Может ли кто-нибудь еще создать и скомпилировать эту программу ( Нажмите здесь) вплоть до первой "быстрой сборки" ..?(вплоть до того момента, когда они говорят: «Это было бы отличное время для быстрой сборки»)
Почему-то я продолжаю получать это исключение!
Я проверил все упомянутое в этом решении Stackoverflow: Нажмите здесь , но ни одна из них не решила мою проблему: (
мое изображение размещено в области контента.Он не находится в папке.
Пожалуйста, помогите!
Вот как выглядит мой код:
namespace myGame
{
public class Game1 : Microsoft.Xna.Framework.Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteBatch mBatch;
Texture2D mHealthBar;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
mBatch = new SpriteBatch(this.graphics.GraphicsDevice);
ContentManager aLoader = new ContentManager(this.Services);
**//ERROR occurs here!**
mHealthBar = aLoader.Load<Texture2D>("HealthBar") as Texture2D;
}
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
protected override void Update(GameTime gameTime)
{
// Allows the game to exit
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
// TODO: Add your update logic here
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
mBatch.Begin();
mBatch.Draw(mHealthBar, new Rectangle(this.Window.ClientBounds.Width / 2 - mHealthBar.Width / 2,
30, mHealthBar.Width, 44), new Rectangle(0, 45, mHealthBar.Width, 44), Color.Red);
//Draw the box around the health bar
mBatch.Draw(mHealthBar, new Rectangle(this.Window.ClientBounds.Width / 2 - mHealthBar.Width / 2,
30, mHealthBar.Width, 44), new Rectangle(0, 0, mHealthBar.Width, 44), Color.White);
mBatch.End();
base.Draw(gameTime);
}
}
}