aboutsummaryrefslogtreecommitdiff
path: root/game/mainmenu/MainMenuScene.cpp
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-23 21:17:45 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-23 21:17:45 +0100
commit225e873c8ac9c4c08720a69b8f2c817d22cf0071 (patch)
tree20c1539a7ea7d133fca143e922165fd7533c87fe /game/mainmenu/MainMenuScene.cpp
parenta3097a20daaf58e4e3852bfb36315dc5e14d3e52 (diff)
made script reusable to switch scenes
Diffstat (limited to 'game/mainmenu/MainMenuScene.cpp')
-rw-r--r--game/mainmenu/MainMenuScene.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/game/mainmenu/MainMenuScene.cpp b/game/mainmenu/MainMenuScene.cpp
index 4067681..7a86ba5 100644
--- a/game/mainmenu/MainMenuScene.cpp
+++ b/game/mainmenu/MainMenuScene.cpp
@@ -1,6 +1,8 @@
#include "MainMenuScene.h"
#include "ButtonSubScene.h"
+#include "ShowStartScript.h"
+#include "api/BehaviorScript.h"
#include "api/Camera.h"
#include "../StartSubScene.h"
#include "MainMenuConfig.h"
@@ -18,27 +20,19 @@ void MainMenuScene::load_scene(){
.bg_color = Color::RED,
});
- GameObject menu_background = this->new_object("menu_background","",MainMenuConfig::MENU_OFFSET + MainMenuConfig::MENU_OFFSET_BACKGROUND);
- menu_background.add_component<Sprite>(
+ GameObject menu = this->new_object("menu_background","",MainMenuConfig::MENU_OFFSET + MainMenuConfig::MENU_OFFSET_BACKGROUND);
+ menu.add_component<Sprite>(
Asset("asset/ui/itemsButtonBlankDark.png"),
Sprite::Data{
.sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+0,
.size = {300,922},
});
+ menu.add_component<BehaviorScript>().set_script<ShowStartScript>();
ButtonSubScene button;
vec2 pos = MainMenuConfig::MENU_OFFSET;
- //Start btn
- button.create(*this,ButtonSubScene::Data{
- .text = "START",
- .text_size = vec2{200,80},
- .position = pos,
- .script = ButtonSubScene::ScriptSelect::START,
- });
-
//Preview btn
- pos.y += MainMenuConfig::MENU_BUTTON_SPACING + MainMenuConfig::LARGE_OVERLAY_SIZE.y;
button.create(*this,ButtonSubScene::Data{
.text = "PREVIEW",
.text_size = vec2{200,80},