本文整理汇总了C++中CCLabelTTF::setPositionY方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::setPositionY方法的具体用法?C++ CCLabelTTF::setPositionY怎么用?C++ CCLabelTTF::setPositionY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::setPositionY方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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);
}
示例3: 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);
}
示例4: 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;
}
示例5: buildHeader
void BaseScene::buildHeader(int highlightIndex, const char* title, const char* description)
{
_currentMenuIndex = highlightIndex;
CCMenuItemImage* homeButton = CCMenuItemImage::create();
homeButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_nrl"));
homeButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
homeButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_home_prd"));
homeButton->setTarget(this, menu_selector(BaseScene::loadHomeScene));
homeButton->setAnchorPoint(ccp(1.0f, 1.0f));
CCMenuItemImage* fbActionButton = CCMenuItemImage::create();
fbActionButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_nrl"));
fbActionButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_prd"));
fbActionButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_fb_action_dis"));
fbActionButton->setTarget(this, menu_selector(BaseScene::loadFBActionScene));
fbActionButton->setAnchorPoint(ccp(1.0f, 1.0f));
if (EziSocialObject::sharedObject()->isFacebookSessionActive() == false)
{
fbActionButton->setEnabled(false);
}
CCMenuItemImage* helpButton = CCMenuItemImage::create();
helpButton->setNormalSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_nrl"));
helpButton->setSelectedSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
helpButton->setDisabledSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("btn_help_prd"));
helpButton->setTarget(this, menu_selector(BaseScene::loadHelpScene));
helpButton->setAnchorPoint(ccp(1.0f, 1.0f));
switch (highlightIndex)
{
case 0:
homeButton->setEnabled(false);
break;
case 1:
fbActionButton->setEnabled(false);
break;
case 2:
helpButton->setEnabled(false);
break;
default:
break;
}
CCMenu* homeMenu = CCMenu::create(homeButton, fbActionButton, helpButton, NULL);
homeMenu->alignItemsHorizontally();
this->addChild(homeMenu);
PlaceNode(homeMenu, 0.88, 0.98);
// Add a line.
CCLayerColor* lineLayer = CCLayerColor::create(ccc4(204, 204, 204, 204),
CCDirector::sharedDirector()->getVisibleSize().width,
1.0 * AppDelegate::SCREEN_SCALE_FACTOR);
this->addChild(lineLayer);
PlaceNode(lineLayer, 0.0, 0.8);
lineLayer->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height - (7 * AppDelegate::SCREEN_SCALE_FACTOR));
// Add Title
CCLabelTTF* titleLabel = CCLabelTTF::create(title, "Arial", 50.0 * AppDelegate::SCREEN_SCALE_FACTOR);
this->addChild(titleLabel);
titleLabel->setAnchorPoint(ccp(0.0f, 0.0f));
//PlaceNode(titleLabel, 0.02, 0.98);
CCLabelTTF* descriptionLabel = CCLabelTTF::create(description,
"Arial", SCALED_VALUE(22.0f));
this->addChild(descriptionLabel);
descriptionLabel->setAnchorPoint(ccp(0.0f, 0.0f));
PlaceNode(descriptionLabel, 0.02, 0.98);
descriptionLabel->setPositionY(homeMenu->getPositionY() - homeButton->getContentSize().height);
descriptionLabel->setColor(ccc3(204, 204, 204));
titleLabel->cocos2d::CCNode::setPosition(descriptionLabel->getPositionX(),
descriptionLabel->getPositionY() + descriptionLabel->getContentSize().height - 2.0f);
}