I have four classes:
PointMass, which inherits from PropPhysics, which inherits from Entity (PropPhysics and Entity are both abstract classes), and World which has a List<Entity> called Entities.
Here, I'm trying to add a PointMass to a World's List<Entity>.
Strangely, whenever I try to add a new, globally defined, or even existing PointMass (within the method's scope), I get a "NullReferenceException was unhandled" error.
I check whether, or not, the PointMass "pMass" is null, but it is not, and it raises the same error.
I even display a message box whenever a PointMass is constructed, but it still raises the same error.
No luck was found from other research.
private void Display_Click(object sender, EventArgs e)
{
p.PositionX = 0;
p.PositionY = 0;
p.Mass = 5;
PointMass pMass = new PointMass();
if (pMass==null)
{
MessageBox.Show("error: Mass is null");
}
MyWorld.Entities.Add(new PointMass());
MyWorld.Entities.Add(pMass);
MyWorld.Entities.Add(p);
}