diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-12-23 22:43:10 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-12-23 22:43:10 +0100 |
commit | ab4d35b795664a10da6e13f9fa22f73a86b948b4 (patch) | |
tree | bde4ac1fdaf58cf6b1852f9eb2f381cfb87b8f00 /game/mainmenu | |
parent | 4cbd236de18446d192dd59d7c7bc4ebb78850e37 (diff) |
reuasable banner
Diffstat (limited to 'game/mainmenu')
-rw-r--r-- | game/mainmenu/BannerSubScene.cpp | 35 | ||||
-rw-r--r-- | game/mainmenu/BannerSubScene.h | 12 | ||||
-rw-r--r-- | game/mainmenu/ShopMenuScene.cpp | 26 |
3 files changed, 50 insertions, 23 deletions
diff --git a/game/mainmenu/BannerSubScene.cpp b/game/mainmenu/BannerSubScene.cpp new file mode 100644 index 0000000..0f4f075 --- /dev/null +++ b/game/mainmenu/BannerSubScene.cpp @@ -0,0 +1,35 @@ +#include "BannerSubScene.h" +#include "MainMenuConfig.h" + + +#include <crepe/api/Sprite.h> +#include <crepe/api/Scene.h> +#include <crepe/api/Text.h> + +using namespace crepe; +using namespace std; + +void BannerSubScene::create(Scene & scn){ + GameObject menu_banner = scn.new_object("menu_banner","", {0,-414}); + menu_banner.add_component<Sprite>( + Asset("asset/ui/settings_container/top_middle_setting.png"), + Sprite::Data{ + .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, + .size = {1100,88}, + }); + menu_banner.add_component<Sprite>( + Asset("asset/ui/settings_container/top_2_middle_setting.png"), + Sprite::Data{ + .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, + .size = {1100,66}, + .position_offset {0,77}, + }); + menu_banner.add_component<Sprite>( + Asset("asset/ui/settings_container/banner_bottom.png"), + Sprite::Data{ + .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, + .size = {1100,7}, + .position_offset {0,113}, + }); + +} diff --git a/game/mainmenu/BannerSubScene.h b/game/mainmenu/BannerSubScene.h new file mode 100644 index 0000000..06cd1a4 --- /dev/null +++ b/game/mainmenu/BannerSubScene.h @@ -0,0 +1,12 @@ +#pragma once + +#include <crepe/api/GameObject.h> + +namespace crepe { +class Scene; +} + +class BannerSubScene { +public: + void create(crepe::Scene & scn); +}; diff --git a/game/mainmenu/ShopMenuScene.cpp b/game/mainmenu/ShopMenuScene.cpp index f3ca9ce..b18ae47 100644 --- a/game/mainmenu/ShopMenuScene.cpp +++ b/game/mainmenu/ShopMenuScene.cpp @@ -3,6 +3,7 @@ #include "api/Camera.h" #include "MainMenuConfig.h" #include "api/Sprite.h" +#include "BannerSubScene.h" using namespace crepe; using namespace std; @@ -13,7 +14,8 @@ void ShopMenuScene::load_scene(){ Camera::Data{ .bg_color = Color::RED, }); - + BannerSubScene banner; + banner.create(*this); GameObject menu_background = this->new_object("menu_background"); menu_background.add_component<Sprite>( Asset("asset/ui/background.png"), @@ -22,28 +24,6 @@ void ShopMenuScene::load_scene(){ .size = {1100,860}, .position_offset {0}, }); - GameObject menu_banner = this->new_object("menu_banner","", {0,-414}); - menu_banner.add_component<Sprite>( - Asset("asset/ui/settings_container/top_middle_setting.png"), - Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = {1100,88}, - }); - menu_banner.add_component<Sprite>( - Asset("asset/ui/settings_container/top_2_middle_setting.png"), - Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = {1100,66}, - .position_offset {0,77}, - }); - menu_banner.add_component<Sprite>( - Asset("asset/ui/settings_container/banner_bottom.png"), - Sprite::Data{ - .sorting_in_layer = MainMenuConfig::STARTING_SORTING_IN_LAYER+1, - .size = {1100,7}, - .position_offset {0,113}, - }); - } string ShopMenuScene::get_name() const { return "shopmenu"; } |