51 lines
995 B
C++
51 lines
995 B
C++
#pragma once
|
|
|
|
#include <core/scheduler.h>
|
|
#include <core/service.h>
|
|
|
|
namespace extra2d {
|
|
|
|
/**
|
|
* @brief 导演类
|
|
*
|
|
* 主循环管理器,协调调度器和服务管理器
|
|
*/
|
|
class Director {
|
|
public:
|
|
static Director& inst();
|
|
|
|
bool init();
|
|
void shutdown();
|
|
|
|
void mainLoop(float dt);
|
|
void mainLoopParallel(float dt);
|
|
|
|
Scheduler& sched() { return SCHED; }
|
|
SvcMgr& svcs() { return SVC_MGR; }
|
|
|
|
float dt() const { return dt_; }
|
|
float totalTime() const { return totalTime_; }
|
|
uint64 frameCount() const { return frameCount_; }
|
|
|
|
void pause();
|
|
void resume();
|
|
bool isPaused() const { return paused_; }
|
|
|
|
void setTimeScale(float scale);
|
|
|
|
private:
|
|
Director() = default;
|
|
|
|
float dt_ = 0.0f;
|
|
float totalTime_ = 0.0f;
|
|
float fixedAccumulator_ = 0.0f;
|
|
float fixedDt_ = 1.0f / 60.0f;
|
|
uint64 frameCount_ = 0;
|
|
bool paused_ = false;
|
|
bool inited_ = false;
|
|
};
|
|
|
|
#define DIRECTOR extra2d::Director::inst()
|
|
|
|
} // namespace extra2d
|