Hello to everyone,
I'm experiencing a very annoying matter in my game editor. I created a form and when the user adds an object to the editor the object is drawn. But the problem is that sometimes I press to add the object and is not drawn and other times it is drawn but the previous one is missing.... Could anyone give me a tip??
Here's my draw code :
GraphicsDevice.Clear(Color.Beige);
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);
// Draws all the objects
//?????????????????????????
if (avatar_pressed == true)
{
avatar.Draw(spriteBatch);
}
foreach (Obstacle obstacle in obstacles)
{
obstacle.Draw(spriteBatch);
}
foreach (Tiles tile in tiles)
{
tile.Draw(spriteBatch);
}
if (back_selected == true)
{
background.Draw(spriteBatch);
}
spriteBatch.End();
Loading

FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 1:22 PM EDT
If I use two draw obstacles either side of draw background - it works -very strange = "the obstacle virus"
GraphicsDevice.Clear(Color.Beige);
spriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.BackToFront, SaveStateMode.SaveState);
// Draws all the objects
//?????????????????????????
if (avatar_pressed == true)
{
avatar.Draw(spriteBatch);
}
foreach (Obstacle obstacle in obstacles)
{
obstacle.Draw(spriteBatch);
}
foreach (Tiles tile in tiles)
{
tile.Draw(spriteBatch);
}
if (back_selected == true)
{
background.Draw(spriteBatch);
}
foreach (Obstacle obstacle in obstacles)
{
obstacle.Draw(spriteBatch);
}
spriteBatch.End();
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 1:23 AM EDT
Steve Tsiki42 reputationPosted May 17, 2011, 1:33 AM EDT
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 2:32 AM EDT
foreach (Obstacle obsc in obstacles)
{
int i =0, k = 0;
i= obsc.ob_rec.X ;
k =obsc.ob_rec.Y ;
}
in
public void ok_obsbox(Object o, EventArgs e)
after obstacles.Add(obs);
and three objects had same rect coordinates
Thats after moving and right clicking them
Steve Tsiki42 reputationPosted May 17, 2011, 3:48 AM EDT
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 10:49 AM EDT
Steve Tsiki42 reputationPosted May 17, 2011, 11:16 AM EDT
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 11:44 AM EDT
You can call it obstacle1 so and just increment 1 as you add objects
Steve Tsiki42 reputationPosted May 17, 2011, 11:59 AM EDT
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 1:05 PM EDT
Steve Tsiki42 reputationPosted May 17, 2011, 1:13 PM EDT
Steve Tsiki42 reputationPosted May 17, 2011, 1:55 PM EDT
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 2:11 PM EDT
mouse in game1.cs
obstacle.cs
background.cs
FroglegRank #1,020 · 1.9K reputationPosted May 17, 2011, 2:12 PM EDT
Steve Tsiki42 reputationPosted May 17, 2011, 2:42 PM EDT