加入 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

@@ -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;
}