定时器相关函数重命名

This commit is contained in:
Nomango 2018-05-26 22:22:24 +08:00
parent 6f8e0a4c3e
commit 5f2583d4ba
2 changed files with 30 additions and 30 deletions

View File

@ -68,24 +68,24 @@ namespace e2d
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);
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);
}
void e2d::Timer::pause(const String& name)
void e2d::Timer::stop(const String& name)
{
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)
{
@ -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)
{
@ -118,7 +118,7 @@ void e2d::Timer::stop(const String& name)
}
}
void e2d::Timer::pauseAll()
void e2d::Timer::stopAll()
{
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)
{
@ -134,7 +134,7 @@ void e2d::Timer::resumeAll()
}
}
void e2d::Timer::stopAll()
void e2d::Timer::removeAll()
{
for (auto timer : s_vTimers)
{

View File

@ -261,14 +261,14 @@ class Timer
friend class Game;
public:
// 启动定时器(每帧执行一次)
static void start(
// 添加定时器(每帧执行一次)
static void add(
const Function& func, /* 执行函数 */
const String& name = L"" /* 定时器名称 */
);
// 启动定时器
static void start(
// 添加定时器
static void add(
const Function& func, /* 执行函数 */
double delay, /* 时间间隔(秒) */
int times = -1, /* 执行次数(设 -1 为永久执行) */
@ -276,19 +276,14 @@ public:
const String& name = L"" /* 定时器名称 */
);
// 启动仅执行一次的定时器
static void startOnce(
const Function& func, /* 执行的函数 */
double timeOut /* 等待的时长(秒) */
// 在足够延迟后执行指定函数
static void start(
double timeout, /* 等待的时长(秒) */
const Function& func /* 执行的函数 */
);
// 暂停具有相同名称的定时器
static void pause(
const String& name
);
// 继续具有相同名称的定时器
static void resume(
// 启动具有相同名称的定时器
static void start(
const String& name
);
@ -297,15 +292,20 @@ public:
const String& name
);
// 暂停所有定时器
static void pauseAll();
// 移除具有相同名称的定时器
static void remove(
const String& name
);
// 继续所有定时器
static void resumeAll();
// 启动所有定时器
static void startAll();
// 停止所有定时器
static void stopAll();
// 移除所有定时器
static void removeAll();
private:
// 更新定时器
static void __update();