From 5f2583d4bafb7872feea1d3d1db3a07684ce3dbf Mon Sep 17 00:00:00 2001 From: Nomango <569629550@qq.com> Date: Sat, 26 May 2018 22:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E9=87=8D=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/Tool/Timer.cpp | 22 +++++++++++----------- core/e2dtool.h | 38 +++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/core/Tool/Timer.cpp b/core/Tool/Timer.cpp index fa8c8ac1..fcf0ccba 100644 --- a/core/Tool/Timer.cpp +++ b/core/Tool/Timer.cpp @@ -68,24 +68,24 @@ namespace e2d static std::vector 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) { diff --git a/core/e2dtool.h b/core/e2dtool.h index 51854d8c..ef4884a5 100644 --- a/core/e2dtool.h +++ b/core/e2dtool.h @@ -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();