Repository navigation
Expand file tree
/
Copy pathmainscene.cpp
More file actions
67 lines (55 loc) · 1.6 KB
/
Copy pathmainscene.cpp
File metadata and controls
67 lines (55 loc) · 1.6 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "mainscene.h"
#include "ui_mainscene.h"
#include <QPainter>
#include "mybutton.h"
#include<QDebug>
#include <QTimer>
Mainscene::Mainscene(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::Mainscene)
{
ui->setupUi(this);
//配置主场景
this->setFixedSize(320,588);
//设置图标i
this->setWindowIcon(QIcon(":/res/Coin0001.png"));
//设置标题
this->setWindowTitle("翻金币");
//实现退出
connect(ui->actionquit,&QAction::triggered,[=](){this->close();});
//开始按钮
mybutton*startbtn = new mybutton(":/res/MenuSceneStartButton.png");
startbtn->setParent(this);
startbtn->move(this->width()*0.5-startbtn->width()*0.5,this->height()*0.7);
choosescene = new ChooseLevelscene;
connect(startbtn,&QPushButton::clicked,[=](){
startbtn->zoom1();
startbtn->zoom2();
//延时
QTimer::singleShot(500,this,[=](){
this->hide();
//进入选择
choosescene->show();
});
});
//connect(choosescene,&ChooseLevelscene::choosesceneback,[=](){this->show();});
}
void Mainscene::paintEvent(QPaintEvent*)
{
QPainter painter(this);
//创建QPixmap对象
QPixmap pix;
//加载图片
pix.load(":/res/PlayLevelSceneBg.png");
//绘制背景图
painter.drawPixmap(0,0,this->width(),this->height(),pix);
//加载标题
pix.load(":/res/Title.png");
//缩放图片
pix = pix.scaled(pix.width()*0.5,pix.height()*0.5);
painter.drawPixmap(10,30,pix.width(),pix.height(),pix);
}
Mainscene::~Mainscene()
{
delete ui;
}