I am making a very basic 2d (top-down) "game". Therefore I use 2 forms. One for the UI (UIForm) and the other one for the visual part of the game (Form1, also the first form to be loaded). Also I have a class wich defines different animal species and provides properties like the size.
However, it seems like I cannot access the Species class from my Form1 since I have created UIForm (which has access to the species class).
This will give an IndexOutOfRange exception:
private Species species = new Species();
int i = this.species.size[1];
This is working though:
int i = UIForm.species.size[1];
Here I have made species public in UIForm for the sake of testing and used that to access the class Species. This works, so I could work around it, but how do I fix this? And why does this happen?
I was used to be able to access the species class from form1 before i had made the UIForm.
I'm sorry if I am too vague or if it's very obvious, but I am still a noob at this.
(B.T.W. There is no threading going on)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…