-
Notifications
You must be signed in to change notification settings - Fork 1
/
gameobject.h
52 lines (42 loc) · 1.13 KB
/
gameobject.h
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
50
51
52
#ifndef GAMEOBJECT_H
#define GAMEOBJECT_H
#include <QQuickItem>
class GameObject : public QQuickItem
{
Q_OBJECT
public:
GameObject() = default;
virtual ~GameObject() = default;
void setPosition(const QPoint &pos) noexcept {
setProperty("x", pos.x());
setProperty("y", pos.y());
}
QPoint getPosition() const noexcept {
return QPoint(property("x").toInt(), property("y").toInt());
}
void setSize(QSize size) noexcept {
setProperty("width", size.width());
setProperty("height", size.height());
}
QSize getSize() const noexcept {
return QSize(property("width").toInt(), property("height").toInt());
}
QRect getRect() const noexcept {
return QRect(getPosition(), getSize());
}
void setActive(bool state) noexcept {
m_isActive.store(state);
}
bool isActive() const noexcept {
return m_isActive.load();
}
bool isDesroyable() const noexcept {
return m_bIsDestroyable;
}
protected:
bool m_bIsDestroyable = true;
std::atomic<bool> m_isActive;
signals:
public slots:
};
#endif // GAMEOBJECT_H