I'm having an issue with C# and XNA for Windows phone. I've created a class called Item which is inside of the Game1 class in XNA. The problem I am experiencing is that after I create all of the items I cannot make changes to them, it does not throw an error but also the change does not take effect. So the code goes something like this:
public class Game1 : Microsoft.Xna.Framework.Game {
Item Loading;
Item[] Stuff = new Item[2];
public class Item {
public bool visible = true;
}
protected override void LoadContent() {
Loading = new Item();
Stuff[1] = new Item();
}
protected override void Update(GameTime gameTime) {
Loading.visible = false;
System.Diagnostics.Debug.WriteLine(Loading.visible); //prints true
Stuff[1].visible = false;
System.Diagnostics.Debug.WriteLine(Stuff[1].visible); //prints false
}
}
I don't understand why it is unable to change the variable, I have also tried doing this through an accessor method inside the class. I have basically duplicated code working for an array of Items, so that leaves me totally stumped.