diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 0136d493e2..2782314e4f 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -103,7 +103,7 @@ CCObject* CCShow::copyWithZone(CCZone *pZone) { pZone = pNewZone = new CCZone(pRet); } - CCFiniteTimeAction::copyWithZone(pZone); + CCActionInstant::copyWithZone(pZone); CC_SAFE_DELETE(pNewZone); return pRet; } @@ -141,7 +141,7 @@ CCObject* CCHide::copyWithZone(CCZone *pZone) { pZone = pNewZone = new CCZone(pRet); } - CCFiniteTimeAction::copyWithZone(pZone); + CCActionInstant::copyWithZone(pZone); CC_SAFE_DELETE(pNewZone); return pRet; } @@ -149,21 +149,41 @@ CCObject* CCHide::copyWithZone(CCZone *pZone) { // // ToggleVisibility // -CCToggleVisibility * CCToggleVisibility::action() { +CCToggleVisibility * CCToggleVisibility::action() +{ CCToggleVisibility *pRet = new CCToggleVisibility(); - if (pRet) { + if (pRet) + { pRet->autorelease(); } return pRet; } -void CCToggleVisibility::update(ccTime time) { +void CCToggleVisibility::update(ccTime time) +{ CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(!m_pTarget->getIsVisible()); } +CCObject* CCToggleVisibility::copyWithZone(CCZone *pZone) +{ + CCZone *pNewZone = NULL; + CCToggleVisibility *pRet = NULL; + + if (pZone && pZone->m_pCopyObject) { + pRet = (CCToggleVisibility*) (pZone->m_pCopyObject); + } else { + pRet = new CCToggleVisibility(); + pZone = pNewZone = new CCZone(pRet); + } + + CCActionInstant::copyWithZone(pZone); + CC_SAFE_DELETE(pNewZone); + return pRet; +} + // // FlipX // diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index dc19e79823..87b0885965 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -96,6 +96,7 @@ public: virtual ~CCToggleVisibility(){} //super method virtual void update(ccTime time); + virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method /** Allocates and initializes the action */