forked from kn0w0n3/Super_Mario
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotebox.cpp
44 lines (32 loc) · 863 Bytes
/
notebox.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
43
44
/*
* Author: equati0n
* Date: December 2016
*/
#include "notebox.h"
#include <QPainter>
NoteBox::NoteBox(int length,QGraphicsItem *parent): QGraphicsItem(parent)
,mCurrentFrame(), mLength(length)
{
setFlag(ItemClipsToShape);
mPixmap10 = QPixmap(":images/notebox.png");
}
void NoteBox::nextFrame(){
mCurrentFrame += 65;
if (mCurrentFrame >= 518 ) {
mCurrentFrame = 0;
}
}
QRectF NoteBox::boundingRect() const {
return QRectF(0,0,63* mLength,63);
}
void NoteBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
Q_UNUSED(widget);
Q_UNUSED(option);
for(int i = 0; i < 63*mLength; ++i) {
painter->drawPixmap(i*63,0, mPixmap10, mCurrentFrame, 0,63, 63);
}
setTransformOriginPoint(boundingRect().center());
}
int NoteBox::type() const {
return Type;
}