当前位置: 首页>>代码示例>>C++>>正文


C++ CCLabelTTF::setPositionX方法代码示例

本文整理汇总了C++中CCLabelTTF::setPositionX方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setPositionX方法的具体用法?C++ CCLabelTTF::setPositionX怎么用?C++ CCLabelTTF::setPositionX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CCLabelTTF的用法示例。


在下文中一共展示了CCLabelTTF::setPositionX方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetDemage

void Enemy:: SetDemage(float val,bool isBoom){
    CCString *str = CCString::createWithFormat("-%.f",val);
  //  CCLog(str->getCString());
    float font = 30;
    if (isBoom) {
        font = 60;
    }
   CCLabelTTF* demageLab = CCLabelTTF::create(str->getCString(),  "Marker Felt", font);
    if (isBoom) {
         demageLab->setColor(ccYELLOW);
    }else
    demageLab->setColor(ccRED);
    float x = CCRANDOM_0_1()*40;
    float y = CCRANDOM_0_1()*40;
    demageLab->setPositionX(x);
    demageLab->setPositionY(y);
    this->addChild(demageLab);
   CCActionInterval* scale=CCScaleTo::create(10, 0.5);
//    CCActionInterval* scale1 = CCScaleTo::create(0.25, 0.2);
    CCActionInterval *fade = CCFadeOut::create(0.5);
   // CCCallFunc *call = CCCallFunc::create(this, callfunc_selector(Enemy::clearDemageLab));
 
    //创建不断重复的动画,并让heroSprite播放
    
    demageLab->runAction(CCSpawn::create(scale,fade,NULL));
    CCAnimate * animate = BoomReady();
    if (animate==NULL) {
        return;
    }
    CCCallFunc* callfun = CCCallFunc::create(this,callfunc_selector(Enemy::boomNow));
    actionSprite->runAction(CCSequence::create(animate,callfun));
}
开发者ID:Grassss,项目名称:FirstDefenceGame,代码行数:32,代码来源:Enemy.cpp

示例2: _showAudioPlaying

void GameLayer::_showAudioPlaying()
{
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    CCLabelTTF* lblMusic = CCLabelTTF::create(CCString::createWithFormat("Playing %s", _music.description)->getCString(), FONT_GAME, 35.0f, CCSizeMake(winSize.width * 0.85f, winSize.height * 0.15f), kCCTextAlignmentRight, kCCVerticalTextAlignmentTop);
    
    lblMusic->setPositionX(origin.x + visibleSize.width * 0.55f);
    lblMusic->setPositionY(origin.y - visibleSize.height * 0.25f);
    
    CCMoveTo* ac1 = CCMoveTo::create(1.0f, ccp(lblMusic->getPositionX(), origin.y + visibleSize.height * 0.05f));
    
    CCDelayTime* ac2 = CCDelayTime::create(2.1f);
    
    CCFadeOut* ac3 = CCFadeOut::create(0.9f);
    
    CCCallFuncN* ac4 = CCCallFuncN::create(this, callfuncN_selector(GameLayer::_removeNode));
    
    addChild(lblMusic, kDeepGameFinish);
    
    lblMusic->runAction(CCSequence::create(ac1, ac2, ac3, ac4, NULL));
    
    SimpleAudioEngine::sharedEngine()->playBackgroundMusic(_music.bg_music, true);
    
}
开发者ID:JerryLootsie,项目名称:BTEndlessTunnel,代码行数:26,代码来源:GameLayer.cpp

示例3: createPerson

CCSprite* CreditsScreen::createPerson(const std::string& name, const std::string& twitterLink, const std::string& fbLink)
{
    const float iconSize = 32;
    
    bool useTwitter = !twitterLink.empty();
    bool useFB = !fbLink.empty();
    
    CCSprite* person = CCSprite::create();
    
    CCLabelTTF* nameLabel = CCLabelTTF::create(name.c_str(), default_font.c_str(), FONT_SIZE_PERSON);
    nameLabel->setPositionX(nameLabel->getContentSize().width / 2);
    
    float totalWidth = nameLabel->getContentSize().width;
    float totalHeight = MAX(nameLabel->getContentSize().height, iconSize);
    
    if(useTwitter || useFB){
        totalWidth += PADDING_AFTER_NAME;
    }
    
    if(useTwitter){
        totalWidth += iconSize + PADDING_PERSON;
        
        urls.push_back(twitterLink);
        Button* twitterButton = ButtonFactory::imageButton(TWITTER_ICON_INACTIVE, TWITTER_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        twitterButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        twitterButton->setPositionY(totalHeight / 2);

        person->addChild(twitterButton);
    }
    
    if(useFB) {
        totalWidth += iconSize + PADDING_PERSON;

        urls.push_back(fbLink);
        Button* fbButton = ButtonFactory::imageButton(FB_ICON_INACTIVE, FB_ICON_PRESSED, new Handler(this, callfuncD_selector(CreditsScreen::openURL), (void*)(urls.size() - 1)), BUTTON_PRIORITY);
        
        fbButton->setPositionX(nameLabel->getPositionX() + totalWidth - iconSize - nameLabel->getContentSize().width/2);
        fbButton->setPositionY(totalHeight / 2);
        
        person->addChild(fbButton);
    }
    
    person->setContentSize(CCSizeMake(totalWidth, totalHeight));
    nameLabel->setPositionY(totalHeight / 2);
    person->addChild(nameLabel);
    
    return person;
}
开发者ID:Stals,项目名称:TilesFight,代码行数:48,代码来源:CreditsScreen.cpp

示例4: addTipBoard

void BaseScene::addTipBoard(const char* tip)
{
    CCSprite* tipBoard = CCSprite::createWithSpriteFrameName("tip_board");
    tipBoard->setAnchorPoint(ccp(0.0f, 1.0f));
    
    //tipBoard->cocos2d::CCNode::setPosition(SCALED_VALUE(12.0f), SCALED_VALUE(368.0f));
    PlaceNode(tipBoard, 0.02, 0.764);
    this->addChild(tipBoard);
    
    CCLabelTTF* tipLabel = CCLabelTTF::create(tip, "Arial", SCALED_VALUE(20.0f));
    tipLabel->setColor(ccc3(33, 33, 33));
    tipLabel->setAnchorPoint(ccp(0.5f, 1.0f));
    tipLabel->setDimensions(CCSizeMake(tipBoard->getContentSize().width * 0.8, tipBoard->getContentSize().height * 0.8));
    
    float py = 0.0f;
    py = tipBoard->getPositionY();
    py = py - SCALED_VALUE(127.0f);
    tipLabel->setPositionY(py);
    
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    tipBoard->setScaleY(1.20f);
    
    if (AppDelegate::SCREEN_HEIGHT > 400.0f)
    {
        tipLabel->setPositionY(py + SCALED_VALUE(10.0f));
    }
    else
    {
        tipLabel->setPositionY(py - SCALED_VALUE(5.0f));
    }
    
    
#else
    //PlaceNode(tipLabel, 0.04, 0.55);
#endif
    
    //tipLabel->setPositionY(py);
    
    float pX = tipBoard->getPositionX() + tipBoard->getContentSize().width/2;
    tipLabel->setPositionX(pX);
    
    this->addChild(tipLabel);
}
开发者ID:ezibyte,项目名称:EziSocialDemo,代码行数:43,代码来源:BaseScene.cpp


注:本文中的CCLabelTTF::setPositionX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。