forked from kn0w0n3/Super_Mario
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmushroomquestbox.cpp
42 lines (30 loc) · 917 Bytes
/
mushroomquestbox.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
41
42
/*
* Author: equati0n
* Date: December 2016
*/
#include "mushroomquestbox.h"
#include <QPainter>
MushroomQuestBox::MushroomQuestBox(int length,QGraphicsItem *parent) : QGraphicsItem(parent) ,mCurrentFrame(), mLength(length) {
setFlag(ItemClipsToShape);
mPixmap = QPixmap(":images/questbox.png");
}
void MushroomQuestBox::nextFrame(){
mCurrentFrame += 50;
if (mCurrentFrame >= 800 ){
mCurrentFrame = 0;
}
}
QRectF MushroomQuestBox::boundingRect() const{
return QRectF(0,0,48* mLength,48);
}
void MushroomQuestBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget){
Q_UNUSED(widget);
Q_UNUSED(option);
for(int i = 0; i < 48*mLength; ++i){
painter->drawPixmap(i*48,0, mPixmap, mCurrentFrame, 0,48, 48);
}
setTransformOriginPoint(boundingRect().center());
}
int MushroomQuestBox::type() const{
return Type;
}