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
FroglegPosted May 17, 2011, 5:22 PM
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();
Steve TsikiPosted May 17, 2011, 6:42 PM
FroglegPosted May 17, 2011, 6:12 PM
FroglegPosted May 17, 2011, 6:11 PM
mouse in game1.cs
obstacle.cs
background.cs
Steve TsikiPosted May 17, 2011, 5:55 PM
Steve TsikiPosted May 17, 2011, 5:13 PM
FroglegPosted May 17, 2011, 5:05 PM
Steve TsikiPosted May 17, 2011, 3:59 PM
FroglegPosted May 17, 2011, 3:44 PM
You can call it obstacle1 so and just increment 1 as you add objects
Steve TsikiPosted May 17, 2011, 3:16 PM
FroglegPosted May 17, 2011, 2:49 PM
Steve TsikiPosted May 17, 2011, 7:48 AM
FroglegPosted May 17, 2011, 6:32 AM
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 TsikiPosted May 17, 2011, 5:33 AM
FroglegPosted May 17, 2011, 5:23 AM