forked from Sicatriz/CppGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.cpp
45 lines (36 loc) · 814 Bytes
/
play.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
#include "play.h"
#include "game.h"
using namespace insemi;
// play button sprite and position
Play::Play(QGraphicsItem* parent): QGraphicsPixmapItem(parent)
{
setPos(800,450);
//setPos(scene()->width()/2 - 200, scene()->height()/2 - 50);
setPixmap(QPixmap(":/gfx/gfx/StartPlay.png"));
setAcceptHoverEvents(true);
}
// button constructor
Play::~Play()
{
}
// click event
void Play::mousePressEvent(QGraphicsSceneMouseEvent *)
{
clicked();
}
// hover sprite
void Play::hoverEnterEvent(QGraphicsSceneHoverEvent *)
{
setPixmap(QPixmap(":/gfx/gfx/StartPlayHov.png"));
}
// leave sprite
void Play::hoverLeaveEvent(QGraphicsSceneHoverEvent *)
{
setPixmap(QPixmap(":/gfx/gfx/StartPlay.png"));
}
// click action
void Play::clicked()
{
Game* game = new Game(0);
game->show();
}