本文整理汇总了C++中CCLabelTTF::runAction方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::runAction方法的具体用法?C++ CCLabelTTF::runAction怎么用?C++ CCLabelTTF::runAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::runAction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMainTupianSprite
//.........这里部分代码省略.........
COLLECTED_SPRITE;
this->addChild(sprite);
if (!m_tupian->getisCollected()) {
int count=S_DM->getCount("ciyu","isCollected>0");
if (count>=COLLECT_LIMIT) {
GuideDialog* guideDialog=new GuideDialog();
guideDialog->autorelease();
guideDialog->setText("非常抱歉,收藏的卡片数量已经超出了限制,请检查账号状态。");
guideDialog->setMode(kGuideDialogOk);
m_gudieDialogLayer=GuideDialogLayer::create(kDialogWithText);
m_gudieDialogLayer->setDelegate(this);
this->addChild(m_gudieDialogLayer,ORDER_DIALOG);
m_gudieDialogLayer->setGuideDialogData(guideDialog);
} else {
m_tupian->setIntisCollected(1);
CCString *sql=CCString::createWithFormat("update ciyu set isCollected=1 where id=%d;",m_tupian->getid());
S_DM->executeSql(sql->getCString());
static_userDefaultIncrement(COLLECT_TUPIAN_COUNT,15);
CCSprite* sprite;
COLLECTED_SPRITE;
KapianCollectLayer* kapianCollectLayer=KapianCollectLayer::create(sprite,kTupian);
this->addChild(kapianCollectLayer);
kapianCollectLayer->collectAnimate();
// if(isFromInit){
// m_tupianBrowserDelegate->reloadTupianTable();
// }
// else{
// m_tupianTabelLayer->reloadData();
// }
}
}
if (m_wenziMenu!=NULL) {
this->removeChild(m_wenziMenu, false);
}
m_wenziMenu=CCMenu::create();
string ciyu=m_tupian->getText();
const char* zi=ciyu.c_str();
char p[ciyu.length()/3][4];
string where="";
vector<Hanzi*>* hanzis=new vector<Hanzi*>();
CLAUSE_INIT;
whereClause.push_back(HANZI_VERIFY_PASS);
for (int i = 0,j=0; i < ciyu.length(); i=i+3,j++)
{
char end='\0';
sprintf(p[j], "%c%c%c%c",zi[i],zi[i+1],zi[i+2],end);
if(i>0)where.append(" or ");
where.append(" (zi like '").append(p[j]).append("') ");
}
whereClause.push_back(where.c_str());
S_DM->findScrollData(hanzis, "id,zi", whereClause, orderbyClause, groupByClause);
m_delay=0.0f;
for (int i=0; i< ciyu.length()/3; i++) {
CCLabelTTF *txtLabel = CCLabelTTF::create(p[i], "KaiTi.ttf", 60.0);
txtLabel->setColor(ccc3(200, 200, 200));
CCSprite* wenzi=CCSprite::createWithSpriteFrameName("zikuang.png");
CCMenuItemSprite* pwenziItem=CCMenuItemSprite::create(wenzi, NULL, this, menu_selector(TupianBrowserLayer::wenziCallback));
pwenziItem->setTag(0);
for (vector<Hanzi *>::iterator it = hanzis->begin(); it != hanzis->end(); it ++) {
if (NULL != *it)
{
Hanzi* hanzi=*it;
if (hanzi->getzi() ==p[i]) {
pwenziItem->setTag(hanzi->getid());
txtLabel->setColor(ccc3(0, 0, 0));
break;
}
}
}
txtLabel->setPosition(S_RM->getRelativePosition("tupian_wenzi_label", wenzi->getContentSize().height));
txtLabel->runAction(CCSequence::create(CCDelayTime::create(m_delay),CCScaleTo::create(0.25, 1.5),CCScaleTo::create(0.25, 1),NULL));
pwenziItem->addChild(txtLabel);
pwenziItem->setPosition(ccp(i*140,0));
m_wenziMenu->addChild(pwenziItem);
m_delay+=0.5;
}
m_wenziMenu->setPosition(ccp(W_SIZE.width/2-(ciyu.length()/3-1)*70,S_RM->getPositionWithName("tupian_wenzi_fangda").y));
m_wenziMenu->setTag(kTagWenziMenu);
this->addChild(m_wenziMenu);
}
示例2: ApplyHurt
//--------------------------------------------------
//
//
void CPet::ApplyHurt( int damage, bool isHardAttack )
{
CBaseDataPet* pPetBaseData = g_pClientLoader->GetBaseDataPetFromId(m_PetData.petid);
int skilldata = CExpressions::GetInstance()->GetAttribute( pPetBaseData->skillaptitude, pPetBaseData->upskill, pPetBaseData->initskill, m_PetData.petlevel );
float pec = CExpressions::GetInstance()->GetSkillFrquency(skilldata, m_PetData.petlevel );
CBaseDataSkill* pDataSkill = g_pClientLoader->GetBaseDataSkillFromId(pPetBaseData->skillfield_defense[m_PetData.skilllevel.skillsLevel[1] - 1]);
//skill attack
if( CCRANDOM_0_1() < pec && m_PetData.skilllevel.skillsLevel[1] > 0 && m_PetData.mp >= pDataSkill->skillmp )
{
CBaseDataAnimation *pAnimationData = g_pClientLoader->GetBaseDataAnimationFromId(m_PetData.ResId);
PlayAnimation( pAnimationData->m_defense, 1, callfunc_selector( CPet::HurtEndCallBack ), this, false, false );
m_PetData.mp = m_PetData.mp - pDataSkill->skillmp;
if( m_PetData.mp <= 0 )
{
m_PetData.mp = 0;
}
std::string effectpath = GetGameParticlePath();
std::string filename = effectpath + pDataSkill->plist;
if( !pDataSkill->plist.empty() )
{
CCParticleSystemQuad *pEmitter = CCParticleSystemQuad::particleWithFile(filename.c_str() );
//m_emitter->setPositionType( kCCPositionTypeRelative );
pEmitter->setPosition( getPosition() );
g_pFightGroundLayer->addChild( pEmitter, 100 );
}
if( CCUserDefault::sharedUserDefault()->getBoolForKey( "sound" ) )
{
string path = "data/audio/" + pDataSkill->skill_sound;
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(path.c_str(), false);
CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("data/audio/scoreCount2.wav", false);
}
return;
}
m_PetData.hp = m_PetData.hp - damage;
char strbuffer[32];
if( 0 == damage )
{
sprintf( strbuffer, "%s", "miss");
}
else
{
sprintf( strbuffer, "-%d", damage);
}
CCLabelTTF *plabel = CCLabelTTF::labelWithString(strbuffer, kFontSystem[FONT_GRAND].fontName,kFontSystem[FONT_GRAND].fontSize);
const ccColor3B ccwhite = {255,255,255};
const ccColor3B ccYellow = {255,255,0};
const ccColor3B ccRed = {255,0,0 };
if( isHardAttack )
{
plabel->setColor( ccYellow );
}
else if( 0 == damage )
{
plabel->setColor( ccRed );
}
else
{
plabel->setColor( ccwhite );
}
plabel->setPosition( ccp( getPosition().x, getPosition().y + getTextureRect().size.height ) );
g_pFightGroundLayer->addChild(plabel,100);
plabel->runAction( CCFadeOut::actionWithDuration(1.5f) );
plabel->runAction(CCMoveBy::actionWithDuration(0.2f, ccp( 0, 50 )));
if( m_PetData.hp <= 0 )
{
CBaseDataAnimation *pAnimationData = g_pClientLoader->GetBaseDataAnimationFromId(m_PetData.ResId);
PlayAnimation( pAnimationData->m_lost, 1, NULL, this, false, false );
m_pLockTarget->m_bIsWin = true;
}
else
{
CBaseDataAnimation *pAnimationData = g_pClientLoader->GetBaseDataAnimationFromId(m_PetData.ResId);
PlayAnimation( pAnimationData->m_injured, 1, callfunc_selector( CPet::HurtEndCallBack ), this, false, false );
}
if( 0 != damage )
{
std::string effectpath = GetGameParticlePath();
std::string filename = effectpath + "hurteffect.plist";
CCParticleSystemQuad *pEmitter = CCParticleSystemQuad::particleWithFile( filename.c_str() );
//m_emitter->setPositionType( kCCPositionTypeRelative );
pEmitter->setPosition( getPosition() );
CCPoint pos = getPosition();
g_pFightGroundLayer->addChild( pEmitter, 100 );
}
if( isHardAttack )
{
//.........这里部分代码省略.........
示例3: init
bool PlayScene::init()
{
bool bRet = false;
do
{
winSize = CCDirector::sharedDirector()->getWinSize();
isPause = false;
//this->registerWithTouchDispatcher();
this->setKeypadEnabled(true);
int lvl = CCUserDefault::sharedUserDefault()->getIntegerForKey("lvl");
if(lvl == 0)
{
lvl = 1;
CCUserDefault::sharedUserDefault()->setIntegerForKey("lvl",1);
}
char mapPath[20];
char lvlinform[30];
//map_tmx_lvl1
sprintf(mapPath,"map/lvl%d.tmx",lvl);
sprintf(lvlinform,"Lvl %d",lvl);
isOver = -1;
CCLabelTTF * lvlInform = CCLabelTTF::create(lvlinform, "Thonburi", 64);
lvlInform->setPosition(ccp(-100,winSize.height/2));
this->addChild(lvlInform,3);
overinfor = CCLabelTTF::create("Game Over", "Thonburi", 64);
overinfor->setPosition(ccp(winSize.width/2,winSize.height/2));
overinfor->setVisible(false);
this->addChild(overinfor,3);
//这里是暂停菜单信息s
lvlInform->runAction(CCJumpTo::create(3,ccp(winSize.width+100,winSize.height/2),60,10));
ccColor4B t;
t.a = 200;
t.r = 0;
t.g = 0;
t.b = 0;
pauseLayer = CCLayerColor::create(t);
this->addChild(pauseLayer,10);
pauseLayer->setPosition(CCPointZero);
CCSprite *pauseBg = CCSprite::create(pause_bg);
pauseBg->setPosition(ccp(winSize.width/2 , winSize.height/2));
pauseLayer->addChild(pauseBg);
CCMenuItemImage *resume = CCMenuItemImage::create(
pause_resume,
pause_resume,
this,
menu_selector(PlayScene::menuResume_CallBack)
);
CCMenuItemImage *save = CCMenuItemImage::create(
pause_save,
pause_save,
this,
menu_selector(PlayScene::menuSaveCallBack)
);
CCMenuItemImage *returnMenu = CCMenuItemImage::create(
pause_return,
pause_return,
this,
menu_selector(PlayScene::menuReturnCallBack)
);
CCMenu * pauseMenu = CCMenu::create(resume,save,returnMenu,NULL);
pauseMenu->alignItemsVerticallyWithPadding(30);
pauseLayer->addChild(pauseMenu);
pauseLayer->setVisible(false);
//////////////////////////////////////////////////////////////////////////
Mediator::getInstance()->release(); //释放
Mediator::getInstance()->init(); //初始化
//加载地图
map = TmxMap::initMap(mapPath); // 地图
this->addChild(map);
//添加摇杆,如果宏定义是手机
#ifdef IAMPHONE__
CCSprite * bg = CCSprite::create(control_bg);
CCSprite * cen = CCSprite::create(control_ce);
control = Joystick::JoystickWithCenter(ccp(120,120),100.f,cen,bg);
control->Active();
this->addChild(control,1);
control->setOpacity((float)0.3);
//按钮
fire = CCMenuItemImage::create(
fire_normal,
fire_press
);
fire->setOpacity(0.3*255);
fire->setPosition(ccp(winSize.width - fire->getContentSize().width/2 - 10 , fire->getContentSize().height/2 + 10));
CCMenu * menu = CCMenu::create(fire,NULL);
menu->setPosition(CCPointZero);
//.........这里部分代码省略.........
示例4: init
bool ZhuShouChatLayer::init()
{
bool bRet = false;
do
{
CC_BREAK_IF(! CCLayerColor::initWithColor(ccc4(0,0,0,160)) );
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
//board
CCSprite* board = CCSprite::create("juqing_duihuakuang.png");
addChild(board, 2, TAG_Board);
board->setAnchorPoint(ccp(0.5, 0));
board->setPosition(ccp(winSize.width/2, 0));
board->setOpacity(0);
board->setScaleY(0.7f);
//next img
BaseSprite *nextImg = BaseSprite::create("sphc_anniu_fanye.png");
board->addChild(nextImg, 0, Tag_ImgNext);
nextImg->setPosition(ccp(597,37));
nextImg->setOpacity(0);
nextImg->runAction(CCSequence::create(
CCFadeIn::create(0.15f),
CCRepeat::create(CCSequence::create(CCFadeOut::create(0.75f), CCFadeIn::create(0.75f), NULL), -1),
NULL));
//npc
string npcFileName = getFileByName(getPinyinName(m_nZhuaShouId)).second;
////////////////////////////////////////////
if(npcFileName.empty())
{
CCLog("Error: %s [can't found npc imgine]", __FUNCTION__);
npcFileName = "juqing_duihua_NPC_shenmiren.png";
}
////////////////////////////////////////////
int x_side = 20;
CCSprite* actorA = CCSprite::create(npcFileName.c_str());
addChild(actorA, 3, TAG_ActorA);
actorA->setAnchorPoint(ccp(0,0));
actorA->setPosition(ccp(x_side,x_side));
actorA->setOpacity(0);
int side = 10;
//label name
CCLabelTTF *namelabel = CCLabelTTF::create("", fontStr_kaiti, 24);
addChild(namelabel, 5, Tag_Label_Name);
namelabel->setAnchorPoint(ccp(0, 0.5));
namelabel->setPosition(ccp(20, board->getContentSize().height-42));
namelabel->setColor(fonColor_PuTong);
namelabel->setOpacity(0);
//label content
//CCLabelTTF* label = CCLabelTTF::create("", fontStr_kaiti, 24, CCSize(board->getContentSize().width - actorA->getContentSize().width - side, 0), kCCTextAlignmentLeft);
m_nTextWidth = board->getContentSize().width - actorA->getContentSize().width - side;
NetLabelTTF* label = NetLabelTTF::create("", fontStr_kaiti, 24);
addChild(label, 5, TAG_label);
label->setHorizontalAlignment(kCCTextAlignmentLeft);
label->setAnchorPoint(ccp(0,1));
label->setColor(fonColor_FaGuang);
label->setPosition(ccp(actorA->getContentSize().width + side, board->getContentSize().height-145));
label->setOpacity(0);
actorA->runAction(CCFadeIn::create(0.0f));
board->runAction(CCFadeIn::create(0.0f));
label->runAction(CCFadeIn::create(0.0f));
namelabel->runAction(CCFadeIn::create(0.0f));
nextImg->runAction(CCFadeIn::create(0.0f));
scheduleOnce(schedule_selector(ZhuShouChatLayer::showChatContext), 0.05f);
{
mTimeEnd = false;
mLabelFadeInEnd = false;
++m_index;
}
bRet = true;
} while(0);
return bRet;
}
示例5: ccp
bool Newbie1Trigger::onRegist() {
// CCLayer* newbieLayer = CCLayer::create();
//
// CCSprite* gray = CCSprite::create("whiteImage.jpg");
// gray->setPosition(ccp(winSize.width/2,winSize.height/2));
// gray->setScaleX(winSize.width/gray->getContentSize().width);
// gray->setScaleY(winSize.height/gray->getContentSize().height);
// gray->setColor(ccc3(0,0,0));
// gray->setOpacity(150);
//
// newbieLayer->addChild(gray);
//
// CCString* str = GXUtil::readFile("NewbieDialog1.j");
// node->addChild(DiaLayer::create(GXJsonUtil::parseDiaLayerInfoBean(str->getCString())),11);
// newbieLayer->setTag(newbieFlowLayerTag);
// node->addChild(newbieLayer);
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("sfx_uicrash.mp3");
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("sfx_uicrash1.mp3");
CCLayer* newbieLayer = CCLayer::create();
newbieLayer->setTag(newbieFlowLayerTag);
CCSprite* black = CCSprite::create("whiteImage.jpg");
black->setColor(ccc3(0,0,0));
black->setScaleX(winSize.width/black->getContentSize().width);
black->setScaleY(winSize.height/black->getContentSize().height);
newbieLayer->addChild(black);
// black->setTag(newbieBlackTag);
black->setPosition(ccp(winSize.width/2,winSize.height/2));
CCLabelTTF* label = CCLabelTTF::create("1939.10.30\n天气 晴\n欧洲战场前线基地", "Arial", 36,CCSizeZero, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop);
label->setPosition(ccp(200,150));
label->setOpacity(0);
label->runAction(CCSequence::create(CCFadeIn::create(0.5),CCDelayTime::create(1.5),CCFadeOut::create(3),GXRemoveFromParentsAction::create(),NULL));
black->runAction(CCSequence::create(CCDelayTime::create(2),CCFadeOut::create(3),NULL));
newbieLayer->addChild(label);
GXShieldTouchMenuItem* nextButton = GXShieldTouchMenuItem::create();
nextButton->setContentSize(winSize);
nextButton->setPosition(ccp(winSize.width/2,winSize.height/2));
MyPriorityMenu* menu = MyPriorityMenu::create(-499, nextButton,NULL);
menu->setPosition(ccp(0,0));
// menu->setTag(newbieMenuTag);
newbieLayer->addChild(menu);
node->addChild(newbieLayer);
// node->runAction(CCRepeat::create(static_cast<CCSequence*>(CCSequence::create(CCCallFunc::create(this,callfunc_selector(Newbie1Trigger::deployUnit)),CCDelayTime::create(1),NULL)),20));
MyBattleMap* battleMap = (MyBattleMap*)node->getChildByTag(MainMapTag);
battleMap->runAction(CCSequence::create(CCDelayTime::create(3),CCEaseIn::create(CCMoveBy::create(9,ccp(-500,-500)),2),CCCallFunc::create(this,callfunc_selector(Newbie1Trigger::toNextCallBack)),NULL));
CCArray* unitArray = CCArray::create();
CreatorInfoBean* PanzerIVBean = CreatorInfoBean::create(PanzerIVCardId);
CreatorInfoBean* VolksgrenadierBean = CreatorInfoBean::create(volksgrenaierCardId);
// CreatorInfoBean* InfanterieBean = CreatorInfoBean::create(InfanterieCardId);
CreatorInfoBean* PanzergrenadierBean = CreatorInfoBean::create(panzergrenadierCardId);
// CreatorInfoBean* HummingBirdBean = CreatorInfoBean::create(HummingBirdCardId);
// CreatorInfoBean* tigerBean = CreatorInfoBean::create(TigerCardId);
MyUnit* unit1 = PanzerIVBean->creator->createObj(PanzerIVBean->getLevel());
unit1->setTag(PanzerIVBean->creator->cardId);
unit1->setPosition(battleMap->transTiledToMap(ccp(25,50)));
unit1->deployPosi = ccp(25,50);
unitArray->addObject(unit1);
MyUnit* unit2 = PanzerIVBean->creator->createObj(PanzerIVBean->getLevel());
unit2->setTag(PanzerIVBean->creator->cardId);
unit2->setPosition(battleMap->transTiledToMap(ccp(30,55)));
unit2->deployPosi = ccp(30,55);
unitArray->addObject(unit2);
MyUnit* unit3 = VolksgrenadierBean->creator->createObj(1);
unit3->setTag(VolksgrenadierBean->creator->cardId);
unit3->setPosition(battleMap->transTiledToMap(ccp(24,54)));
unit3->deployPosi = ccp(24,54);
unitArray->addObject(unit3);
MyUnit* unit4 = VolksgrenadierBean->creator->createObj(1);
unit4->setTag(VolksgrenadierBean->creator->cardId);
unit4->setPosition(battleMap->transTiledToMap(ccp(35,50)));
unit4->deployPosi = ccp(35,50);
unitArray->addObject(unit4);
MyUnit* unit5 = VolksgrenadierBean->creator->createObj(1);
unit5->setTag(VolksgrenadierBean->creator->cardId);
unit5->setPosition(battleMap->transTiledToMap(ccp(33,59)));
unit5->deployPosi = ccp(33,59);
unitArray->addObject(unit5);
MyUnit* unit6 = PanzergrenadierBean->creator->createObj(1);
unit6->setTag(PanzergrenadierBean->creator->cardId);
unit6->setPosition(battleMap->transTiledToMap(ccp(23,52)));
unit6->deployPosi = ccp(23,52);
unitArray->addObject(unit6);
//.........这里部分代码省略.........