加入 Node节点类 还未测试新框架
This commit is contained in:
35
source_game/Global/GameCamera.h
Normal file
35
source_game/Global/GameCamera.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "EngineFrame/Base/Actor.h"
|
||||
class GameMap;
|
||||
class BaseObject;
|
||||
class GameCamera : public Actor
|
||||
{
|
||||
private:
|
||||
// 跟随对象
|
||||
BaseObject *_FromActor = nullptr;
|
||||
|
||||
public:
|
||||
// 缩放比率
|
||||
float CameraRate = 1.0;
|
||||
|
||||
// 添加平滑移动相关的成员变量
|
||||
bool _isSmoothMoving = false;
|
||||
Vec2 _currentPosition; // 当前摄像机位置
|
||||
Vec2 _velocity; // 当前移动速度(用于平滑移动)
|
||||
float _smoothTime = 0.1f; // 平滑时间(秒),可调整
|
||||
float _maxSpeed = 2000; // 最大移动速度,防止过快
|
||||
|
||||
public:
|
||||
void SetFromActor(BaseObject *actor);
|
||||
void Update(float deltaTime);
|
||||
|
||||
void SetPos(float x, float y, float z);
|
||||
void AddPos(float x, float y, float z);
|
||||
|
||||
// 同步坐标相关
|
||||
void SyncPos(float deltaTime);
|
||||
void SyncPosByFromParent(float deltaTime);
|
||||
|
||||
// 平滑阻尼函数(类似Unity的Mathf.SmoothDamp)
|
||||
Vec2 SmoothDamp(const Vec2 ¤t, const Vec2 &target, Vec2 ¤tVelocity, float smoothTime, float maxSpeed, float deltaTime);
|
||||
};
|
||||
Reference in New Issue
Block a user