add how to playbutton

This commit is contained in:
arthur.jamet
2021-06-15 14:23:19 +02:00
parent 35612b8be9
commit 1ff0a8bc5d
3 changed files with 21 additions and 1 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

+21 -1
View File
@@ -85,6 +85,25 @@ namespace BBM
texture->use("assets/buttons/button_back_hovered.png"); texture->use("assets/buttons/button_back_hovered.png");
}); });
auto &howToPlay = scene->addEntity("to to play")
.addComponent<PositionComponent>(1920 - 10 - 75, 1080 - 85, 0)
.addComponent<Drawable2DComponent, RAY::Texture>("assets/buttons/button_htp.png")
.addComponent<OnClickComponent>([](WAL::Entity &entity, WAL::Wal &)
{
gameState.nextScene = BBM::GameState::SceneID::MainMenuScene;
})
.addComponent<OnIdleComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_htp.png");
})
.addComponent<OnHoverComponent>([](WAL::Entity &entity, WAL::Wal &)
{
RAY::Texture *texture = dynamic_cast<RAY::Texture *>(entity.getComponent<Drawable2DComponent>().drawable.get());
texture->use("assets/buttons/button_htp_hovered.png");
});
auto &lavaOption = scene->addEntity("lava option text") auto &lavaOption = scene->addEntity("lava option text")
.addComponent<PositionComponent>(1920 / 6, 2 * 1080 / 3, 0) .addComponent<PositionComponent>(1920 / 6, 2 * 1080 / 3, 0)
.addComponent<Drawable2DComponent, RAY2D::Text>("Lava: Off", 70, RAY::Vector2(), BLACK) .addComponent<Drawable2DComponent, RAY2D::Text>("Lava: Off", 70, RAY::Vector2(), BLACK)
@@ -148,7 +167,8 @@ namespace BBM
scene->addEntity("camera") scene->addEntity("camera")
.addComponent<PositionComponent>(8, 20, 7) .addComponent<PositionComponent>(8, 20, 7)
.addComponent<CameraComponent>(Vector3f(8, 0, 8)); .addComponent<CameraComponent>(Vector3f(8, 0, 8));
play.getComponent<OnClickComponent>().setButtonLinks(&lavaOption, &back, &back, nullptr); play.getComponent<OnClickComponent>().setButtonLinks(&lavaOption, &back, &back, &howToPlay);
howToPlay.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, &play);
back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play); back.getComponent<OnClickComponent>().setButtonLinks(&play, nullptr, nullptr, &play);
lavaOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, nullptr, &heightOption); lavaOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, nullptr, &heightOption);
heightOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, &lavaOption, nullptr); heightOption.getComponent<OnClickComponent>().setButtonLinks(nullptr, &play, &lavaOption, nullptr);