C#中的Spritesheet动画

时间:2015-09-01 17:03:28

标签: c# visual-studio sprite-sheet

这是我正在使用的MSDN教程,问题是我无法取得任何进展,因为不知道是什么取代了省略号,因为我尝试过的所有内容都会返回错误。

private AnimatedTexture SpriteTexture;
private const float Rotation = 0;
private const float Scale = 2.0f;
private const float Depth = 0.5f;
public Game1()
{
    ... //this is where I am stuck
    SpriteTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth);

    // Set device frame rate to 30 fps.
    TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0);
}

1 个答案:

答案 0 :(得分:0)

download the .zip with source code应该the tutorial I believe you're trying to follow。首先,AnimatedTexture是未定义的自定义类。打开AnimatedSprite.sln以从Microsoft的示例代码中获取所需内容。

在zip中是Game1类的其余部分,您引用的构造函数是:

    private AnimatedTexture SpriteTexture;
    private const float Rotation = 0;
    private const float Scale = 2.0f;
    private const float Depth = 0.5f;
    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        SpriteTexture = new AnimatedTexture(Vector2.Zero,
            Rotation, Scale, Depth);
#if ZUNE
        // Frame rate is 30 fps by default for Zune.
        TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0);
#endif
    }