加入 Node节点类 还未测试新框架

This commit is contained in:
2025-10-27 23:12:56 +08:00
parent 80d088316b
commit 0ae47e5d6a
52 changed files with 1642 additions and 458 deletions

View File

@@ -20,18 +20,18 @@ void Scene_Loading_UI::Enter()
AddChild(actor);
RefPtr<Sprite> BackGroundSp = new Sprite("ImagePacks2/Loading1.png");
actor->AddComponent(BackGroundSp);
actor->AddChild(BackGroundSp);
RefPtr<Sprite> BackGround2Sp = new Sprite("ImagePacks2/Loading0.png");
BackGround2Sp->SetPos(Vec2{0, 686});
actor->AddComponent(BackGround2Sp);
actor->AddChild(BackGround2Sp);
RefPtr<Sprite> LoadCircleSp = new Sprite("ImagePacks2/Loading2.png");
LoadCircleSp->SetName("LoadCircle");
LoadCircleSp->SetPos(Vec2{1280 - 60, 686 - 60});
LoadCircleSp->SetBlendMode(LINEARDODGE);
LoadCircleSp->SetAnchor(Vec2{0.5f, 0.5f});
actor->AddComponent(LoadCircleSp);
actor->AddChild(LoadCircleSp);
actor->SetCallbackOnUpdate([LoadCircleSp](float deltaTime) mutable
actor->SetCallbackOnUpdate("Rotate", [LoadCircleSp](float deltaTime) mutable
{
float angle = LoadCircleSp->GetRotation();
LoadCircleSp->SetRotation(angle + 180.0f * deltaTime); });

View File

@@ -17,23 +17,25 @@ Scene_Test::~Scene_Test()
void Scene_Test::Enter()
{
map = new GameMap;
map->LoadMap("map/cataclysm/town/elvengard/new_d_elvengard_l.map");
map->LoadMap("map/cataclysm/town/elvengard/new_elvengard.map");
map->Enter(this);
AddChild(map);
map->SetCallbackOnUpdate("csas", [this](float dt)
{
Vec2 pos = map->GetPos();
pos.x -= 10 * dt;
map->SetPos(pos); });
RefPtr<CharacterObject> obj = new CharacterObject();
obj->SetPosition({1000, 300, 0});
obj->Construction(0);
// RefPtr<CharacterObject> obj = new CharacterObject();
// obj->SetPosition({1000, 300, 0});
// obj->Construction(0);
// map->AddObject(obj);
map->AddObject(obj);
RefPtr<MonsterObject> monster = new MonsterObject();
monster->SetPosition({1200, 301, 0});
monster->Construction(1);
monster->SetDirection(1);
map->AddObject(monster);
_camera = new GameMapCamera;
_camera->SetFromActor(obj.Get());
// RefPtr<MonsterObject> monster = new MonsterObject();
// monster->SetPosition({1200, 301, 0});
// monster->Construction(1);
// monster->SetDirection(1);
// map->AddObject(monster);
return;
@@ -107,11 +109,6 @@ void Scene_Test::HandleEvents(SDL_Event *e)
void Scene_Test::Update(float deltaTime)
{
Scene::Update(deltaTime);
// 摄像机中有检测宿主坐标 所以要在场景的update后调用以便读取到本帧最新的坐标
if (_camera)
_camera->Update(deltaTime);
if (map)
map->Update(deltaTime);
}
void Scene_Test::Render()
@@ -123,8 +120,3 @@ void Scene_Test::Exit()
{
SDL_Log("Scene_Test::退出测试场景!当前引用计数%d", this->GetRefCount());
}
RefPtr<BaseNode> Scene_Test::GetCamera()
{
return this->_camera;
}

View File

@@ -3,7 +3,6 @@
#include "Asset/AssetManager.h"
#include "EngineFrame/Component/Animation.h"
#include "Actor/Map/GameMap.h"
#include "Actor/Map/GameMapCamera.h"
#include "Actor/Object/CharacterObject.h"
#include "Actor/Object/MonsterObject.h"
@@ -11,7 +10,6 @@ class Scene_Test : public Scene
{
private:
GameMap *map = nullptr;
RefPtr<GameMapCamera> _camera = nullptr;
public:
Scene_Test(/* args */);
@@ -23,7 +21,7 @@ public:
void Update(float deltaTime) override;
void Render() override;
void Exit() override;
RefPtr<BaseNode> GetCamera() override;
public:
int MyId = 0;