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
FroglegPosted Mar 11, 2011, 2:09 AM
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
FroglegPosted Mar 11, 2011, 4:18 AM
Need to think about that
Steve TsikiPosted Mar 11, 2011, 3:32 AM
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???
FroglegPosted Mar 11, 2011, 12:59 AM
One thing, you had farseer classes included in your project when all you had to do was reference farseerphysic.dll
Steve TsikiPosted Mar 9, 2011, 5:27 AM
Thanks for responding.
FroglegPosted Mar 9, 2011, 4:05 AM
Make sure you are not creating multiple objects on top of each other
Steve TsikiPosted Mar 8, 2011, 3:36 PM
FroglegPosted Mar 8, 2011, 3:16 PM
Steve TsikiPosted Mar 8, 2011, 10:51 AM