public Block[,] Layer2ID;
Layer2ID[X, Y].Draw(spriteBatch, new Vector2(X * 32, Y * 32)); //Child of Block, let's call it Wall
Layer2ID is populated with an array of Block’s children, but is of the Block type, thus, when I call the draw function, it uses Block’s draw function instead of the child’s. Why is this, and how do I fix it?
Thank you.
From your description, it sounds like you have something like this
The method inside Wall is hiding the method in Block, it is not virtual. You may even have a
newmodifier on the method inside Wall, as the compiler will generally warn you of the hiding method and recommend the new keyword to mark your intent. This hiding method is only called via the Wall reference, not via a reference of Block.Unlike Java, for example, methods in C# are not virtual by default, you have to mark them as such. To use your methods polymorphically, apply the virtual and override modifiers to the methods in the base and derived classes, respectively.
With this in place, the overriding method will be invoked.