Action新增getTarget函数,获取执行该动作的目标

This commit is contained in:
Nomango 2017-10-08 12:45:59 +08:00
parent 388337bbef
commit 414cfc156c
3 changed files with 10 additions and 3 deletions

View File

@ -71,6 +71,11 @@ Action * Action::reverse() const
return nullptr;
}
Sprite * Action::getTarget()
{
return m_pTargetSprite;
}
void Action::_reset()
{
m_bEnding = false;

View File

@ -76,7 +76,7 @@ void Sprite::addAction(Action * action)
void Sprite::resumeAction(Action * action)
{
if (action->m_pTargetSprite == this)
if (action->getTarget() == this)
{
ActionManager::resumeAction(action);
}
@ -84,7 +84,7 @@ void Sprite::resumeAction(Action * action)
void Sprite::pauseAction(Action * action)
{
if (action->m_pTargetSprite == this)
if (action->getTarget() == this)
{
ActionManager::pauseAction(action);
}
@ -92,7 +92,7 @@ void Sprite::pauseAction(Action * action)
void Sprite::stopAction(Action * action)
{
if (action->m_pTargetSprite == this)
if (action->getTarget() == this)
{
ActionManager::stopAction(action);
}

View File

@ -1101,6 +1101,8 @@ public:
virtual Action * copy() const = 0;
// 获取一个新的逆向动作
virtual Action * reverse() const;
// 获取执行该动作的目标
virtual Sprite * getTarget();
protected:
bool m_bRunning;