diff options
| author | Samu Laaksonen <laaksonen.sj@gmail.com> | 2012-09-25 20:00:41 +0300 |
|---|---|---|
| committer | Samu Laaksonen <laaksonen.sj@gmail.com> | 2012-09-25 20:00:41 +0300 |
| commit | 685fe05def77b039221edf06c74af74915d536c5 (patch) | |
| tree | 9c1a14b8f68bc0f801bdec3edc447d04fdbf7a4c /src/MenuScene.cpp | |
| parent | 29eabac0670574efd384182c065f53d08c42a483 (diff) | |
| download | prism-685fe05def77b039221edf06c74af74915d536c5.tar.gz prism-685fe05def77b039221edf06c74af74915d536c5.zip | |
Initial code commit
Added some stuff for project base
- tiled sources
- few Qt based classes for gfx
Diffstat (limited to 'src/MenuScene.cpp')
| -rw-r--r-- | src/MenuScene.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/MenuScene.cpp b/src/MenuScene.cpp new file mode 100644 index 0000000..1deaa66 --- /dev/null +++ b/src/MenuScene.cpp @@ -0,0 +1,53 @@ +#include <QApplication> + +#include "ParallaxScrollerStatic.h" +#include "GraphicsButtonObject.h" +#include "GameView.h" + +#include "MenuScene.h" + +MenuScene::MenuScene(const QString &name, const QRectF &rect, GameView *parent) + : GameScene(name, parent) +{ + setSceneRect(rect); + + QString appDir = qApp->applicationDirPath(); + + m_background = new ParallaxScrollerStatic(this); + m_background->setLayerWidth(rect.width()); + m_background->addParallaxScrollItem(QString(appDir + "/gfx/bg/layer1.png"), QPointF(0,0), -2, 6); + m_background->addParallaxScrollItem(QString(appDir + "/gfx/bg/layer2.png"), QPointF(0,0), -1, 4); + + initializeScene(); +} + +MenuScene::~MenuScene() +{ + delete m_background; +} + +void MenuScene::updateLogic() +{ + advance(); + update(); +} + +void MenuScene::initializeScene() +{ + int yoff = 200; + + GraphicsButtonObject *btn1 = new GraphicsButtonObject("Play", 0, this); + btn1->setPos(260, yoff); + + GraphicsButtonObject *btn2 = new GraphicsButtonObject("Credits", 0, this); + btn2->setPos(260, btn1->pos().y() + btn1->boundingRect().bottom() + 20); + + GraphicsButtonObject *btn3 = new GraphicsButtonObject("Quit", 0, this); + btn3->setPos(260, btn2->pos().y() + btn2->boundingRect().bottom() + 20); + + connect(btn1, SIGNAL(clicked()), gameView(), SLOT(showLevelSelectionScene())); + connect(btn2, SIGNAL(clicked()), gameView(), SLOT(showCreditsScene())); + connect(btn3, SIGNAL(clicked()), qApp, SLOT(quit())); + + addTitle("Platformer"); +} |
