2012-05-08 3 views
-1

레벨 클래스 생성자에 대한 매개 변수로 배경 이미지 (texture2d)를 가져야하는 Level.cs 클래스를 만들고 있습니다. 그러나 변수 'back'을 받아들이지 않을 것입니다. 어떻게해야합니까?클래스 생성자의 매개 변수로 Texture2D

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); 
    } 

대니.

답변

3

텍스처에서 텍스처를로드하려고합니까?

당신은 문자열로 "Texture2D를"이름을 변경하거나 할 수

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); 
} 

하거나 할

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); 
} 
관련 문제