Creates a Button object that inherits Entity. More...
#include <UI_Button.h>
Public Member Functions | |
UI_Button (C_Texture *spritesheet, C_Vec2 pos, C_Vec2 dimensions, C_Vec2 spriteDimensions, float *universalSpeed) | |
UI_Button (C_Texture *sprite, C_Vec2 spriteDimensions, C_Vec2 pos, std::string message, std::string fontLocation, int fontSize, int r, int g, int b, SDL_Renderer *renderer, float border, C_Vec2 minDimensions, float *universalSpeed) | |
UI_Button (int buttonR, int buttonG, int buttonB, C_Vec2 pos, std::string message, std::string fontLocation, int fontSize, int r, int g, int b, SDL_Renderer *renderer, float border, C_Vec2 minDimensions, float *universalSpeed) | |
~UI_Button () | |
void | update (float dt) |
bool | input (SDL_Event &incomingEvent) |
void | draw (SDL_Renderer *renderer) |
Public Member Functions inherited from EB_Entity | |
EB_Entity (C_Texture *sprite, C_Vec2 pos, C_Vec2 dimensions, std::string iD, float *universalSpeed) | |
Constructs the Entity object. More... | |
~EB_Entity () | |
Destructs the Entity object. More... | |
void | setPosition (C_Vec2 pos) |
Sets the position of the Entity. More... | |
void | setX (float x) |
Sets the x position of the Entity. More... | |
void | setY (float y) |
Sets the y position of the Entity. More... | |
void | setDimensions (C_Vec2 dimensions) |
Sets the dimensions of the Entity. More... | |
void | setWidth (float width) |
Sets the width of the Entity. More... | |
void | setHeight (float height) |
Sets the height of the Entity. More... | |
C_Vec2 | getPosition () |
Gets the position of the Entity. More... | |
C_Vec2 | getDimensions () |
Gets the dimensions of the Entity. More... | |
Private Attributes | |
C_Vec2 | spriteDimensions |
The dimensions of the sprites. More... | |
C_Text * | text |
The text of the button. More... | |
float | border |
The size of the border from the button and the text. More... | |
bool | spritesheet |
A boolean for if the button is using an spritesheet. More... | |
bool | usingText |
A boolean for if the button is using text. More... | |
bool | pressed |
A boolean for if the button has been pressed. More... | |
int | spriteIndex |
The x index of the sprite in the spritesheet if on is used. More... | |
Additional Inherited Members | |
Protected Attributes inherited from EB_Entity | |
C_Texture * | sprite |
A pointer to the Entity Texture. More... | |
C_Vec2 | pos |
The position of the Entity. More... | |
C_Vec2 | dimensions |
The dimensions of the Entity. More... | |
std::string | iD |
The ID of the type of Entity. More... | |
float * | universalSpeed |
A pointer for the universal speed of the game. More... | |
Creates a Button object that inherits Entity.
UI_Button::UI_Button | ( | C_Texture * | spritesheet, |
C_Vec2 | pos, | ||
C_Vec2 | dimensions, | ||
C_Vec2 | spriteDimensions, | ||
float * | universalSpeed | ||
) |
Constructs the Button object with an image.
spritesheet | A pointer to the objects Texture. |
pos | The position of the Button. |
dimensions | The dimensions of the Button. |
spriteDimensions | The dimensions of the sprite. |
universalSpeed | A pointer for the universal speed of the game. |
UI_Button::UI_Button | ( | C_Texture * | sprite, |
C_Vec2 | spriteDimensions, | ||
C_Vec2 | pos, | ||
std::string | message, | ||
std::string | fontLocation, | ||
int | fontSize, | ||
int | r, | ||
int | g, | ||
int | b, | ||
SDL_Renderer * | renderer, | ||
float | border, | ||
C_Vec2 | minDimensions, | ||
float * | universalSpeed | ||
) |
Constructs the Button object with an image and text.
spritesheet | A pointer to the objects Texture. |
spriteDimensions | The dimensions of the sprite. |
pos | The position of the Button. |
message | The text of the Button. |
fontLocation | The location of the font. |
r | The blue of the Button font colour. |
g | The blue of the Button font colour. |
b | The blue of the Button font colour. |
renderer | A pointer to the renderer. |
border | The size of the border of the Button. |
minDimensions | The minimum dimensions of the Button. |
universalSpeed | A pointer for the universal speed of the game. |
UI_Button::UI_Button | ( | int | buttonR, |
int | buttonG, | ||
int | buttonB, | ||
C_Vec2 | pos, | ||
std::string | message, | ||
std::string | fontLocation, | ||
int | fontSize, | ||
int | r, | ||
int | g, | ||
int | b, | ||
SDL_Renderer * | renderer, | ||
float | border, | ||
C_Vec2 | minDimensions, | ||
float * | universalSpeed | ||
) |
Constructs the Button object with a colour and text.
buttonR | The red of the Button colour. |
buttonG | The green of the Button colour. |
buttonB | The blue of the Button colour. |
pos | The position of the Button. |
message | The text of the Button. |
fontLocation | The location of the font. |
r | The red of the Button font colour. |
g | The green of the Button font colour. |
b | The blue of the Button font colour. |
renderer | A pointer to the renderer. |
border | The size of the border of the Button. |
minDimensions | The minimum dimensions of the Button. |
universalSpeed | A pointer for the universal speed of the game. |
UI_Button::~UI_Button | ( | ) |
Destructs the Button object.
|
virtual |
Draws the Button to the screen.
renderer | A pointer to the SDL renderer. |
Reimplemented from EB_Entity.
bool UI_Button::input | ( | SDL_Event & | incomingEvent | ) |
A function that handles the Button input.
incomingEvent | A reference to the incoming event. |
|
virtual |
A function that updates the Button.
dt | The delta time. |
Implements EB_Entity.
|
private |
The size of the border from the button and the text.
|
private |
A boolean for if the button has been pressed.
|
private |
The dimensions of the sprites.
|
private |
The x index of the sprite in the spritesheet if on is used.
|
private |
A boolean for if the button is using an spritesheet.
|
private |
The text of the button.
|
private |
A boolean for if the button is using text.