I'm coming up with one error in my build, and it is stating that I need to create a new instance of the EmitterLocationEmitterLocation from the particleEngineparticleEngine. When I hover over particleEngine.EmitterLocation = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);) particleEngine.EmitterLocation = new Vector2(Mouse.GetState().X, Mouse.GetState().Y); it states that particleEngineparticleEngine is returning a nullnull value. What could be causing this?
/// <summary>
/// Base class for screens that contain a menu of options. The user can
/// move up and down to select an entry, or cancel to back out of the screen.
/// </summary>
abstract class MenuScreen : GameScreen
ParticleEngine particleEngine;
public void LoadContent(ContentManager content)
{
if (content == null)
{
content = new ContentManager(ScreenManager.Game.Services, "Content");
}
base.LoadContent();
List<Texture2D> textures = new List<Texture2D>();
textures.Add(content.Load<Texture2D>(@"gfx/circle"));
textures.Add(content.Load<Texture2D>(@"gfx/star"));
textures.Add(content.Load<Texture2D>(@"gfx/diamond"));
particleEngine = new ParticleEngine(textures, new Vector2(400, 240));
}
enter code here public override void Update(GameTime gameTime, bool otherScreenHasFocus,
bool coveredByOtherScreen)
{
base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
// Update each nested MenuEntry object.
for (int i = 0; i < menuEntries.Count; i++)
{
bool isSelected = IsActive && (i == selectedEntry);
menuEntries[i].Update(this, isSelected, gameTime);
}
particleEngine.EmitterLocation = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);
particleEngine.Update();
}
public override void Draw(GameTime gameTime)
{
// make sure our entries are in the right place before we draw them
UpdateMenuEntryLocations();
GraphicsDevice graphics = ScreenManager.GraphicsDevice;
SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
SpriteFont font = ScreenManager.Font;
spriteBatch.Begin();
.................// Draw stuff logic
.........................
spriteBatch.End();
particleEngine.Draw(spriteBatch);
}