本文整理汇总了C++中CCNode::release方法的典型用法代码示例。如果您正苦于以下问题:C++ CCNode::release方法的具体用法?C++ CCNode::release怎么用?C++ CCNode::release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCNode
的用法示例。
在下文中一共展示了CCNode::release方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restoreAllPriorities
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: TestClazzReleased
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: menuCloseCallback
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:
CCBAnimationManager::~CCBAnimationManager()
{
CCDictElement *pElement = NULL;
CCDICT_FOREACH(mNodeSequences, pElement)
{
CCNode *node = (CCNode*)pElement->getIntKey();
node->release();
}
示例5: ccTouchBegan
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;
}
}