I'm facing a problem in my code. I have created a class called Obstacles and in my main code I created this function:
public void o_value(Object o, EventArgs e) // Function to change bool and insert Object Obtacle
{
obstacle_pressed = true;
obstacles.Add(new Obstacle(new Rectangle(300, 300, 30, 60),Content.Load("Obstacles/default")));
}
Then in my Draw function I do as followed:
Then in my Draw function I do as followed:
if (obstacle_pressed == true)
{
foreach (Obstacle obstacle in obstacles)
{
obstacle.Draw(spriteBatch); // I have created a function Draw in Obstacles Class
}
}
But nothing is shown in my Game!
Could anyone please help?
Thanks
But nothing is shown in my Game!
Could anyone please help?
Thanks

FroglegRank #1,020 · 1.9K reputationPosted Mar 10, 2011, 9:09 PM EST
I think the obstacles list needs to be updated with new coordinates after moving
To check the list I put
if (obstacle_pressed == true)
{
foreach (Obstacle obs in obstacles)
{
if (obstacles.Count==5)
{//put breakpoint here
}
obs.Draw(spriteBatch);
}
}
in draw method
Steve Tsiki42 reputationPosted Mar 8, 2011, 5:51 AM EST
FroglegRank #1,020 · 1.9K reputationPosted Mar 8, 2011, 10:16 AM EST
Steve Tsiki42 reputationPosted Mar 8, 2011, 10:36 AM EST
FroglegRank #1,020 · 1.9K reputationPosted Mar 8, 2011, 11:05 PM EST
Make sure you are not creating multiple objects on top of each other
Steve Tsiki42 reputationPosted Mar 9, 2011, 12:27 AM EST
Thanks for responding.
FroglegRank #1,020 · 1.9K reputationPosted Mar 10, 2011, 7:59 PM EST
One thing, you had farseer classes included in your project when all you had to do was reference farseerphysic.dll
Steve Tsiki42 reputationPosted Mar 10, 2011, 10:32 PM EST
Yeah I understood the problem. So you suggest to reset the coordinates for the next obstacle to be pressed??? But how am I supposed to do so??? Should I create a list of each object's position???
FroglegRank #1,020 · 1.9K reputationPosted Mar 10, 2011, 11:18 PM EST
Need to think about that