我是qt创建的新手,我想使用SpriteSheet Animation

我已使用本文Click Here 中的以下代码

并且出现以下错误Please click here to see the image

    class Sprite
{
public:

    Sprite();

    void draw( QPainter* painter);

    QPoint pos() const;

    void nextFrame();

private:

    QPixmap* mSpriteImage;
    int mCurrentFrame;
    QPoint mPos;
    int mXDir;

};

Sprite::Sprite():mPos(0,0),mCurrentFrame(0)
{
    mSpriteImage = new QPixmap(":dragon.png");
}

void Sprite::draw( QPainter* painter)
{
    painter->drawPixmap ( mPos.x(),mPos.y(), *mSpriteImage,
                                   mCurrentFrame, 0, 100,100 );
}

QPoint Sprite::pos() const
{
    return mPos;
}

void Sprite::nextFrame()
{
    //following variable keeps track which
    //frame to show from sprite sheet
    mCurrentFrame += 100;
    if (mCurrentFrame >= 500 )
        mCurrentFrame = 0;
    mPos.setX( mPos.x() + 10 );
}

最佳答案

在文件中包含QPixmap应该没问题

关于c++ - 如何在Qt Creator中使用Sprite Sheet Animation?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34226893/

10-11 22:55
查看更多