Example #1
0
void CCButton::setState(CCControlState mState)
{
    ////set background node
    CCNode * bgNode = backgroundImageForState(mState);
    if (bgNode != NULL) {
        bgNode->setTag(CCButtonBgTag);
        CCNode * mTepNode = this->getChildByTag(CCButtonBgTag);
        if (mTepNode != NULL) {
            mTepNode->removeFromParentAndCleanup(true);
        }
        this->addChild(bgNode, CCButtonZorder0);
    }

    //set touch node
    CCNode * stateNode = imageForState(mState);
    if (stateNode != NULL) {
        stateNode->setTag(CCButtonTouchedTag);
        CCNode * mTepNode = this->getChildByTag(CCButtonTouchedTag);
        if (mTepNode != NULL) {
            mTepNode->removeFromParentAndCleanup(true);
        }
        this->addChild(stateNode, CCButtonZorder1);
    }

    //set title node
    const char*  titleForState = this->titleForState(mState);
    if (titleForState != NULL) {
        this->setTitleForState(titleForState,mState);
    }
}
Example #2
0
void GameScene::ccTouchEnded(cocos2d::CCTouch *pTouch, cocos2d::CCEvent *pEvent){
    
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCPoint touchPoint = pDirector->convertToGL(pTouch->getLocationInView());
  
    CCNode* pCard = this->getChildByTag(nextNumber);
    if (!pCard)
    {
        return;
    }
    
    CCRect cardRect = pCard->boundingBox();
    if (cardRect.containsPoint(touchPoint)) {
        CCSprite* pNewCard = CCSprite::create("card_backside.png");
        pNewCard->setPosition(pCard->getPosition());
        this->addChild(pNewCard);
        
        pCard->removeFromParentAndCleanup(true);
        
        if (nextNumber >= 25)
        {
            this->unschedule(schedule_selector(GameScene::measureGametime));
            showHighScoreLabel();
            return;
        }
        nextNumber++;
    }
    
    //CCLog("x: %f, y:%f", touchPoint.x, touchPoint.y);
}
void DamageValueEffect::update(float dt)
{
	map<CCNode*,float>::iterator it= m_pDamageLabels->begin();
	while(it != m_pDamageLabels->end())
	{
		float time = it->second;
		time -= dt;
		if(time <= 0)
		{
			CCNode* label = it->first;
			if(label)
			{
				label->stopAllActions();
				label->removeFromParentAndCleanup(true);
				m_pDamageLabels->erase(it++);
				label = NULL;
			}
		}
		else
		{
			it->second = time;
			it++;
		}
	}

}
Example #4
0
void ListViewLayer::reloadData(ListViewDataSource source)
{
	// 容器不能为空
	CCAssert(source.listViewContainer != NULL,"");

	// 目前已经有的容器
	CCNode* container = getChildByTag(TAG_LIST_CONTAINER);


	if (source.listViewContainer != container)
	{
		// 把旧的移除
		if (container)
			container->removeFromParentAndCleanup(true);

		// 添加新的
		mSource = source;
		addChild(mSource.listViewContainer,0,TAG_LIST_CONTAINER);
		mTableView = CCTableView::create(this, mSource.listViewContainer->getContentSize());
		mTableView->setDirection(mSource.dir);
		mTableView->setPosition(ccp(0,0));
		mTableView->setDelegate(this);
		mSource.listViewContainer->addChild(mTableView);
	}

	mSource = source;
	mTableView->reloadData();
}
Example #5
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;
}
Example #6
0
void CommDlg::setNoCancel()
{
    CCNode *cancelBtn = getChildByTag(kCommBtnTagCancel);
    CCNode *cancelTxt = getChildByTag(kCommTextTagCancel);
    CCNode *okBtn = getChildByTag(kCommBtnTagOk);
    CCNode *okTxt = getChildByTag(kCommTextTagOk);
    
    //没有Ok按钮,就不要删cancel按钮了,否则没按钮了
    if (okBtn == NULL) {
        return;
    }
    
    if(cancelBtn)
    {
        cancelBtn->setIsVisible(false);
        cancelBtn->removeFromParentAndCleanup(true);
        cancelBtn=NULL;
    }
    
    if(cancelTxt)
        cancelTxt->setIsVisible(false);
    if(okBtn)
        okBtn->setPosition(CCPointMake(0, -78));
    if(okTxt)
        okTxt->setPosition(CCPointMake(-4, -74));
    
}
void CCBProxy::releaseMembers(){
	CCDictElement *e;
	CCNode *n;
	CCDICT_FOREACH(_memVars, e){
		n = (CCNode *)e->getObject();
		n->removeFromParentAndCleanup(true);
		n->autorelease();
	}
Example #8
0
void CartoonMoveAction::stop(void)
{
	CCNode *tempTarget = m_pTarget; 
	CCMoveTo::stop();
	cartoonInfo.release();
	if (isTempTarget)
	{
		tempTarget->removeFromParentAndCleanup(true);
	}
}
Example #9
0
// remove objects
void LCWordCloudLayer::removeAll()
{
	for (int i=0; i<m_pNodeArray->count(); i++) {
		CCNode* node = (CCNode*) m_pNodeArray->objectAtIndex(i);
		if (node->getParent()) {
			node->removeFromParentAndCleanup(true);
		}
	}
	this->m_pNodeArray->removeAllObjects();
	this->resetNodesPosition();
}
Example #10
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;
}
Example #11
0
void HeroHeadView::onMenuItemClicked(cocos2d::CCObject *pTarget)
{
    cocos2d::CCNode *p = static_cast<cocos2d::CCNode *>(pTarget);
    printf("tag %d\n",p->getTag());
    
    if(p->getTag() == 1){
        CCNode *pNode = this->getChildByTag(TAG_PLAYER_INFO);
        if (!pNode)
        {
            PlayerInfoView *pInfo = PlayerInfoView::create(this);
            this->addChild(pInfo);
            pInfo->setTag(TAG_PLAYER_INFO);
        }
        else {
            pNode->removeFromParentAndCleanup(true);
        }
    }
}
void TitleNode::onProgressEnded(CCObject* sender) {
    CCLog("TitleNode::onProgressEnded");
    
    CCNode* node = dynamic_cast<CCNode*>(sender);
    node->removeFromParentAndCleanup(true);
    
    CCSize designResoulutionSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize();
    
    CCLabelTTF* touchToStart = CCLabelTTF::create("Touch to Start!", "Arial", 15);
    touchToStart->setAnchorPoint(ccp(0.5f, 1));
    touchToStart->setPosition(ccp(designResoulutionSize.width/2, designResoulutionSize.height/2-100));
    touchToStart->setColor(ccRED);
    this->addChild(touchToStart);
    
    FiniteStateMachine::getInstance()->setState(CommonEnum::eStateStages);
    
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
}
void EquipmentUpgradeUILayer::playUpgradeEffect()
{
	if(m_choosedEquipmentPic && m_choosedEquipmentPic->getCurrentNode())
	{
		CCNode* particle = ParticleManagerX::sharedManager()->getParticles_uieffect("particle_effect_upgradesuccess");
		if(particle != NULL)
		{
			CCNode* child = m_choosedEquipmentPic->getCurrentNode()->getChildByTag(100);
			if(child)
			{
				child->removeFromParentAndCleanup(true);
				child = NULL;
			}
			m_choosedEquipmentPic->getCurrentNode()->addChild(particle,100,100);
			particle->setPosition(ccp(m_choosedEquipmentPic->getCurrentNode()->getContentSize().width * 0.5,m_choosedEquipmentPic->getCurrentNode()->getContentSize().height * 0.5));
		}
	}
}
Example #14
0
void QimiAlipayView::onLoadOrderSucssful(cocos2d::extension::CCHttpClient *sender, cocos2d::extension::CCHttpResponse *response)
{
    CCNode* node = this->getChildByTag(100000);
    if (node!=NULL)
    {
        node->removeFromParentAndCleanup(true);
    }
    
    Json::Value root = GameUtils::getResponseData(response);
    
    if (root == NULL)
    {
        QimiPlatform::shareQimiPlatform()->openAlertDailog("系统提示", "服务器异常,请稍后再试");
        return;
    }
    
    if (!root.isNull())
    {
        m_oderId= root["data"].asString();
    }
    loadAlixPay();
}
Example #15
0
void GameScene::hideStageLogo()
{
	CCNode* stageLogo = this->getChildByTag(kTagStageLogo);
	stageLogo->removeFromParentAndCleanup(true);
}
Example #16
0
void TutorialNode::removeNode(void *obj) {
  CCNode* node = (CCNode*)obj;
  node->removeFromParentAndCleanup(true);
}
Example #17
0
void CCINode::showFrame(){
    //std::vector<CCIMovieTag *> tags = this->swfMovie->getTags();

    while (true) {
        CCIMovieTag * tag = NULL;
        
        if (currentTag<tags.size()) {
            tag = tags[currentTag++];
        }else{
            
            this->removeAllChildrenWithCleanup(true);
            //this->stop();
            currentTag = 0;
            currentFrame = 0;
            break;
        }
        if(tag->getTagType()==TagTypePlaceObject||tag->getTagType()==TagTypePlaceObject2||tag->getTagType()==TagTypePlaceObject3){
            CCIPlaceObject * placeTag = (CCIPlaceObject *)tag;
            
            int charactorId = placeTag->getCharacterId();
            int depth = placeTag->getDepth();
            
            
            CCIPlaceObject2 * placeTag2 = NULL;
            if (tag->getTagType()==TagTypePlaceObject2||tag->getTagType()==TagTypePlaceObject3) {
                placeTag2 = (CCIPlaceObject2 *)tag;
            }
            
            CCNode * node;
            if (!placeTag2||placeTag2->placeType==PlaceObjectTypeNew) {
                //place1 or placetag2 new
                node = (CCNode *)this->nodes->objectForKey(charactorId);
                if (node&&node->getParent()==NULL) {
                    this->addChild(node, depth, depth);
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->play();
                    }
                }
            }else if(placeTag2&&placeTag2->placeType==PlaceObjectTypeModify){
                node = (CCNode *)this->getChildByTag(depth);
            }else if(placeTag2&&placeTag2->placeType==PlaceObjectTypeReplace){
                
                CCNode * newNode = (CCNode *)this->nodes->objectForKey(charactorId);
                
                node = (CCNode *)this->getChildByTag(depth);
                if (node) {
                    if (newNode) {
                        //get last transform matrix
                        newNode->setPosition(node->getPosition());
                        newNode->setScaleX(node->getScaleX());
                        newNode->setScaleY(node->getScaleY());
                        newNode->setSkewX(node->getSkewX());
                        newNode->setSkewY(node->getSkewY());
                    }
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->stop();
                    }
                    node->removeFromParentAndCleanup(true);
                }
                
                node = newNode;
                if (node&&node->getParent()==NULL) {
                    this->addChild(node, depth, depth);
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->play();
                    }
                }
                
            }
            
            if (node) {
                CCIMatrix * matrix = placeTag->getMatrix();
                if (matrix) {
                    int x = matrix->getTranslateX();
                    int y = matrix->getTranslateY();
                    
                    node->setPosition(this->swfMovie->getHeader()->getBounds()->convertToCCSpace(x, y));
                    //restore
                    float scaleX = 1.0;
                    float scaleY = 1.0;
                    node->setScaleX(1);
                    node->setScaleY(1);
                    node->setSkewX(0);
                    node->setSkewY(0);
                    
                    if (matrix->HasScale) {
                        scaleX = matrix->getScaleX();
                        scaleY = matrix->getScaleY();
                        node->setScaleX(scaleX);
                        node->setScaleY(scaleY);
                    }
                    if (matrix->HasRotate) {
                        float skewX = matrix->getSkewX();
                        float skewY = matrix->getSkewY();
                        
                        this->applySkew(node, skewX, skewY,false);
                    }
                    
                }
                CCICxform * colorTransform = placeTag->getColorTransform();
                
                int red = 255;
                int green = 255;
                int blue = 255;
                int alpha = 255;
                
                if (colorTransform) {
                    if (colorTransform->HasMultTerms) {
                        red = colorTransform->RedMultTerm-1;
                        green = colorTransform->GreenMultTerm-1;
                        blue = colorTransform->BlueMultTerm-1;
                        if (colorTransform->hasAlpha()) {
                            CCICxformWithAlpha * cxformAlpha = (CCICxformWithAlpha *)colorTransform;
                            alpha = cxformAlpha->AlphaMultTerm-1;
                        }
                    }
                    
                    if (colorTransform->HasAddTerms) {
                        //TODO no add term
                    }
                    if (red==-1) {
                        red = 0;
                    }
                    if (green ==-1) {
                        green = 0;
                    }
                    if (blue == -1) {
                        blue = 0;
                    }
                    if (alpha ==-1) {
                        alpha = 0;
                    }
                }
                
                this->applyColorTransform(node, ccc4(red, green, blue, alpha));
                
                if (tag->getTagType()==TagTypePlaceObject3) {
                    //check filters
                    CCIPlaceObject3 * placeTag3 = (CCIPlaceObject3 *)tag;
                    
                    CCIFilterList * filterList = placeTag3->getFilterList();
                        
                    if (filterList) {
                        //apply filter list
                        for (int i=0; i<filterList->NumberOfFilters; i++) {
                            //CCIFilter * filter = filterList->Filter[i];
                            
                        }
                    }
                }
            }
        }else if (tag->getTagType()==TagTypeRemoveObject||tag->getTagType()==TagTypeRemoveObject2){
            CCIRemoveObject * removeTag = (CCIRemoveObject *)tag;
            int depth = removeTag->getDepth();
            CCNode * node = this->getChildByTag(depth);
            if (node) {
                CCInteger * nodeType = (CCInteger *)node->getUserObject();
                if (nodeType->getValue()==NodeTypeCCINode) {
                    CCINode * ccinode = (CCINode *)node;
                    ccinode->stop();
                }
                node->removeFromParentAndCleanup(true);
            }
        }else if(tag->getTagType()==TagTypeFrameLabel){
            if (isPlayingFrameLabel&&currentTag!=frameLabelIndex) {
                currentTag = frameLabelIndex;
                currentFrame = 0;
                //this->removeAllChildrenWithCleanup(true);
                break;
            }
        }else if(tag->getTagType()==TagTypeShowFrame){
            if (this->delegate) {
                this->delegate->didEnterFrame(currentFrame, this->frameLabel);
            }
            currentFrame++;
            
            break;
        }
    }
}