Hey there. I just picked up C# to learn game programming with XNA, but I also have some experience in Java.
Here's my code, in essence:
public class A
{
public Rectangle getRectangle()
{
return [some rectangle];
}
public bool collision(A other)
{
Rectangle rect1 = getRectangle();
Rectangle rect2 = other.getRectangle();
return rect1.Intersects(rect2);
}
}
public class B : A
{
public Rectangle getRectangle()
{
return [some other rectangle];
}
}
The problem arises when I try something like this:
A a;
B b;
if(a.collision(b))
...
Where B's version of get rectangle is never actually called, as far as I can tell. I tried a solution like the one suggested here but the message I get is basically "B.getRectangle() hides inherited member A.getRectangle(). Use the new keyword if this was intended."
I appreciate in advance any help I receive. I'm thinking my past java experience is getting in the way of understanding how C# is different. I guess if anyone just knows of a good link that explains the differences between C# and java or just how C# works in this respect that could suffice.
Cheers.