-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogoanimation.cpp
40 lines (28 loc) · 928 Bytes
/
logoanimation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "logoanimation.h"
#include <QPainter>
LogoAnimation::LogoAnimation(QGraphicsItem *parent): QGraphicsItem(parent) ,mCurrentFrame7() {
setFlag(ItemClipsToShape);
mPixmap7 = QPixmap(":images/spritesheet.png");
//QTimer *timer = new QTimer(this);
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(nextFrame()));
timer->start(100);
}
void LogoAnimation::nextFrame(){
mCurrentFrame7 += 342;
if (mCurrentFrame7 >= 9918 ) {
mCurrentFrame7 = 0;
}
}
QRectF LogoAnimation::boundingRect() const {
return QRectF(0,0,114,109);
}
void LogoAnimation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
painter->drawPixmap(0,0, mPixmap7, mCurrentFrame7, 0,114, 109);
setTransformOriginPoint(boundingRect().center());
Q_UNUSED(widget);
Q_UNUSED(option);
}
int LogoAnimation::type() const {
return Type;
}