Added an accessor for the button's image
This commit is contained in:
+5
-1
@@ -42,7 +42,7 @@ void Button::SetBackgroundTexture(SDL_Renderer* renderer, SDL_Texture* texture)
|
|||||||
//get the w & h, & create
|
//get the w & h, & create
|
||||||
int w = 0, h = 0;
|
int w = 0, h = 0;
|
||||||
SDL_QueryTexture(texture, nullptr, nullptr, &w, &h);
|
SDL_QueryTexture(texture, nullptr, nullptr, &w, &h);
|
||||||
image.Create(renderer, w, h);
|
image.Create(renderer, w, h, {0, 0, 0, 0});
|
||||||
|
|
||||||
//copy
|
//copy
|
||||||
SDL_SetRenderTarget(renderer, image.GetTexture());
|
SDL_SetRenderTarget(renderer, image.GetTexture());
|
||||||
@@ -156,6 +156,10 @@ int Button::GetY() const {
|
|||||||
return posY;
|
return posY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Image* Button::GetImage() {
|
||||||
|
return ℑ
|
||||||
|
}
|
||||||
|
|
||||||
bool Button::CheckBounds(int x, int y) {
|
bool Button::CheckBounds(int x, int y) {
|
||||||
//return if true (x, y) is within bounds, otherwise return false
|
//return if true (x, y) is within bounds, otherwise return false
|
||||||
return !(
|
return !(
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ public:
|
|||||||
int GetX() const;
|
int GetX() const;
|
||||||
int GetY() const;
|
int GetY() const;
|
||||||
|
|
||||||
|
Image* GetImage();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CheckBounds(int x, int y);
|
bool CheckBounds(int x, int y);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user