鉴于很多游戏素材都是这样的
所以这个类需要改进一下。。。。添加一个构造函数
SingleAnimation::SingleAnimation(const QString &FileName, const QPoint PosCount
, const QPoint PosIndex, const int &PlaySpeed)
:m_Index(0)
{
QPixmap *Pixmap = new QPixmap(FileName);
int &&WidthCount = PosCount.x();
int &&HeightCount = PosCount.y();
int &&Width = Pixmap->width() / WidthCount;
int &&Height = Pixmap->height() / HeightCount;
int &&IndexX = PosIndex.x();
int &&IndexY = PosIndex.y();
if(IndexX)
{
for(int y=0; y<HeightCount; y++)
{
m_PixmapList << Pixmap->copy(IndexX*Width,y*Height,Width,Height);
}
}
else
{
for(int x=0; x<WidthCount; x++)
{
m_PixmapList << Pixmap->copy(x*Width,Height*IndexY,Width,Height);
}
}
m_PlaySpeed = PlaySpeed;
}
嗯,这是为了把得到的图片进行分割,然后插入到播放列表
来我们试试~
for(int i=0;i<4;i++)
{
SingleAnimation *Anima = new SingleAnimation(u8"E:/素材/QQ堂-素材/Done_body13001_walk.png",QPoint(4,4),QPoint(0,i),150);
Scene->addItem(Anima);
Anima->setloop(true);
Anima->start();
Anima->setPos(Anima->getSize().width()*i+10,0);
}