예제 #1
0
CCObject *HTouchEnabledLayerColor::dismissNodeEx(int command, HEndDismissNode *notify) {
    CCNode *node = notify->getNode();
    do {
        if (node->getParent() != this) break;
        HBakNodeInfo *info = NULL;
        for (int i = m_pBakNodeList->count() - 1; i >= 0; --i) {
            info = (HBakNodeInfo *)m_pBakNodeList->objectAtIndex(i);
            if (node == info->m_pNode) {
                break;
            }
            info = NULL;
        }
        if (!info) break;
        
        node->retain();
        node->removeFromParentAndCleanup(false);
        info->m_pParent->addChild(node, info->m_iIndex);
        node->setScaleX(info->m_fScaleX);
        node->setScaleY(info->m_fScaleY);
        node->setPosition(info->m_ptPos);
        node->release();
        
        restoreAllPriorities(info);
        m_pBakNodeList->removeObject(info);
    } while (false);
    if (notify->getTarget() && notify->getAction()) {
        (notify->getTarget()->*notify->getAction())(node);
    }
    return NULL;
}
예제 #2
0
TEST( Notifier, TestOfNotificationUseAfterRelease )
{
	Notifier notifier;

	TestClazzReleased* pReleasedNode = new TestClazzReleased( notifier );
	pReleasedNode->init();

	CCNode* pHolder = new CCNode();
	pHolder->init();
	notifier.addNotification( getNotificationTestUseAfterRelease(), {pHolder, &CCNode::removeAllChildren } );

	EXPECT_EQ( 1u, pReleasedNode->retainCount() );
	EXPECT_EQ( 1u, pHolder->retainCount() );

	pHolder->addChild( pReleasedNode );

	EXPECT_EQ( 2u, pReleasedNode->retainCount() );
	EXPECT_EQ( 1u, pHolder->retainCount() );

	pReleasedNode->release();

	EXPECT_EQ( 1u, pReleasedNode->retainCount() );
	EXPECT_EQ( 1u, pHolder->retainCount() );

	//OLD: Now when we notify we have problem. We have use after release.
	//NEW: Now everything should work because we mark second notification as toRemove so we simply skip it :)
	notifier.notify( getNotificationTestUseAfterRelease() );

	pHolder->release();
}
예제 #3
0
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
    //CCDirector::sharedDirector()->end();

//#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    //exit(0);
//    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
//    CCBReader* reader = new CCBReader(ccNodeLoaderLibrary);
//    CCScene* scene = reader->createSceneWithNodeGraphFromFile("TeLabels.ccbi");
//    CCDirector::sharedDirector()->replaceScene(CCTransitionFade::transitionWithDuration(2.0f, scene));
CCLog("1");
    
    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    CCLog("2");
    CCBReader* reader = new CCBReader(ccNodeLoaderLibrary);
    CCLog("3");
    CCNode* scene = reader->readNodeGraphFromFile("TestLabels.ccbi");
    CCLog("4");
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    scene->setPosition(ccp(size.width/2, size.height/2));
                                                  if(scene != NULL)
                                                  {
                                                      this->addChild(scene, 2);
                                                      scene->release();
                                                  }
    CCLog("5");
//#endif
}
예제 #4
0
CCBAnimationManager::~CCBAnimationManager()
{
    CCDictElement *pElement = NULL;
    CCDICT_FOREACH(mNodeSequences, pElement)
    {
        CCNode *node = (CCNode*)pElement->getIntKey();
        node->release();
    }
예제 #5
0
CCObject *HTouchEnabledLayerColor::dismissAllNodesEx(int command, CCObject *param) {
    HBakNodeInfo *info = NULL;
    for (int i = m_pBakNodeList->count() - 1; i >= 0; --i) {
        info = (HBakNodeInfo *)m_pBakNodeList->objectAtIndex(i);
        CCNode *node = info->m_pNode;
        node->retain();
        node->removeFromParentAndCleanup(false);
        info->m_pParent->addChild(node, info->m_iIndex);
        node->setScaleX(info->m_fScaleX);
        node->setScaleY(info->m_fScaleY);
        node->setPosition(info->m_ptPos);
        node->release();
        restoreAllPriorities(info);
    }
    m_pBakNodeList->removeAllObjects();
    return NULL;
}
예제 #6
0
bool CCScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    CC_SAFE_RELEASE_NULL(m_touchNode);
    const CCPoint p = pTouch->getLocation();
    CCObject *node;
    CCNode *touchNode = NULL;
    CCNode *checkNode = NULL;
    bool visible = true;
    sortAllTouchableNodes();
    CCARRAY_FOREACH(m_touchableNodes, node)
    {
        checkNode = touchNode = dynamic_cast<CCNode*>(node);

        // check node is visible
        visible = true;
        do
        {
            visible = visible && checkNode->isVisible();
            checkNode = checkNode->getParent();
        } while (checkNode && visible);
        if (!visible) continue;

        const CCRect boundingBox = touchNode->getCascadeBoundingBox();
        if (boundingBox.containsPoint(p))
        {
            touchNode->retain();
            bool ret = touchNode->ccTouchBegan(pTouch, pEvent);
            if (ret && touchNode->isRunning())
            {
                m_touchNode = touchNode;
                m_touchNode->retain();
            }
            touchNode->release();
            if (ret) return true;
        }
    }
예제 #7
0
 CCDICT_FOREACH(mBaseValues, pElement)
 {
     CCNode *node = (CCNode*)pElement->getIntKey();
     node->release();
 }