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::PauseResumeActions()
: m_pPausedTargets(NULL)
{
}
PauseResumeActions::~PauseResumeActions()
{
CC_SAFE_RELEASE(m_pPausedTargets);
}
void PauseResumeActions::onEnter() void PauseResumeActions::onEnter()
{ {
ActionsDemo::onEnter(); ActionsDemo::onEnter();
@ -1656,12 +1668,15 @@ void PauseResumeActions::pause(float dt)
{ {
CCLog("Pausing"); CCLog("Pausing");
CCDirector *director = CCDirector::sharedDirector(); 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) void PauseResumeActions::resume(float dt)
{ {
CCLog("Resuming"); CCLog("Resuming");
CCDirector *director = CCDirector::sharedDirector(); 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 class PauseResumeActions : public ActionsDemo
{ {
public: public:
PauseResumeActions();
virtual ~PauseResumeActions();
virtual void onEnter(); virtual void onEnter();
virtual std::string subtitle(); virtual std::string subtitle();
virtual std::string title(); virtual std::string title();