help with object instantiation and array classes
I am having problems trying to build and debug my program. Here is what I have that causes me errors:
class NpcData
{
public int X; // actual X coordinate
public int Y; // actual Y coordinate
public byte pathMovement;
public byte pathMarker;
public float frameDelay;
public string[] speech = new string[4];
public string name;
public Texture2D visual;
}
And in my main() function, I declare it as this:
NpcData[] player = new NpcData[2];
However, in my other classes and methods, the first instance my application executes a command like:
player[0].name = "my Name";
Results in an error stating: Object reference not set to an instance of an object.
Tips: use the "new" keyword to create an object instance.
Is there something I am missing? I am using XNA 2.0 if that helps any.
Thanks