I have XNA game and it contains these classes
public partial class Bird : Microsoft.Xna.Framework.GameComponent
{
private Vector2 velocity;
private Vector2 position;
..........................
public Vector2 Velocity
{
get { return velocity; }
set { velocity = value; }
}
public Vector2 Position
{
get { return position; }
set { position = value; }
}
}
public class BigRedBird : Microsoft.Xna.Framework.GameComponent,Bird
{
public BigRedBird(Game game ,Rectangle area,Texture2D image)
: base(game)
{
// TODO: Construct any child components here
}
.....................
}
How can I access Position and velocity from Bird Class and use it in BigRedBird Class in the
constructor.
Thanks
To start with you are inheriting from two classes which would be illegal.
As Bird already inherits from GameComponent its not a problem that you don’t mention it in BigRedBird it’s already inherited through bird!
As BigRedBird inherits from Bird it will have all its properties so you just need to do