c#中的精灵表动画

本文关键字:动画 精灵 | 更新日期: 2023-09-27 18:10:41

这是一个来自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);
}

c#中的精灵表动画

您应该下载带有源代码的.zip文件,我相信您正在尝试遵循该教程。首先,AnimatedTexture是一个未定义的自定义类。打开AnimatedSprite.sln,从微软的示例代码中获得所需的内容。

在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
    }