-1

Levelクラスコンストラクターのパラメーターとして背景画像(texture2d)を取得するLevel.csクラスを作成しています。しかし、変数'back'は受け入れられません。どうすればよいですか。

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

よろしくダニー。

4

1 に答える 1

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);   
}
于 2012-05-08T19:08:26.200 に答える