2017-09-27 17:56:28 +08:00
|
|
|
|
#include "..\easy2d.h"
|
2017-10-10 01:14:03 +08:00
|
|
|
|
#include "..\Win\winbase.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()
|
|
|
|
|
|
{
|
2017-10-08 13:26:42 +08:00
|
|
|
|
// <20><>ʱָ<CAB1><D6B8>
|
2017-10-10 01:14:03 +08:00
|
|
|
|
static Action * action;
|
2017-09-27 17:56:28 +08:00
|
|
|
|
// ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>еĶ<D0B5><C4B6><EFBFBD>
|
2017-10-06 01:41:06 +08:00
|
|
|
|
for (size_t i = 0; i < s_vActions.size(); i++)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-10-08 13:26:42 +08:00
|
|
|
|
action = s_vActions[i];
|
|
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬
|
|
|
|
|
|
if (action->isRunning())
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
2017-10-08 13:26:42 +08:00
|
|
|
|
if (action->isEnding())
|
2017-10-08 12:30:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD>
|
2017-10-10 01:32:53 +08:00
|
|
|
|
action->autoRelease();
|
2017-10-08 13:26:42 +08:00
|
|
|
|
action->release();
|
2017-10-08 12:30:45 +08:00
|
|
|
|
s_vActions.erase(s_vActions.begin() + i);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2017-10-08 13:26:42 +08:00
|
|
|
|
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
if (!action->m_bInit)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->_init();
|
|
|
|
|
|
}
|
|
|
|
|
|
// ִ<>ж<EFBFBD><D0B6><EFBFBD>
|
2017-10-10 01:14:03 +08:00
|
|
|
|
action->_exec(GetNow());
|
2017-10-08 12:30:45 +08:00
|
|
|
|
}
|
2017-09-27 17:56:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-10-12 02:44:44 +08:00
|
|
|
|
action->m_pParentScene = EApp::getLoadingScene();
|
2017-10-06 02:32:33 +08:00
|
|
|
|
s_vActions.push_back(action);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-12 23:34:13 +08:00
|
|
|
|
void ActionManager::notifyAllSceneActions(EScene * scene)
|
2017-10-06 02:32:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
2017-10-06 16:40:10 +08:00
|
|
|
|
if (action->m_pParentScene == scene)
|
|
|
|
|
|
{
|
2017-10-08 12:30:45 +08:00
|
|
|
|
action->notify();
|
2017-10-06 16:40:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-12 23:34:13 +08:00
|
|
|
|
void ActionManager::waitAllSceneActions(EScene * scene)
|
2017-10-06 16:40:10 +08:00
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (action->m_pParentScene == scene)
|
2017-10-06 02:32:33 +08:00
|
|
|
|
{
|
2017-10-08 12:30:45 +08:00
|
|
|
|
action->wait();
|
2017-10-06 02:32:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-12 23:34:13 +08:00
|
|
|
|
void ActionManager::stopAllSceneActions(EScene * scene)
|
2017-10-06 02:32:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (action->m_pParentScene == scene)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->stop();
|
|
|
|
|
|
}
|
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)
|
|
|
|
|
|
{
|
2017-10-06 02:32:33 +08:00
|
|
|
|
if (action->m_pTargetSprite == sprite)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
action->resume();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::pauseSpriteAllActions(Sprite * sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
2017-10-06 02:32:33 +08:00
|
|
|
|
if (action->m_pTargetSprite == sprite)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
action->pause();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ActionManager::stopSpriteAllActions(Sprite * sprite)
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
2017-10-06 02:32:33 +08:00
|
|
|
|
if (action->m_pTargetSprite == sprite)
|
2017-09-27 17:56:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
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();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-05 11:28:13 +08:00
|
|
|
|
|
|
|
|
|
|
void ActionManager::clearAllActions()
|
|
|
|
|
|
{
|
|
|
|
|
|
for (auto action : s_vActions)
|
|
|
|
|
|
{
|
|
|
|
|
|
action->autoRelease();
|
|
|
|
|
|
action->release();
|
|
|
|
|
|
}
|
|
|
|
|
|
s_vActions.clear();
|
|
|
|
|
|
}
|