This repository has been archived on 2022-12-14. You can view files and clone it, but cannot push or open issues or pull requests.
WaveGGJ17/VaporWaveWars/button.hpp
2017-01-20 23:52:42 +01:00

30 lines
736 B
C++

#ifndef BUTTON_HPP
#define BUTTON_HPP
#include "commons.hpp"
class Button : public sf::Sprite{
public:
Button(std::string path);
//upon creating a button, its state is set to off by default, you must activate it maually after declaration
Button();
void turnOn();
void turnOff();
bool isOn();
int getClicks();
//buttons auto-detect if they are pressed, you just have to passa mouse-event to them
void handleMouseEvent(sf::Event& event);
void update(sf::Vector2f mousePosition);
protected:
int _xSize;
int _ySize;
sf::Texture _texture;
bool inside(sf::Vector2f position);
private:
int _clicks;
int _state;
void initTexture(std::string path);
};
#endif // BUTTON_HPP