This commit is contained in:
Ming 2010-08-30 07:45:39 +00:00
parent 4ac8acdf44
commit b9587a7062
6 changed files with 39 additions and 8 deletions

View File

@ -175,8 +175,7 @@ CCScheduler* CCScheduler::init(void)
void CCScheduler::removeHashElement(_hashSelectorEntry *pElement)
{
ccArrayFree(pElement->timers);
NSObject *pObj = dynamic_cast<NSObject*>(pElement->target);
CCX_SAFE_RELEASE(pObj);
pElement->target->selectorProtocolRelease();
pElement->target = NULL;
HASH_DEL(m_pHashForSelectors, pElement);
free(pElement);
@ -211,7 +210,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *p
pElement->target = pTarget;
if (pTarget)
{
dynamic_cast<NSObject*>(pTarget)->retain();
pTarget->selectorProtocolRetain();
}
HASH_ADD_INT(m_pHashForSelectors, target, pElement);
@ -343,7 +342,7 @@ void CCScheduler::priorityIn(tListEntry **ppList, SelectorProtocol *pTarget, int
// update hash entry for quick access
tHashUpdateEntry *pHashElement = (tHashUpdateEntry *)calloc(sizeof(*pHashElement), 1);
pHashElement->target = pTarget;
dynamic_cast<NSObject*>(pTarget)->retain();
pTarget->selectorProtocolRetain();
pHashElement->list = ppList;
pHashElement->entry = pListElement;
HASH_ADD_INT(m_pHashForUpdates, target, pHashElement);
@ -362,7 +361,7 @@ void CCScheduler::appendIn(_listEntry **ppList, SelectorProtocol *pTarget, bool
// update hash entry for quicker access
tHashUpdateEntry *pHashElement = (tHashUpdateEntry *)calloc(sizeof(*pHashElement), 1);
pHashElement->target = pTarget;
dynamic_cast<NSObject*>(pTarget)->retain();
pTarget->selectorProtocolRetain();
pHashElement->list = ppList;
pHashElement->entry = pListElement;
HASH_ADD_INT(m_pHashForUpdates, target, pHashElement);
@ -409,8 +408,7 @@ void CCScheduler::unscheduleUpdateForTarget(const SelectorProtocol *pTarget)
free(pElement->entry);
// hash entry
NSObject *pObj = dynamic_cast<NSObject*>(pElement->target);
CCX_SAFE_RELEASE(pObj);
pElement->target->selectorProtocolRelease();
pElement->target = NULL;
HASH_DEL(m_pHashForUpdates, pElement);
free(pElement);

View File

@ -60,6 +60,16 @@ void CCActionManager::purgeSharedManager(void)
CCX_SAFE_RELEASE(gSharedManager);
}
void CCActionManager::selectorProtocolRetain()
{
retain();
}
void CCActionManager::selectorProtocolRelease()
{
release();
}
CCActionManager::CCActionManager(void)
{
assert(gSharedManager == NULL);

View File

@ -876,6 +876,16 @@ void CCNode::pauseSchedulerAndActions()
CCActionManager::getSharedManager()->pauseTarget(this);
}
void CCNode::selectorProtocolRetain(void)
{
retain();
}
void CCNode::selectorProtocolRelease(void)
{
release();
}
CGAffineTransform CCNode::nodeToParentTransform(void)
{
if ( m_bIsTransformDirty ) {

View File

@ -124,6 +124,11 @@ public:
@since v0.99.0
*/
void purgeSharedManager(void);
// SelectorProtocol methods
virtual void selectorProtocolRetain(void);
virtual void selectorProtocolRelease(void);
public:
// returns a shared instance of the CCActionManager

View File

@ -219,7 +219,6 @@ private:
CGPoint convertToWindowSpace(CGPoint nodePoint);
public:
CCNode();
@ -442,6 +441,11 @@ public:
*/
void pauseSchedulerAndActions(void);
// SelecterProtocol methods
virtual void selectorProtocolRetain(void);
virtual void selectorProtocolRelease(void);
// transformation methods

View File

@ -41,6 +41,10 @@ public:
virtual void callfunc(CCNode* pSender){};
virtual void callfunc(CCNode* pSender, void* pData){};
virtual void menuHandler(NSObject* pSender){};
// the child call responding retain/release function
virtual void selectorProtocolRetain(void) {};
virtual void selectorProtocolRelease(void) {};
};
class CCNode;