初始化内容
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#include "ui_game.h"
|
||||
|
||||
#include "game_sudo.h"
|
||||
#include "game_snake.h"
|
||||
#include "game_match.h"
|
||||
|
||||
UIGame::UIGame()
|
||||
{
|
||||
UI::Panel* panel = CreatePanel("root");
|
||||
panel->SetPosScale({ 0.0f, 0.0f });
|
||||
panel->SetPosPixel(POS_CONTENT);
|
||||
|
||||
UI::Panel* panel_menu = g_ui->CreatePanel();
|
||||
panel_menu->SetLocator(createLocatorX(200));
|
||||
g_ui->SetPanelParent(panel_menu, panel);
|
||||
|
||||
|
||||
{
|
||||
UI::ListBox* lst = g_ui->CreateListBoxDefault(true);
|
||||
lst->SetItemCallback([](UI::Panel* item, Value v) {
|
||||
if (v)
|
||||
item->ExSetString(v.ToString());
|
||||
else
|
||||
item->ExSetString({});
|
||||
});
|
||||
_allGame.push_back("数独");
|
||||
_allGame.push_back("贪吃蛇");
|
||||
_allGame.push_back("消消乐");
|
||||
lst->SetItemData(_allGame);
|
||||
panel_menu->Add(lst);
|
||||
_edt = lst;
|
||||
}
|
||||
{
|
||||
UI::Text* txt = g_ui->CreateTextDefault();
|
||||
txt->SetElementData(Align::LT);
|
||||
txt->GetText()->SetMaxW(400);
|
||||
txt->SetString("请选择一个示例");
|
||||
panel_menu->Add(txt);
|
||||
_txtInfo = txt;
|
||||
}
|
||||
}
|
||||
|
||||
void UIGame::Update()
|
||||
{
|
||||
if (_edt->IsSelectChange())
|
||||
{
|
||||
Value name = _edt->GetSelect();
|
||||
if (name)
|
||||
{
|
||||
if (name.ToString() == "数独")
|
||||
{
|
||||
_txtInfo->SetString("数独游戏,双击进入。\n操作说明:按1-9选择数字,按~取消选择");
|
||||
}
|
||||
else if (name.ToString() == "贪吃蛇")
|
||||
{
|
||||
_txtInfo->SetString("贪吃蛇,双击进入。\n由ai编写");
|
||||
}
|
||||
else if (name.ToString() == "消消乐")
|
||||
{
|
||||
_txtInfo->SetString("消消乐游戏,双击进入。\n操作说明:点击相邻方块进行交换,形成3个或以上连续匹配");
|
||||
}
|
||||
else
|
||||
_txtInfo->SetString("");
|
||||
}
|
||||
}
|
||||
|
||||
Value enter = _edt->GetSelectClickDouble();
|
||||
if (enter)
|
||||
{
|
||||
if (enter.ToString() == "数独")
|
||||
{
|
||||
g_scene->Del("child");
|
||||
g_scene->Del("main");
|
||||
g_scene->Add("game", new GameSudo);
|
||||
}
|
||||
else if(enter.ToString() == "贪吃蛇")
|
||||
{
|
||||
g_scene->Del("child");
|
||||
g_scene->Del("main");
|
||||
g_scene->Add("game", new GameSnake);
|
||||
}
|
||||
else if(enter.ToString() == "消消乐")
|
||||
{
|
||||
g_scene->Del("child");
|
||||
g_scene->Del("main");
|
||||
g_scene->Add("game", new GameMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user