init
This commit is contained in:
parent
54f5313273
commit
b49080f675
83 changed files with 2083 additions and 0 deletions
33
Button.cpp
Normal file
33
Button.cpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by Benjamin on 1/25/2022.
|
||||
//
|
||||
|
||||
#include "Button.h"
|
||||
|
||||
Button::Button(const sf::Texture &texture, const std::function<void()> &command) : Sprite(texture) {
|
||||
this->command = command;
|
||||
}
|
||||
|
||||
Button::Button(const sf::Texture &texture, float x, float y, float scale, int origin, const std::function<void()> &command) : Sprite(texture, x, y, scale, origin) {
|
||||
this->command = command;
|
||||
}
|
||||
|
||||
void Button::click() {
|
||||
command();
|
||||
}
|
||||
|
||||
void Button::hover() {
|
||||
Sprite::hover();
|
||||
|
||||
sf::Vector2f pos = getPosition();
|
||||
setScale(getScale().x + 0.1, getScale().x + 0.1);
|
||||
setPosition(pos.x, pos.y);
|
||||
}
|
||||
|
||||
void Button::unHover() {
|
||||
Sprite::unHover();
|
||||
|
||||
sf::Vector2f pos = getPosition();
|
||||
setScale(getScale().x - 0.1, getScale().x - 0.1);
|
||||
setPosition(pos.x, pos.y);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue