2017-09-27 17:56:28 +08:00
|
|
|
|
#include "..\easy2d.h"
|
2017-09-30 16:18:45 +08:00
|
|
|
|
#include <assert.h>
|
2017-09-27 17:56:28 +08:00
|
|
|
|
|
|
|
|
|
|
static std::vector<Action*> s_vActions;
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::__exec()
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰʱ<C7B0><CAB1>
|
|
|
|
|
|
static LARGE_INTEGER nNow;
|
|
|
|
|
|
QueryPerformanceCounter(&nNow);
|
|
|
|
|
|
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
|
|
|
|
|
std::vector<Action*>::iterator iter;
|
|
|
|
|
|
for (iter = s_vActions.begin(); iter != s_vActions.end();)
|
|
|
|
|
|
{
|
|
|
|
|
|
if ((*iter)->isRunning() && (*iter)->_exec(nNow))
|
|
|
|
|
|
{
|
|
|
|
|
|
// _exec <20><><EFBFBD><EFBFBD> true ʱ˵<CAB1><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
(*iter)->release();
|
|
|
|
|
|
iter = s_vActions.erase(iter);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
iter++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::addAction(Action * action)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (action)
|
|
|
|
|
|
{
|
2017-09-30 16:18:45 +08:00
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
for (auto a : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
assert(a != action);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
2017-09-27 17:56:28 +08:00
|
|
|
|
s_vActions.push_back(action);
|
2017-09-30 16:18:45 +08:00
|
|
|
|
action->_init();
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::startAction(Action * action)
|
|
|
|
|
|
{
|
|
|
|
|
|
resumeAction(action);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::resumeAction(Action * action)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto act : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (act == action)
|
|
|
|
|
|
{
|
|
|
|
|
|
act->resume();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::pauseAction(Action * action)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto act : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (act == action)
|
|
|
|
|
|
{
|
|
|
|
|
|
act->pause();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::stopAction(Action * action)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto act : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (act == action)
|
|
|
|
|
|
{
|
|
|
|
|
|
act->stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::startSpriteAllActions(Sprite * sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
resumeSpriteAllActions(sprite);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::resumeSpriteAllActions(Sprite * sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (action->m_pParent == sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->resume();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::pauseSpriteAllActions(Sprite * sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (action->m_pParent == sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->pause();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::stopSpriteAllActions(Sprite * sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (action->m_pParent == sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::startAllActions()
|
|
|
|
|
|
{
|
|
|
|
|
|
resumeAllActions();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::resumeAllActions()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->resume();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::pauseAllActions()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->pause();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::stopAllActions()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->stop();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|