0

このチュートリアルを試しましたが、複数のエラー メッセージが表示されます。

http://what-when-how.com/xna-game-studio-4-0-programmingdeveloping-for-windows-phone-7-and-xbox-360/2d-avatars-using-render-targets-xna- game-studio-4-0-プログラミング/

2Dアバターを描きたいだけです。

名前「world」は現在のコンテキストに存在しません
名前「view」は現在のコンテキストに存在しませ
ん 名前「projection」は現在のコンテキストに存在しません 名前「avatarRenderer」は現在のコンテキストに存在しません 名前「avatarAnimation」は現在のコンテキストに存在しません
エラーを修正するにはどうすればよいですか?

public class Game1 : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    RenderTarget2D renderTarget;

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
    }

    protected override void Initialize()
    {
        base.Initialize();
    }

    protected override void LoadContent()
    {  
        spriteBatch = new SpriteBatch(GraphicsDevice);
        renderTarget = new RenderTarget2D(GraphicsDevice, 512, 512, false, SurfaceFormat.Color, DepthFormat.Depth16);
        projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 1, 0.01f, 200.0f);

    }

    protected override void Update(GameTime gameTime)
    {

        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.SetRenderTarget(renderTarget);
        GraphicsDevice.Clear(Color.Transparent);
        avatarRenderer.World = world;
        avatarRenderer.View = view;
        avatarRenderer.Projection = projection;
        avatarRenderer.Draw(avatarAnimation);
        GraphicsDevice.SetRenderTarget(null);
        GraphicsDevice.Clear(Color.CornflowerBlue);

        spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
        spriteBatch.Draw(renderTarget, Vector2.Zero, Color.White);
        spriteBatch.End();

        base.Draw(gameTime);
    }
}
4

1 に答える 1

3

このチュートリアルは、すでにアバターを描画している基本的なチュートリアルに追加されることになっています。たとえば、これ

worldviewおよびprojectionは、使用する変換行列です。は、avatarRendererから取得できるレンダラーですAvatarDescription

于 2012-12-18T14:26:27.060 に答える