-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnormalball.cpp
39 lines (33 loc) · 861 Bytes
/
normalball.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
#include "normalball.h"
#include<QPainter>
#include<QDebug>
const QImage NormalBall::outlook(":/Ball/image/ball/normalBall.png");
NormalBall::NormalBall(QGraphicsItem* parent):
AbstractBall(5,parent),
collidingOutLookActiveTime(0)
{
}
NormalBall::~NormalBall()
{
}
QRectF NormalBall::boundingRect() const
{
return QRectF(-5,-5,10,10);
}
void NormalBall::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
static QBrush brush(outlook.scaled(this->boundingRect().size().toSize()));
Q_UNUSED(option)
Q_UNUSED(widget)
if(collidingOutLookActiveTime>0)
{
painter->setOpacity(0.5);
collidingOutLookActiveTime--;
}
else if(collidingState==collided)
{
collidingOutLookActiveTime=20;
}
painter->setBrushOrigin(this->boundingRect().topLeft());
painter->fillRect(this->boundingRect(),brush);
}