CCLabelAtlas* DamageValueEffect::CreateAddBloodLabel(unsigned int blood,CCPoint parentPos)
{
	CCPoint uiPos = parentPos;
	char damageString[10];
	sprintf(damageString,"%d",blood);
	CCLabelAtlas* lable = CCLabelAtlas::create(damageString,"UI/ui_numble_4.png",41,43,48);

	lable->setPosition(uiPos.x,uiPos.y);
	lable->setAnchorPoint(ccp(0.5,0.5));
	lable->setScale(0);
	CCActionInterval* actionScale = CCScaleTo::create(0.01f,2);
	CCActionInterval* actionMove = CCMoveBy::create(0.01f,ccp(0,40));
	CCSpawn* FirstAction = CCSpawn::createWithTwoActions(actionScale,actionMove);
	CCActionInterval* actionFade = CCFadeOut::create(1.0f);
	CCActionInterval* bezierAction = CCMoveBy::create(1.0f,ccp(0,80));
	CCSpawn* SecondAction = CCSpawn::createWithTwoActions(bezierAction,actionFade);
	lable->runAction(CCSequence::create(FirstAction,CCScaleTo::create(0.05f,0.7f),CCDelayTime::create(0.2f),SecondAction,
		NULL));
	if(m_pDamageLabels->find(lable) == m_pDamageLabels->end())
	{
		m_pDamageLabels->insert(make_pair(lable,1.3f));
		if(GameManager::Get()->GetSceneLayer() != NULL && GameManager::Get()->GetSceneLayer()->getLevelLayer() != NULL
			&& GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer())
		{
			GameManager::Get()->GetSceneLayer()->getLevelLayer()->getObjectLayer()->addChild(lable,MAP_Z_OBJ_TOP);
		}
	}
	return lable;
}
Пример #2
0
//******************************************************************************
// useAutoSkill
//******************************************************************************
void Card::useAutoSkill(float fEffect, int iBaoJi)
{
    float fDur = 0.0;
    
    if(fEffect < -2.0){
        fDur = 0.3;
    }
    else if(fEffect < 0.0){
        fDur = 0.1;
    }
    else{
        m_AtkInfo.iAttackPt *= fEffect;
        m_numAtkVal->setNumber(m_AtkInfo.iAttackPt, 0.6, 0.0);
        
        fDur = 0.3;
    }
    
    CCPoint ptSrc = CCPointMake(0, 0);
    if (getCD() == 0)
        ptSrc = CCPointMake(0, 8);
    CCPoint ptDst = CCPointMake(ptSrc.x, ptSrc.y + 8);
    
    this->stopAllActions();
    this->setPositionInPixels(ptSrc);
    this->runAction(CCSequence::actions(CCMoveTo::actionWithDuration(fDur, ptDst),
                                        CCMoveTo::actionWithDuration(fDur, ptSrc),
                                        NULL));
    
    if (iBaoJi > 0) {
        CCSprite* spBaojiBg = CCSprite::spriteWithSpriteFrameName("baojibg.png");
        if (spBaojiBg) {
            spBaojiBg->setAnchorPoint(CCPointMake(0.5, 0));
            spBaojiBg->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615 + m_spCard->getContentSize().height * 0.5));
            addChild(spBaojiBg,0,kToBeDeleteTag);
        }
        
        CCSprite *sp = CCSprite::spriteWithFile("baojinum.png");
        if (sp) {
            char buf[10];
            snprintf(buf, 9, "/%d", iBaoJi);
            CCLabelAtlas *lbb = CCLabelAtlas::labelWithString(buf,
                                                              "baojinum.png",
                                                              sp->getContentSize().width / 11,
                                                              sp->getContentSize().height, '/');
            lbb->setPositionInPixels(CCPointMake(55 + 106*m_idx, 615 + m_spCard->getContentSize().height * 0.5));
            lbb->setAnchorPoint(CCPointMake(0.5, 0));
            addChild(lbb,0,kToBeDeleteTag);
            
            lbb->runAction(CCSequence::actions(CCDelayTime::actionWithDuration(fDur*2),
                                               CCCallFunc::actionWithTarget(this, callfunc_selector(Card::delUnusedObj)),
                                               NULL));
        }
    }
}
Пример #3
0
void ScoreCenter::showPromptScore(int score, CCPoint ppoint)
{
    CCString* curScore = CCString::createWithFormat("%u", score);
    CCLabelAtlas* label = ResCenter::shareInstance()->getLableAtlasByType(ResCenter::klableScore);
    label->setPosition(ppoint);
    //label->setScale(0.5);
    label->setString(curScore->getCString());
    
    CCFiniteTimeAction* sf = ActionEffectHub::shareInstance()->scoreFly();
    CCFiniteTimeAction* cb = CCCallFuncN::create(this, callfuncN_selector(ScoreCenter::_removeScorePrompt));

    CCSequence* cbSeq = CCSequence::create(sf, cb, NULL);
    label->runAction(cbSeq);
    this->getLayer()->addChild(label);
}
Пример #4
0
void RpgPlayer::beAttacked(int atkValue)
{
	if (hp <= 0)
	{
		return;
	}
	int oldhp = hp;
	if (hp >= atkValue)
	{
		hp -= atkValue;
	}
	else
	{
		hp = 0;
	}
	
	atkValue = oldhp-hp;
	if (atkValue)
	{
		std::stringstream ss;
		ss << atkValue;
		//CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"fps_images.png", 12, 32, '.');
		CCLabelAtlas *labelAtlas = CCLabelAtlas::create(ss.str().c_str(),"numbers_1.png", 41.28, 81, '.');
		labelAtlas->setVisible(true);
		//labelAtlas->setPosition(ccp(125,125));
		labelAtlas->setColor(ccc3(255,0,0));
		CCAction *spawn = CCSpawn::create(CCMoveBy::create(0.5f,ccp(0,64)),CCFadeOut::create(0.5),NULL);
		labelAtlas->runAction(spawn);
		this->addChild(labelAtlas,2);
		CCSprite::runAction(CCSequence::create(CCDelayTime::create(0.6),
			CCCallFuncND::create(this, callfuncND_selector(RpgMonster::actionEnd_removeLabel), (void*)labelAtlas),NULL));
		showHp();
		tryConbineAction(RpgMonster::ACTION_BE_ATTACK);
	}
	if (ui)
	{
		ui->updateHp(this);
	}
	if (hp <=0)
	{
		doDeath(); // RpgMonster 将死亡
	}
}