Need help guys, I'm still too dumb for this :S
Basically I have this button class, copy/move constructor and operator assignment where added in the vain attempt to make it work with map, so ignore them.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
enum class BUTTON { INACTIVE, HIGHLIGHTED, PRESSED, RELEASED };
class Button
{
public:
Button(std::string path);
Button(Button& rhs);
Button(Button&& rhs);
Button& operator=(Button& rhs);
~Button();
void setFrame(BUTTON status);
void setDestRect(int x, int y, int width = 0, int height = 0);
SDL_Texture* getTexture()const { return texture; }
SDL_Point getFrameSize()const { return *frameSize; }
SDL_Rect getSourceRect()const { return *sourceRect; }
SDL_Rect getDestRect()const { return *destRect; }
private:
SDL_Point* frameSize;
SDL_Rect* sourceRect;
SDL_Rect* destRect;
SDL_Texture* texture;
};
|
Then I have this Singleton called IntroState derived from GameState and basically is just the intro menu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
enum class INTRO_BUTTON { NEW_GAME, OPTIONS, QUIT };
class IntroState : public GameState
{
public:
IntroState(IntroState&) = delete;
IntroState(IntroState&&) = delete;
void operator=(IntroState&) = delete;
void operator=(IntroState&&) = delete;
~IntroState();
//Public Methods
static IntroState& instance();
void init()override;
void update()override;
void draw()override;
private:
IntroState();
std::map<INTRO_BUTTON, Button> buttons;
};
|
And there you see the treacherous std::map...
The init function is something like this
1 2 3 4 5 6
|
void IntroState::init()
{
buttons[INTRO_BUTTON::NEW_GAME] = std::move(Button("assets/temps/newGameButton.png"));
buttons[INTRO_BUTTON::OPTIONS] = std::move(Button("assets/temps/optionsButton.png"));
buttons[INTRO_BUTTON::QUIT] = std::move(Button("assets/temps/quitButton.png"));
}
|
And ignore the move, that was another attempt at trying everything in order to make it work, but with or without it it just returns me a sh*tload of error messages, which just disappear if I comment out those 3 lines above... I have no idea of how I am misusing the map, please guys, help me figure this out x_x
Main error msg is that there are no appropriate constructors for Button::Button
But there is, and this is it:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
Button::Button(std::string path) :frameSize{new SDL_Point},sourceRect { new SDL_Rect}, destRect{ new SDL_Rect }, texture{ nullptr }
{
//Load Texture
texture = TextureManager::instance().load(path);
SDL_QueryTexture(texture, NULL, NULL, &frameSize->x, &frameSize->y);
//Set sizes
frameSize->x /= 2;
frameSize->y /= 2;
sourceRect->w = destRect->w = frameSize->x;
sourceRect->h = destRect->h = frameSize->y;
}
|