-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.h
More file actions
45 lines (37 loc) · 940 Bytes
/
Copy pathButton.h
File metadata and controls
45 lines (37 loc) · 940 Bytes
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
//sfml class for dealing with buttons
#pragma once
#include <iostream>
#include <vector>
#include <ctime>
#include <sstream>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <SFML/window.hpp>
using namespace std;
using namespace sf;
enum button_states { BTN_IDLE = 0, BTN_HOVER, BTN_ACTIVE };
class Button
{
private:
bool pressed;
bool hover;
short unsigned buttonState; //0-idle, 1-hover, 2-active
Color idleColor;
Color hoverColor;
Color activeColor;
RectangleShape button;
Text text;
public:
//constructor/destructor
Button(float width, float height , float x, float y, Color idlecColor, Color hoverColor, Color activeColor, Font* font, string text);
~Button();
//accessors
bool isPressed() const;
const string getText() const;
//functions
void render(RenderTarget &target);
void update(Vector2f mousePos);
bool isClicked(Vector2f mousePos);
};