Ejemplo n.º 1
0
void CCTextureWatcher::dovisit()
{
    if (m_bFresh)
    {
        if (m_pTextures)
        {
            m_pTextures->removeAllObjects();
            m_pTextures->release();
        }

        CCTextureCache::sharedTextureCache()->removeUnusedTextures();
        m_pTextures = CCTextureCache::sharedTextureCache()->snapshotTextures();
        m_nTotalPage = (m_pTextures->count() + NUM_PER_PAGE - 1) / NUM_PER_PAGE;
        if (m_pTextures->count() > 0)
        {
            m_bFresh = false;
            m_pList->reload();
        }
    }
    CCNode *pParent = m_pLayer->getParent();
    if (pParent)
    {
        if (pParent != CCDirector::sharedDirector()->getRunningScene())
        {
            pParent->removeChild(m_pLayer, true);
            CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
            m_bFresh = true;
        }
    }
    else
    {
        CCDirector::sharedDirector()->getRunningScene()->addChild(m_pLayer, 9998);
    }

    pParent = m_menuHide->getParent();
    if (pParent)
    {
        if (pParent != CCDirector::sharedDirector()->getRunningScene())
        {
            pParent->removeChild(m_menuHide, true);
            CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
        }
    }
    else
    {
        CCDirector::sharedDirector()->getRunningScene()->addChild(m_menuHide, 9999);
    }
}
Ejemplo n.º 2
0
bool TapSprite::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    if(status->getAnimationFlg()) return false;
    
    // タッチ開始処理
    
    // タッチ位置を取得
    CCPoint point = pTouch->getLocation();
    // スプライトの大きさ
    CCSize size = this->getTexture()->getContentSize();
    // スプライトの範囲
    CCRect rect = CCRectMake(this->getPositionX()-size.width/2, this->getPositionY()-size.height/2, size.width, size.height);
    
    // タッチ位置がスプライト内ならイベント処理するのでtrueを返す
    if(rect.containsPoint(point)){
        status->setWaitFlg(false);
        status->setChangeFlg(false);
        CCNode* parent;
        CCSprite* sprite;
        sprite = status->getSprite(thisx,thisy);
        parent = sprite->getParent();
        parent->removeChild(sprite);
        parent->addChild(sprite);
        //this->setPosition(point);
        this->setPosition(ccp(point.x,point.y + 25));
        return true;
    }else{
        return false;
    }
}
Ejemplo n.º 3
0
//#hy: 会崩溃,暂时不要调用
void CCtrlPage::ClearPages()
{
	VECPAGES::iterator it = m_vecPageItem.begin();
	VECPAGES::iterator endit = m_vecPageItem.end();

	for (; it != endit; ++it)
	{
		LPPageItemAtt pItem = *it;

		if (NULL != pItem && NULL != pItem->pObj)
		{
			if (m_pScrollView)
			{
				CCNode* pContainer = m_pScrollView->getContainer();
				if (pContainer)
				{
					pContainer->removeChild(pItem->pObj, true);
				}
			}

			if (pItem->bAutoDestory)
			{
				CC_SAFE_RELEASE(pItem->pObj);
			}
		}

		CC_SAFE_DELETE(pItem);
	}

	m_vecPageItem.clear();
}
Ejemplo n.º 4
0
void Image::loadAnimation(const char* filename, int capacity)
{
    imageFile = filename;
    spriteSheet = CCSpriteBatchNode::create(imageFile.append(".png").c_str(), capacity);
    imageFile.erase(imageFile.length() - 4, 4);
    spriteSheet->retain();
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(imageFile.append(".plist").c_str());
    imageFile.erase(imageFile.length() - 6, 6);
    
    spritesName = CCArray::createWithCapacity(capacity);
    spritesName->retain();
    for(int i = 1; i <= capacity; i++)
    {
        /*char num[10];
         sprintf(num, "%04d", i);*/
        spritesName->addObject(ScreateF("%s_%02d.png", filename, i));//imageFile.append(num).append(".png")));
    }
    CCSpriteFrame* firstFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(((CCString*)spritesName->objectAtIndex(0))->getCString());
    delegate->setDisplayFrame(firstFrame);
    CCNode* parent = delegate->getParent();
    parent->addChild(spriteSheet);
    parent->removeChild(delegate, false);
    spriteSheet->addChild(delegate);
    runningAnimation = NULL;
}
Ejemplo n.º 5
0
BloodBar::~BloodBar()
{
	if (m_bgFrame)
	{
		CCNode* pParent = m_bgFrame->getParent();
		if (pParent)
		{
			pParent->removeChild(m_bgFrame);
		}
	}
	if (m_frFrame)
	{
		CCNode* pParent = m_frFrame->getParent();
		if (pParent)
		{
			pParent->removeChild(m_frFrame);
		}		
	}
}
Ejemplo n.º 6
0
void HSGameGuide::Stop()
{
	CCNode* p = this->getParent();
	if (!p)
	{
		return;
	}
	this->setTouchEnabled(false);
	p->removeChild(this,false);
	this->setVisible(false);
}
Ejemplo n.º 7
0
void Ship::destroy()
{
        g_LIFE--;
        CCPoint p = getPosition();
        CCNode* myParent = getParent();
		Explosion* exp = new Explosion();
		exp->setPosition(p);
		myParent->addChild(exp);
		exp->release();
        myParent->removeChild(this,true);
        if (SOUND) {
			SimpleAudioEngine::sharedEngine()->playEffect(s_shipDestroyEffect);
        }
}
Ejemplo n.º 8
0
void TapSprite::eraseSoldierMap(int x,int y){
    
    status->setEraseFlg(combo, x, y);
    
    // 削除対象ノードにペアレントが存在する場合は切り離して捨てる
    CCNode* parent;
    CCSprite* sprite;
    sprite = status->getSprite(x,y);
    
    if(!sprite) return;
    parent = sprite->getParent();
    
    if(!parent) return;
    parent->removeChild(sprite);
    
    status->setSprite(NULL, x, y);
}
Ejemplo n.º 9
0
void TapSprite::eraseSoldierInstance(CCObject* sprite){
    CCNode* mParent;
    if(!sprite) return;
    mParent = ((CCSprite*)sprite)->getParent();
    
    if(!mParent) return;
    mParent->removeChild(((CCSprite*)sprite));
    
    animation--;
    
    if(animation == 0){
        if(!eraseSoldier()){
            loopx = 0;
            loopy = 0;
            fillSoldierAnim();
        }
    }
}
Ejemplo n.º 10
0
void TapSprite::labelClear(){
    std::vector<CCLabelTTF*>::iterator it = labelVec.begin();  // イテレータのインスタンス化
    while( it != labelVec.end() )  // 末尾要素まで
    {
        // 削除対象ノードにペアレントが存在する場合は切り離して捨てる
        CCNode* parent;
        CCLabelTTF* label = *it;
        
        if(!label) return;
        parent = label->getParent();
        
        if(!parent) return;
        parent->removeChild(label);
        
        it++;
    }
    labelVec.clear();
}
Ejemplo n.º 11
0
void SpriteDecorationBatchNode::RemoveShadow(CCNode* pNode)
{
	if (pNode)
	{
		std::map<CCNode*,CCSprite*>::iterator iter = m_playerShadows.find(pNode);
		if (iter != m_playerShadows.end())
		{
			CCSprite* pShadowSprite = (*iter).second;
			if (pShadowSprite)
			{
				CCNode* pParentNode = pShadowSprite->getParent();
				if (pParentNode)
				{
					pParentNode->removeChild(pShadowSprite);
				}
			}
			m_playerShadows.erase(iter);
		}
	}
}
Ejemplo n.º 12
0
KDvoid Enemy::destroy ( KDvoid )
{
	CCNode*        pParent = this->getParent ( );
	const CCPoint&  tPoint = this->getPosition ( );

	if ( !m_bActive )
	{
		Global::nScore += m_nScoreValue;
		Global::playEffect ( PATH_SOUND_EXPLODE );

		Explosion*  pExplosion = Explosion::create ( );
		pExplosion->setPosition ( tPoint );
		pParent->addChild ( pExplosion );
    
		spark ( tPoint, pParent, 1.2f, 0.7f );
	}

	Global::pEnemyContainer->removeObject ( this );
    pParent->removeChild ( this, KD_TRUE );
}
Ejemplo n.º 13
0
//#hy: 会崩溃,暂时不要调用
void CCtrlPage::RemovePageItem(int nIndex)
{
	if (static_cast<int>(m_vecPageItem.size()) <= nIndex || 0 > nIndex)
	{
		return ;
	}

	VECPAGES::iterator it = m_vecPageItem.begin();
	std::advance(it, nIndex);
	LPPageItemAtt pItem = *it;

	if (NULL != pItem && NULL != pItem->pObj)
	{
		if (m_pScrollView)
		{
			CCNode* pContainer = m_pScrollView->getContainer();
			if (pContainer)
			{
				pContainer->removeChild(pItem->pObj, true);
			}
		}

		if (pItem->bAutoDestory)
		{
			CC_SAFE_RELEASE(pItem->pObj);
		}
	}

	CC_SAFE_DELETE(pItem);
	m_vecPageItem.erase(it);

	if (0 == m_vecPageItem.size())
	{
		m_nPageIndex = -1;
	}

	ResetPagePos();
}
Ejemplo n.º 14
0
void TapSprite::changeSoldier(int x, int y){
    
    int i;
    if(x){
        i = abs(x);
    }else{
        i = abs(y);
    }
    
    int absx = 0;
    if(x > 0){
        absx = 1;
    }else if (x < 0){
        absx = -1;
    }
    int absy = 0;
    if(y > 0){
        absy = 1;
    }else if (y < 0){
        absy = -1;
    }
    
    int destx = thisx;
    int desty = thisy;
    
    for(int j = 0;j < i;j++){
        if(x > 0){
            destx++;
        }else if(x < 0){
            destx--;
        }
        if(y > 0){
            desty++;
        }else if(y < 0){
            desty--;
        }
        
        CCSize size = this->getTexture()->getContentSize();
        CCSprite* dest = status->getSprite(destx,desty);
        
        CCNode* parent;
        CCSprite* sprite;
        
        parent = dest->getParent();
        parent->removeChild(dest);
        parent->addChild(dest);
        
        sprite = status->getSprite(thisx,thisy);
        parent = sprite->getParent();
        parent->removeChild(sprite);
        parent->addChild(sprite);
        
        CCPointArray* pAry = CCPointArray::create(3);
        pAry->addControlPoint(ccp(0,0));
        dest->stopAllActions();
        dest->setPosition(ccp((size.width * (destx)) + size.width/2 + 5, (size.height * (desty)) + size.height/2));
        if(x && y){
            pAry->addControlPoint(ccp(size.width * (-absx) * 0.75f, size.height * (-absy) * 0.25f ));
        }
        else if(x){
            pAry->addControlPoint(ccp(size.width * 0.5f * (-absx), -size.height * 0.5f ));
        }
        else if(y){
            pAry->addControlPoint(ccp(size.width * 0.5f,size.height * 0.5f *  (-absy)));
        }
        pAry->addControlPoint(ccp(size.width * (-absx),size.height *  (-absy)));
        dest->runAction(CCCardinalSplineBy::create(0.125f, pAry,1.0f));
        
        ((TapSprite*)dest)->setPlace(thisx,thisy);
        
        int tempStatus = status->getSoldier(destx, desty);
        status->setSoldier(status->getSoldier(thisx, thisy),destx, desty);
        status->setSoldier(tempStatus,thisx,thisy);
        
        status->setSprite(status->getSprite(thisx, thisy),destx, desty);
        status->setSprite(dest,thisx,thisy);
        
        thisx = destx;
        thisy = desty;
        
    }
}