• Advertisement
Sign in to follow this  

Problem setting a segment deletion in XNA map editor

This topic is 2689 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok. Ive tried the texture = null function but it sends me an error within the Object reference not set to an instance of an object.

Here is a sample of my code were the problem occurs. See if you can help me out it will be greatly appreciated.

game1.cs codeing to see if the program will delete the sement once the right button is pressed
if(drawType == Draw_Select)
{
if (Cursor.RightButton == ButtonState.Pressed)
mapTexures = null;
}




map.cs logic < where the problem occurs

public void Draw(SpriteBatch spriteBatch, Texture2D[] mapsTex, Vector2 _Scroll)
{
Rectangle sRect = new Rectangle();
Rectangle dRect = new Rectangle();



spriteBatch.Begin();

for (int l = 0; l < 6; l++)
{
float scale = 1.0f;
Color color = Color.White;
// Background insider
if (l == 0)
{
color = Color.White;
scale = 0.05f;
}
// Back Section #2
if (l == 0)
{
color = Color.White;
scale = 1.0f;
}
//Back Section
if (l == 0)
{
color = Color.White;
scale = .80f;
}
// Mid Section
if (l == 0)
{
color = Color.White;
scale = 1.0f;
}
// Front Section
else if (l == 6)
{
color = Color.White;
scale = 0.85f;
}

scale *= 0.5f;

for (int i = 0; i < 120; i++)
{
if (mapSeg[l, i] != null)
{
sRect = segDef[mapSeg[l, i].GetDefInx()].GetSrcRect();
dRect.X = (int)(mapSeg[l, i].GetLoc().X - _Scroll.X * scale);
dRect.Y = (int)(mapSeg[l, i].GetLoc().Y - _Scroll.Y * scale);
dRect.Width = (int)((float)sRect.Width * scale);
dRect.Height = (int)((float)sRect.Height * scale);

Problem occurs here--> spriteBatch.Draw(mapsTex[segDef[mapSeg[l,i].GetDefInx()].GetSrcIdx()],
dRect,
sRect,
color);

}

}
}

spriteBatch.End();

again it reads Object reference not set to an instance of an object.

Please help

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement