Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 2D头像的困难_C#_Xna - Fatal编程技术网

C# 2D头像的困难

C# 2D头像的困难,c#,xna,C#,Xna,我尝试了本教程,但收到多条错误消息 我只想画一个2D头像 “世界”名称在当前上下文中不存在 当前上下文中不存在名称“视图” 当前上下文中不存在名称“projection” 当前上下文中不存在名称“AvatarRender” 当前上下文中不存在名称“avatarAnimation” 如何修复错误 public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBat

我尝试了本教程,但收到多条错误消息

我只想画一个2D头像

“世界”名称在当前上下文中不存在
当前上下文中不存在名称“视图”
当前上下文中不存在名称“projection” 当前上下文中不存在名称“AvatarRender” 当前上下文中不存在名称“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);
    }
}

本教程应该添加到已经绘制化身的基础教程中。例如


世界
视图
投影
是要使用的变换矩阵。而
avatarenderer
是可以从
AvatarDescription

检索的渲染器。本教程应该添加到已经绘制了化身的基本教程中。例如

世界
视图
投影
是要使用的变换矩阵。而
avatarenderer
是可以从
AvatarDescription
检索的渲染器