定时器相关函数重命名
This commit is contained in:
parent
6f8e0a4c3e
commit
5f2583d4ba
|
|
@ -68,24 +68,24 @@ namespace e2d
|
||||||
static std::vector<e2d::TimerEntity*> s_vTimers;
|
static std::vector<e2d::TimerEntity*> s_vTimers;
|
||||||
|
|
||||||
|
|
||||||
void e2d::Timer::start(const Function& func, double delay, int updateTimes, bool paused, const String& name)
|
void e2d::Timer::add(const Function& func, double delay, int updateTimes, bool paused, const String& name)
|
||||||
{
|
{
|
||||||
auto timer = new (std::nothrow) TimerEntity(func, name, delay, updateTimes, paused);
|
auto timer = new (std::nothrow) TimerEntity(func, name, delay, updateTimes, paused);
|
||||||
s_vTimers.push_back(timer);
|
s_vTimers.push_back(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::start(const Function& func, const String& name)
|
void e2d::Timer::add(const Function& func, const String& name)
|
||||||
{
|
{
|
||||||
Timer::start(func, 0, -1, false, name);
|
Timer::add(func, 0, -1, false, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::startOnce(const Function& func, double timeOut)
|
void e2d::Timer::start(double timeout, const Function& func)
|
||||||
{
|
{
|
||||||
auto timer = new (std::nothrow) TimerEntity(func, L"", timeOut, 1, false);
|
auto timer = new (std::nothrow) TimerEntity(func, L"", timeout, 1, false);
|
||||||
s_vTimers.push_back(timer);
|
s_vTimers.push_back(timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::pause(const String& name)
|
void e2d::Timer::stop(const String& name)
|
||||||
{
|
{
|
||||||
for (auto timer : s_vTimers)
|
for (auto timer : s_vTimers)
|
||||||
{
|
{
|
||||||
|
|
@ -96,7 +96,7 @@ void e2d::Timer::pause(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::resume(const String& name)
|
void e2d::Timer::start(const String& name)
|
||||||
{
|
{
|
||||||
for (auto timer : s_vTimers)
|
for (auto timer : s_vTimers)
|
||||||
{
|
{
|
||||||
|
|
@ -107,7 +107,7 @@ void e2d::Timer::resume(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::stop(const String& name)
|
void e2d::Timer::remove(const String& name)
|
||||||
{
|
{
|
||||||
for (auto timer : s_vTimers)
|
for (auto timer : s_vTimers)
|
||||||
{
|
{
|
||||||
|
|
@ -118,7 +118,7 @@ void e2d::Timer::stop(const String& name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::pauseAll()
|
void e2d::Timer::stopAll()
|
||||||
{
|
{
|
||||||
for (auto timer : s_vTimers)
|
for (auto timer : s_vTimers)
|
||||||
{
|
{
|
||||||
|
|
@ -126,7 +126,7 @@ void e2d::Timer::pauseAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::resumeAll()
|
void e2d::Timer::startAll()
|
||||||
{
|
{
|
||||||
for (auto timer : s_vTimers)
|
for (auto timer : s_vTimers)
|
||||||
{
|
{
|
||||||
|
|
@ -134,7 +134,7 @@ void e2d::Timer::resumeAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void e2d::Timer::stopAll()
|
void e2d::Timer::removeAll()
|
||||||
{
|
{
|
||||||
for (auto timer : s_vTimers)
|
for (auto timer : s_vTimers)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -261,14 +261,14 @@ class Timer
|
||||||
friend class Game;
|
friend class Game;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 启动定时器(每帧执行一次)
|
// 添加定时器(每帧执行一次)
|
||||||
static void start(
|
static void add(
|
||||||
const Function& func, /* 执行函数 */
|
const Function& func, /* 执行函数 */
|
||||||
const String& name = L"" /* 定时器名称 */
|
const String& name = L"" /* 定时器名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动定时器
|
// 添加定时器
|
||||||
static void start(
|
static void add(
|
||||||
const Function& func, /* 执行函数 */
|
const Function& func, /* 执行函数 */
|
||||||
double delay, /* 时间间隔(秒) */
|
double delay, /* 时间间隔(秒) */
|
||||||
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
int times = -1, /* 执行次数(设 -1 为永久执行) */
|
||||||
|
|
@ -276,19 +276,14 @@ public:
|
||||||
const String& name = L"" /* 定时器名称 */
|
const String& name = L"" /* 定时器名称 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 启动仅执行一次的定时器
|
// 在足够延迟后执行指定函数
|
||||||
static void startOnce(
|
static void start(
|
||||||
const Function& func, /* 执行的函数 */
|
double timeout, /* 等待的时长(秒) */
|
||||||
double timeOut /* 等待的时长(秒) */
|
const Function& func /* 执行的函数 */
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停具有相同名称的定时器
|
// 启动具有相同名称的定时器
|
||||||
static void pause(
|
static void start(
|
||||||
const String& name
|
|
||||||
);
|
|
||||||
|
|
||||||
// 继续具有相同名称的定时器
|
|
||||||
static void resume(
|
|
||||||
const String& name
|
const String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -297,15 +292,20 @@ public:
|
||||||
const String& name
|
const String& name
|
||||||
);
|
);
|
||||||
|
|
||||||
// 暂停所有定时器
|
// 移除具有相同名称的定时器
|
||||||
static void pauseAll();
|
static void remove(
|
||||||
|
const String& name
|
||||||
|
);
|
||||||
|
|
||||||
// 继续所有定时器
|
// 启动所有定时器
|
||||||
static void resumeAll();
|
static void startAll();
|
||||||
|
|
||||||
// 停止所有定时器
|
// 停止所有定时器
|
||||||
static void stopAll();
|
static void stopAll();
|
||||||
|
|
||||||
|
// 移除所有定时器
|
||||||
|
static void removeAll();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 更新定时器
|
// 更新定时器
|
||||||
static void __update();
|
static void __update();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue