-1

I'm making a Level.cs class that should take a background image (texture2d) as a parameter for the Level class constructor. But it wont accept the variable 'back'.. What do I do?

    public Level(Texture2D back ,ContentManager content, EventHandler ScreenEvent, Microsoft.Xna.Framework.Game game) : base(ScreenEvent)
    {
        background = content.Load<Texture2D>(back);
        backgroundVector = new Vector2(-1150, 0);
        velocity = 5.0f;
        ground = 508;
        graphics = new GraphicsDeviceManager(game);   
    }

Best regards Danny.

Danny
  • 1

1 Answers1

3

You are trying to load a texture from a texture?

You could either rename the "Texture2D" to string

 public Level(String back ,ContentManager content, EventHandler ScreenEvent, Microsoft.Xna.Framework.Game game) : base(ScreenEvent)
{
    background = content.Load<Texture2D>(back);
    backgroundVector = new Vector2(-1150, 0);
    velocity = 5.0f;
    ground = 508;
    graphics = new GraphicsDeviceManager(game);   
}

or just do

 public Level(Texture2D back ,ContentManager content, EventHandler ScreenEvent, Microsoft.Xna.Framework.Game game) : base(ScreenEvent)
{
    background = back;
    backgroundVector = new Vector2(-1150, 0);
    velocity = 5.0f;
    ground = 508;
    graphics = new GraphicsDeviceManager(game);   
}
Rasmus Søborg
  • 3,597
  • 4
  • 29
  • 46