fixed #1386: PauseResumeActionsTest crashes.

This commit is contained in:
James Chen 2012-07-24 11:21:08 +08:00
parent 221d06509a
commit e7d7ff99c7
2 changed files with 19 additions and 2 deletions

View File

@ -1628,6 +1628,18 @@ string ActionCardinalSpline::subtitle()
/** PauseResumeActions
*/
PauseResumeActions::PauseResumeActions()
: m_pPausedTargets(NULL)
{
}
PauseResumeActions::~PauseResumeActions()
{
CC_SAFE_RELEASE(m_pPausedTargets);
}
void PauseResumeActions::onEnter()
{
ActionsDemo::onEnter();
@ -1656,12 +1668,15 @@ void PauseResumeActions::pause(float dt)
{
CCLog("Pausing");
CCDirector *director = CCDirector::sharedDirector();
this->m_pPausedTargets = director->getActionManager()->pauseAllRunningActions();
CC_SAFE_RELEASE(m_pPausedTargets);
m_pPausedTargets = director->getActionManager()->pauseAllRunningActions();
CC_SAFE_RETAIN(m_pPausedTargets);
}
void PauseResumeActions::resume(float dt)
{
CCLog("Resuming");
CCDirector *director = CCDirector::sharedDirector();
director->getActionManager()->resumeTargets(this->m_pPausedTargets);
director->getActionManager()->resumeTargets(m_pPausedTargets);
}

View File

@ -367,6 +367,8 @@ private:
class PauseResumeActions : public ActionsDemo
{
public:
PauseResumeActions();
virtual ~PauseResumeActions();
virtual void onEnter();
virtual std::string subtitle();
virtual std::string title();