建档
This commit is contained in:
65
source_game/Scene/Scene_Loading_UI.cpp
Normal file
65
source_game/Scene/Scene_Loading_UI.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "Scene/Scene_Loading_UI.h"
|
||||
#include "Scene/Scene_SelectCharacter_UI.hpp"
|
||||
#include "Scene/Scene_Test.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);
|
||||
}
|
||||
|
||||
RefPtr<Actor> actor = new Actor;
|
||||
AddChild(actor);
|
||||
|
||||
RefPtr<Sprite> BackGroundSp = new Sprite("ImagePacks2/Loading1.png");
|
||||
actor->AddComponent(BackGroundSp);
|
||||
RefPtr<Sprite> BackGround2Sp = new Sprite("ImagePacks2/Loading0.png");
|
||||
BackGround2Sp->SetPos(VecFPos{0, 686});
|
||||
actor->AddComponent(BackGround2Sp);
|
||||
RefPtr<Sprite> LoadCircleSp = new Sprite("ImagePacks2/Loading2.png");
|
||||
LoadCircleSp->SetName("LoadCircle");
|
||||
LoadCircleSp->SetPos(VecFPos{1280 - 60, 686 - 60});
|
||||
LoadCircleSp->SetBlendMode(SDL_BLENDMODE_ADD);
|
||||
LoadCircleSp->SetAnchor(VecFPos{0.5f, 0.5f});
|
||||
actor->AddComponent(LoadCircleSp);
|
||||
|
||||
actor->SetCallbackOnUpdate([LoadCircleSp](float deltaTime) mutable
|
||||
{
|
||||
float angle = LoadCircleSp->GetRotation();
|
||||
LoadCircleSp->SetRotation(angle + 180.0f * deltaTime); });
|
||||
|
||||
// 文字测试
|
||||
// RefPtr<Text> text = new Text("测试文字加载中...", Global_Game::GetInstance().Fonts[0], SDL_Color{255, 255, 255, 255}, SDL_Color{0, 0, 0, 255}, 4);
|
||||
// actor->AddComponent(text);
|
||||
}
|
||||
|
||||
void Scene_Loading_UI::Update(float deltaTime)
|
||||
{
|
||||
Scene::Update(deltaTime);
|
||||
if (Global_Game::GetInstance().InitFlag)
|
||||
{
|
||||
// 设定游戏层场景
|
||||
RefPtr<Scene_Test> scene = new Scene_Test;
|
||||
Game::GetInstance().ChangeScene(scene);
|
||||
// 设定UI层场景
|
||||
RefPtr<Scene_SelectCharacter_UI> sceneUI = new Scene_SelectCharacter_UI;
|
||||
Game::GetInstance().ChangeUIScene(sceneUI);
|
||||
}
|
||||
}
|
||||
|
||||
void Scene_Loading_UI::Exit()
|
||||
{
|
||||
if (music)
|
||||
{
|
||||
Mix_FreeMusic(music);
|
||||
music = nullptr;
|
||||
}
|
||||
}
|
||||
17
source_game/Scene/Scene_Loading_UI.h
Normal file
17
source_game/Scene/Scene_Loading_UI.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Scene/Scene.h"
|
||||
#include <SDL2/SDL_mixer.h>
|
||||
|
||||
class Scene_Loading_UI : public Scene
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
|
||||
public:
|
||||
void Enter() override;
|
||||
void Update(float deltaTime) override;
|
||||
void Exit() override;
|
||||
|
||||
// 加载界面音乐
|
||||
Mix_Music *music = nullptr;
|
||||
};
|
||||
88
source_game/Scene/Scene_SelectCharacter_UI.hpp
Normal file
88
source_game/Scene/Scene_SelectCharacter_UI.hpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Scene/Scene.h"
|
||||
#include "Asset/AssetManager.h"
|
||||
#include "EngineFrame/Component/Animation.h"
|
||||
#include "Actor/Map/GameMap.h"
|
||||
#include "Actor/Map/GameMapCamera.h"
|
||||
class Scene_SelectCharacter_UI : public Scene
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
GameMap *map;
|
||||
RefPtr<GameMapCamera> camera = nullptr;
|
||||
|
||||
public:
|
||||
Scene_SelectCharacter_UI(/* args */) {
|
||||
|
||||
};
|
||||
~Scene_SelectCharacter_UI() {
|
||||
|
||||
};
|
||||
|
||||
public:
|
||||
void Enter() override
|
||||
{
|
||||
map = new GameMap;
|
||||
map->LoadMap("map/cataclysm/town/elvengard/new_elvengard.map");
|
||||
map->Enter(this);
|
||||
|
||||
camera = new GameMapCamera;
|
||||
AddChild(camera);
|
||||
return;
|
||||
RefPtr<Actor> actor = new Actor;
|
||||
actor->SetPos(VecFPos{450, 350});
|
||||
// actor->SetAnchor(VecFPos{0.5, 0.5});
|
||||
actor->SetScale(VecFPos{-1.f, 1.f});
|
||||
AddChild(actor);
|
||||
|
||||
RefPtr<Actor> actor2 = new Actor;
|
||||
actor->AddChild(actor2);
|
||||
|
||||
RefPtr<Animation> ani4 = new Animation("map/cataclysm/town/hendonmyre/animation/object/gateall_02.ani");
|
||||
// ani4->SetScale(VecFPos{-1.0, 1.0});
|
||||
actor2->AddChild(ani4);
|
||||
|
||||
// RefPtr<Animation> ani3 = new Animation("map/cataclysm/town/elvengard/animation/obj/serialight01_right.ani");
|
||||
// ani3->SetPos(VecPos{300, 300});
|
||||
// actor->AddChild(ani3);
|
||||
|
||||
// RefPtr<Animation> ani4 = new Animation("map/cataclysm/town/hendonmyre/animation/object/gateall_02.ani");
|
||||
// ani4->SetPos(VecPos{300, 500});
|
||||
// actor->AddChild(ani4);
|
||||
|
||||
// for (size_t i = 0; i < 400; i++)
|
||||
// {
|
||||
// RefPtr<Actor> actor = new Actor;
|
||||
// AddChild(actor);
|
||||
|
||||
// // RefPtr<Animation> ani3 = new Animation("common/commoneffect/animation/priestslowheal1.ani");
|
||||
// // actor->AddComponent(ani3);
|
||||
// // ani3->SetRenderZOrder(1000);
|
||||
|
||||
// // RefPtr<Animation> ani = new Animation("common/anton/main.ani");
|
||||
// // actor->AddComponent(ani);
|
||||
// // ani->SetRenderZOrder(500);
|
||||
|
||||
// RefPtr<Sprite> sprite = new Sprite("sprite/item/avatar/swordman/0sm_acap.img", 0);
|
||||
// actor->AddComponent(sprite);
|
||||
// // RefPtr<Animation> ani2 = new Animation("common/anton/face/0/0.ani");
|
||||
// // actor->AddComponent(ani2);
|
||||
// // ani2->SetRenderZOrder(1000);
|
||||
// }
|
||||
|
||||
// SDL_Log("进入了选择角色场景!");
|
||||
};
|
||||
|
||||
void HandleEvents(SDL_Event *e) override
|
||||
{
|
||||
Scene::HandleEvents(e);
|
||||
map->HandleEvents(e);
|
||||
};
|
||||
void Update(float deltaTime) override
|
||||
{
|
||||
Scene::Update(deltaTime);
|
||||
map->Update(deltaTime);
|
||||
};
|
||||
// void Render() override;
|
||||
// void Exit() override;
|
||||
};
|
||||
33
source_game/Scene/Scene_Test.cpp
Normal file
33
source_game/Scene/Scene_Test.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include "Scene_Test.h"
|
||||
#include <memory>
|
||||
#include <EngineCore/Game.h>
|
||||
Scene_Test::Scene_Test()
|
||||
{
|
||||
}
|
||||
|
||||
Scene_Test::~Scene_Test()
|
||||
{
|
||||
SDL_Log("Scene_Test::我的ID是%d --- 我被释放了!", this->MyId);
|
||||
}
|
||||
|
||||
void Scene_Test::Enter()
|
||||
{
|
||||
SDL_Log("进入测试场景!");
|
||||
}
|
||||
|
||||
void Scene_Test::HandleEvents(SDL_Event *e)
|
||||
{
|
||||
}
|
||||
|
||||
void Scene_Test::Update(float deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
void Scene_Test::Render()
|
||||
{
|
||||
}
|
||||
|
||||
void Scene_Test::Exit()
|
||||
{
|
||||
SDL_Log("Scene_Test::退出测试场景!当前引用计数%d", this->GetRefCount());
|
||||
}
|
||||
21
source_game/Scene/Scene_Test.h
Normal file
21
source_game/Scene/Scene_Test.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Scene/Scene.h"
|
||||
|
||||
class Scene_Test : public Scene
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
public:
|
||||
Scene_Test(/* args */);
|
||||
~Scene_Test();
|
||||
|
||||
public:
|
||||
void Enter() override;
|
||||
void HandleEvents(SDL_Event *e) override;
|
||||
void Update(float deltaTime) override;
|
||||
void Render() override;
|
||||
void Exit() override;
|
||||
|
||||
public:
|
||||
int MyId = 0;
|
||||
};
|
||||
Reference in New Issue
Block a user