I got it when trying to initialize my array of sprites
(( the only one trowing me null is the sprite2D[] AllianceCharacters
declaration:
sprite2D[] AllianceCharacters;
static string Cardspath = Directory.GetCurrentDirectory() + "\\Content\\Cards";
string[] ActionBar = Directory.GetFiles(Cardspath + "\\ActionBar\\");
string[] Equips = Directory.GetFiles(Cardspath + "\\ActionBar\\Equips");
string[] CharactersAlliance = Directory.GetFiles(Cardspath + "\\Characters\\Alliance\\");
string[] CharactersHorde = Directory.GetFiles(Cardspath + "\\Characters\\Horde\\");
string[] CharactersMonster = Directory.GetFiles(Cardspath + "\\Characters\\Monster\\");
initialization:
for (int i = 0; i < CharactersAlliance.Length; i++)
{
AllianceCharacters[i] = new sprite2D(Content.Load<Texture2D>(Cardspath + "\\Characters\\Alliance\\" + CharactersAlliance[i]));
AllianceCharacters[i].name = CharactersAlliance[i];
}
//This is called at the beginning::
void FixNames()
{
int x, y, z, a, h, m;
y = Equips.Length;
z = ActionBar.Length;
a = CharactersAlliance.Length;
h = CharactersHorde.Length;
m = CharactersMonster.Length;
char[] xnb = { 'b', 'n', 'x', '.' };
for (x = 0; x < y; x++)
{
Equips[x] = Path.GetFileName(Equips[x]);
Equips[x] = Equips[x].TrimEnd(xnb);
}
for (x = 0; x < z; x++)
{
ActionBar[x] = Path.GetFileName(ActionBar[x]);
ActionBar[x] = ActionBar[x].TrimEnd(xnb);
}
for (x = 0; x < a; x++)
{
CharactersAlliance[x] = Path.GetFileName(CharactersAlliance[x]);
CharactersAlliance[x] = CharactersAlliance[x].TrimEnd(xnb);
}
for (x = 0; x < h; x++)
{
CharactersHorde[x] = Path.GetFileName(CharactersHorde[x]);
CharactersHorde[x] = CharactersHorde[x].TrimEnd(xnb);
}
for (x = 0; x < m; x++)
{
CharactersMonster[x] = Path.GetFileName(CharactersMonster[x]);
CharactersMonster[x] = CharactersMonster[x].TrimEnd(xnb);
}
}
any idea on what could be making it fail ?