There, this is the whole class
#include "ColorButton.h"
ColorButton::ColorButton(void)
{
}
ColorButton::~ColorButton(void)
{
}
void ColorButton::loadButton(int cloneID, float xPos, float yPos, float scalex, float scaley, float texty, uString text){
x = xPos;
y = yPos;
SID = agk::CloneSprite(cloneID);
agk::SetSpriteScale(SID, scalex, scaley);
agk::SetSpritePositionByOffset(SID, x, y);
agk::SetSpriteVisible(SID, 1);
//adding text to the button
textID = agk::CreateText(text);
agk::SetTextAlignment(textID, 1);
agk::SetTextPosition(textID, xPos, yPos + texty);
agk::SetTextSize(textID, 3);
}
void ColorButton::loadButton(int ID, int cloneID, float xPos, float yPos, float scalex, float scaley, float texty, uString text){
x = xPos;
y = yPos;
SID = agk::CloneSprite(cloneID);
agk::SetSpriteScale(SID, scalex, scaley);
agk::SetSpritePositionByOffset(SID, x, y);
agk::SetSpriteVisible(SID, 1);
//adding text to the button
textID = agk::CreateText(text);
agk::SetTextAlignment(textID, 1);
agk::SetTextPosition(textID, xPos, yPos + texty);
agk::SetTextSize(textID, 3);
}
void ColorButton::setColor(int r, int g, int b, int hr, int hg, int hb){
R = r;
G = g;
B = b;
agk::SetSpriteColor(SID, r, g, b, 255);
hoverR = hr;
hoverB = hb;
hoverG = hg;
}
int ColorButton::updateButton(){
//Checking if the mouse is pressed
if(agk::GetSpriteHitTest(SID, agk::GetPointerX(), agk::GetPointerY())){
agk::SetSpriteColor(SID, hoverR, hoverG, hoverB, 255);
if (agk::GetPointerState() == 1){
state = -1;
}else{
if(state == -1){
state = 1;
}else{
state = 0;
agk::SetSpriteColor(SID, R, G, B, 255);
}
}
}else{
state = 0;
agk::SetSpriteColor(SID, R, G, B, 255);
}
return state;
}
and the .h file
#pragma once
#include "agk.h"
class ColorButton
{
public:
ColorButton(void);
~ColorButton(void);
int SID;
float x;
float y;
int R;
int G;
int B;
int hoverR;
int hoverG;
int hoverB;
int state;
int textID;
void loadButton(int cloneID, float xPos, float yPos, float scalex, float scaley, float texty, uString text); //Creates a button with a solid color that will change when the button is hovered or clicked
void loadButton(int ID, int cloneID, float xPos, float yPos, float scalex, float scaley, float texty, uString text); //Creates a button with a solid color that will change when the button is hovered or clicked
void setColor(int r, int g, int b, int hr, int hg, int hb);
int updateButton();
};