-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d067f0e
commit 37fc988
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "state_start_with_button.hpp" | ||
#include <drawable_helpers.hpp> | ||
#include <game_interface.hpp> | ||
#include <game_properties.hpp> | ||
#include <state_intro.hpp> | ||
#include <text.hpp> | ||
|
||
void StateStartWithButton::onCreate() | ||
{ | ||
auto const buttonSize = jt::Vector2u { 128, 48 }; | ||
m_button = std::make_shared<jt::Button>(buttonSize, textureManager()); | ||
m_button->addCallback( | ||
[this]() { getGame()->stateManager().switchState(std::make_shared<StateIntro>()); }); | ||
auto text = jt::dh::createText(renderTarget(), "Start", 24); | ||
text->setTextAlign(jt::Text::TextAlign::LEFT); | ||
text->setOrigin({ -34, -6 }); | ||
m_button->setDrawable(text); | ||
m_button->setPosition( | ||
GP::GetScreenSize() * 0.5f - jt::Vector2f { buttonSize.x / 2.0f, buttonSize.y / 2.0f }); | ||
add(m_button); | ||
} | ||
|
||
void StateStartWithButton::onEnter() { } | ||
|
||
void StateStartWithButton::onUpdate(float /*elapsed*/) { } | ||
|
||
void StateStartWithButton::onDraw() const { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef JAMTEMPLATE_STATE_START_WITH_BUTTON_HPP | ||
#define JAMTEMPLATE_STATE_START_WITH_BUTTON_HPP | ||
|
||
#include <button.hpp> | ||
#include <game_state.hpp> | ||
#include <memory> | ||
|
||
class StateStartWithButton : public jt::GameState { | ||
void onCreate() override; | ||
void onEnter() override; | ||
void onUpdate(float elapsed) override; | ||
void onDraw() const override; | ||
|
||
std::shared_ptr<jt::Button> m_button; | ||
}; | ||
|
||
#endif // JAMTEMPLATE_STATE_START_WITH_BUTTON_HPP |