-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneMenu.cpp
More file actions
67 lines (52 loc) · 1.83 KB
/
SceneMenu.cpp
File metadata and controls
67 lines (52 loc) · 1.83 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
67
#include "SceneMenu.hpp"
#include "Game.hpp"
SceneMenu::SceneMenu(Game* g, sf::RenderWindow* w) : Scene(g,w),_menu(*w) {
sf::Vector2u targetResolution(640,360);
initView(sf::Vector2i(targetResolution));
sf::Vector2u displayResolution(_view.getSize());
_bg = new Background(displayResolution);
VLayout* layout = new VLayout;
layout->setSpace(5);
TextButton* resB;
resB = new TextButton(" Play Solo", Resources::pauseMenuFont);
resB->onClick = [this](const sf::Event&, Button&){ changeScene("Jump", 1); };
TextButton* resB2;
resB2 = new TextButton(" Play 1v1", Resources::pauseMenuFont);
resB2->onClick = [this](const sf::Event&, Button&){ changeScene("Jump", 2); };
TextButton* resB3;
resB3 = new TextButton(" Play Three", Resources::pauseMenuFont);
resB3->onClick = [this](const sf::Event&, Button&){ changeScene("Jump", 3); };
TextButton* resB4;
resB4 = new TextButton(" Play Four", Resources::pauseMenuFont);
resB4->onClick = [this](const sf::Event&, Button&){ changeScene("Jump", 4); };
TextButton* exitB;
exitB = new TextButton(" Exit", Resources::pauseMenuFont);
exitB->onClick = [this](const sf::Event&, Button&){ exit(0); };
layout->add(resB);
layout->add(resB2);
layout->add(resB3);
layout->add(resB4);
layout->add(exitB);
_menu.setLayout(layout);
}
SceneMenu::~SceneMenu() {
delete _bg;
}
void SceneMenu::processInput() {
sf::Event event;
while (_window->pollEvent(event)) {
_menu.processEvent(event);
}
}
void SceneMenu::update(float deltaTime) {
_bg->update(deltaTime);
}
void SceneMenu::render() {
render(_window);
}
void SceneMenu::render(sf::RenderTarget* target) {
_bg->draw(target);
target->setView(target->getDefaultView());
_menu.draw();
target->setView(_view);
}