-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtower_position.cpp
More file actions
49 lines (40 loc) · 1.01 KB
/
Copy pathtower_position.cpp
File metadata and controls
49 lines (40 loc) · 1.01 KB
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
45
46
47
48
49
#include "tower_position.h"
#include <QSize>
#include <QPainter>
#include <QPixmap>
const QSize TowerPosition::m_fixedSize(35,35);//设置图片的大小,需要修改
TowerPosition::TowerPosition(QPoint pos, QString path):
m_pos(pos),
m_path(path),
m_hasTower(false)
{
}
bool TowerPosition::hasTower()
{
return m_hasTower;
}
void TowerPosition::setHasTower(bool hasTower)
{
m_hasTower=hasTower;
}
QPoint TowerPosition::getCenterPos()
{
QPoint tmp;
tmp.setX(m_pos.x()+m_fixedSize.width()/2);
tmp.setY(m_pos.y()+m_fixedSize.height()/2);
return tmp;
}
QPoint TowerPosition::getPos()
{
return m_pos;
}
bool TowerPosition::ContainPos(QPoint pos)
{
bool xInHere=pos.x()>m_pos.x() && pos.x()<m_pos.x()+m_fixedSize.width();
bool yInHere=pos.y()>m_pos.y() && pos.y()<m_pos.y()+m_fixedSize.height();
return xInHere && yInHere;
}
void TowerPosition::draw(QPainter *painter) const
{
painter->drawPixmap(m_pos.x(),m_pos.y(),m_path);
}