66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#include "Scene/Scene_Loading_UI.h"
|
|
#include "Scene/Scene_MainUi.h"
|
|
#include "Actor/Map/GameWorld.h"
|
|
#include "Scene_Loading_UI.h"
|
|
#include "EngineFrame/Component/Sprite.h"
|
|
#include "EngineFrame/Component/Text.h"
|
|
#include "Global/Global_Game.h"
|
|
#include "Asset/Asset_Script.h"
|
|
|
|
void Scene_Loading_UI::Enter()
|
|
{
|
|
// 加载OGG文件
|
|
music = Mix_LoadMUS("Music/characterSelectStage.ogg");
|
|
if (music)
|
|
{
|
|
Mix_PlayMusic(music, 1);
|
|
}
|
|
else
|
|
{
|
|
printf("Mix_LoadMUS: %s\n", Mix_GetError());
|
|
}
|
|
|
|
RefPtr<Actor> actor = new Actor;
|
|
AddChild(actor);
|
|
|
|
RefPtr<Sprite> BackGroundSp = new Sprite("ImagePacks2/Loading1.png");
|
|
actor->AddChild(BackGroundSp);
|
|
RefPtr<Sprite> BackGround2Sp = new Sprite("ImagePacks2/Loading0.png");
|
|
BackGround2Sp->SetPosition(0, 686);
|
|
actor->AddChild(BackGround2Sp);
|
|
RefPtr<Sprite> LoadCircleSp = new Sprite("ImagePacks2/Loading2.png");
|
|
LoadCircleSp->SetName("LoadCircle");
|
|
LoadCircleSp->SetPosition(1280 - 60, 686 - 60);
|
|
LoadCircleSp->SetBlendMode(LINEARDODGE);
|
|
LoadCircleSp->SetAnchor(0.5f, 0.5f);
|
|
actor->AddChild(LoadCircleSp);
|
|
|
|
actor->SetCallbackOnUpdate("Rotate", [LoadCircleSp](float deltaTime) mutable
|
|
{
|
|
float angle = LoadCircleSp->GetRotation();
|
|
LoadCircleSp->SetRotation(angle - 180.0f * deltaTime); });
|
|
}
|
|
|
|
void Scene_Loading_UI::Update(float deltaTime)
|
|
{
|
|
Scene::Update(deltaTime);
|
|
if (Global_Game::GetInstance().InitFlag)
|
|
{
|
|
// 设定游戏层场景
|
|
RefPtr<GameWorld> scene = new GameWorld;
|
|
Game::GetInstance().ChangeScene(scene);
|
|
// 设定UI层场景
|
|
RefPtr<Scene_MainUi> sceneUI = new Scene_MainUi;
|
|
Game::GetInstance().ChangeUIScene(sceneUI);
|
|
}
|
|
}
|
|
|
|
void Scene_Loading_UI::Exit()
|
|
{
|
|
if (music)
|
|
{
|
|
Mix_FreeMusic(music);
|
|
music = nullptr;
|
|
}
|
|
}
|