本文整理汇总了C++中CCLabelTTF::enableShadow方法的典型用法代码示例。如果您正苦于以下问题:C++ CCLabelTTF::enableShadow方法的具体用法?C++ CCLabelTTF::enableShadow怎么用?C++ CCLabelTTF::enableShadow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCLabelTTF
的用法示例。
在下文中一共展示了CCLabelTTF::enableShadow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool StatisticsScene::init()
{
//////////////////////////////
// 1. super init first
if ( !BaseLayer::init() )
{
return false;
}
// Set background
setBackground(1);
CCSprite* sp = CCSprite::create("texttable1.png");
sp->setPosition(ccp(0, 250 * g_fResScale));
sp->setScale(g_fResScale);
m_bgLayer->addChild(sp);
CCSize szShadow = CCSize(10 * g_fResScale, -10 * g_fResScale);
CCLabelTTF* lb = CCLabelTTF::create("OVERALL STATISTICS", "Luckiest Guy", 50);
lb->enableShadow(szShadow, 1, 1, true);
lb->setAnchorPoint(ccp(0.5, 0.5));
lb->setPosition(ccp(0, 440 * g_fResScale));
lb->setScale(g_fResScale);
m_bgLayer->addChild(lb);
for (int i = 0; i < 4; i++) {
CCLabelTTF* lb = CCLabelTTF::create(lpStatistics[i], "Luckiest Guy", 50);
lb->enableShadow(szShadow, 1, 1, true);
lb->setAnchorPoint(ccp(0, 0.5));
lb->setPosition(ccp(-560 * g_fResScale, (360 - i * 70) * g_fResScale));
lb->setScale(g_fResScale);
m_bgLayer->addChild(lb);
}
CCSprite* sp1 = CCSprite::create("texttable2.png");
sp1->setPosition(ccp(0, -250 * g_fResScale));
sp1->setScale(g_fResScale);
m_bgLayer->addChild(sp1);
CCLabelTTF* lb1 = CCLabelTTF::create("PROGRESS COMPARED TO LAST WEEK", "Luckiest Guy", 50);
lb1->enableShadow(szShadow, 1, 1, true);
lb1->setAnchorPoint(ccp(0.5, 0.5));
lb1->setPosition(ccp(0, -60 * g_fResScale));
lb1->setScale(g_fResScale);
m_bgLayer->addChild(lb1);
for (int i = 0; i < 4; i++) {
CCLabelTTF* lb = CCLabelTTF::create(lpStatistics[i], "Luckiest Guy", 50);
lb->enableShadow(szShadow, 1, 1, true);
lb->setAnchorPoint(ccp(0, 0.5));
lb->setPosition(ccp(-560 * g_fResScale, (-140 - i * 70) * g_fResScale));
lb->setScale(g_fResScale);
m_bgLayer->addChild(lb);
}
return true;
}
示例2: init
// Initialize the menu items, background, and overall setup of the main menu
//
// return - false if there was an error in initializing, true otherwise
bool MainMenu::init()
{
CCLabelTTF* labelSinglePlayer; // the text for single player menu item
CCLabelTTF* labelMultiplayer; // the text for multiplayer menu item
CCLabelTTF* labelOptions; // the text for options menu item
CCMenuItemLabel* itemSinglePlayer; // menu item for starting single player game
CCMenuItemLabel* itemMultiplayer; // menu item for starting multiplayer game
CCMenuItemLabel* itemOptions; // menu item for opening up options
CCMenu* menu; // menu to contain the menu items
CCSize size; // the size of the window
CCSprite* background; // the background splashscreen
if(!CCLayer::init())
{
return false;
}
// get the window size from the director
size = CCDirector::sharedDirector()->getWinSize();
// create the text for the menu items
labelSinglePlayer = CCLabelTTF::create("Start Single Player", FONT_STYLE, Font_Size_Default);
labelMultiplayer = CCLabelTTF::create("Start Multiplayer", FONT_STYLE, Font_Size_Default);
labelOptions = CCLabelTTF::create("Options", FONT_STYLE, Font_Size_Default);
// add shadows to the labels, so they will be easier to read against the background
labelSinglePlayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
labelMultiplayer->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
labelOptions->enableShadow(FONT_SHADOW_OFFSET, FONT_SHADOW_OPACITY, FONT_SHADOW_BLUR);
// create the items for the menu
itemSinglePlayer = CCMenuItemLabel::create(labelSinglePlayer, this, menu_selector(MainMenu::HandleSinglePlayerPressed));
itemMultiplayer = CCMenuItemLabel::create(labelMultiplayer, this, menu_selector(MainMenu::HandleMultiplayerPressed));
itemOptions = CCMenuItemLabel::create(labelOptions, this, menu_selector(MainMenu::HandleOptionsPressed));
// set the color of the menu items
itemSinglePlayer->setColor(MENU_COLOR);
itemMultiplayer->setColor(MENU_COLOR);
itemOptions->setColor(MENU_COLOR);
// create menu to contain the menu items
menu = CCMenu::create(itemSinglePlayer, itemMultiplayer, itemOptions, NULL);
menu->alignItemsVerticallyWithPadding(MENU_ITEM_PADDING);
menu->setPosition(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN);
addChild(menu, 1);
// add splash screen as a sprite on the center of the screen
background = CCSprite::create(BACKGROUND_IMAGE);
background->setScale(size.height / background->boundingBox().size.height);
background->setPosition( ccp(size.width * POS_HALF_SCREEN, size.height * POS_HALF_SCREEN) );
addChild(background, 0);
return true;
}
示例3: init
bool UpdateScene::init() {
CCScene::init();
CCDirector *pDirector = CCDirector::sharedDirector();
//背景黑框和屏幕一样大小
CCSprite *lm = CCSprite::create("black.png");
addChild(lm);
CCSize vs = pDirector->getVisibleSize();
lm->setPosition(ccp(vs.width/2, vs.height/2));
CCSize sz = lm->getContentSize();
lm->setScaleX(vs.width/sz.width);
lm->setScaleY(vs.height/sz.height);
CCLabelTTF *lab = CCLabelTTF::create("Loading...", "", 25);
lab->setColor(ccc3(255, 255, 255));
lab->enableShadow(CCSizeMake(1, 2), 1, 1, true);
lab->setAnchorPoint(ccp(0, 0.5));
lab->setPosition(ccp(16, 768-743));
addChild(lab);
CCSpriteFrameCache *sf = CCSpriteFrameCache::sharedSpriteFrameCache();
sf->addSpriteFramesWithFile("loadAni.plist");
CCAnimation *ani = CCAnimation::create();
char name[100];
for(int i = 0; i <= 20; i++) {
sprintf(name, "load%d.png", i);
ani->addSpriteFrame(sf->spriteFrameByName(name));
}
ani->setDelayPerUnit(2/20.0);
ani->setRestoreOriginalFrame(true);
CCSprite *cat = CCSprite::createWithSpriteFrameName("load0.png");
addChild(cat);
cat->setPosition(ccp(vs.width-228, 101));
cat->runAction(CCRepeatForever::create(CCAnimate::create(ani)));
updateYet = false;
scheduleUpdate();
nodeNum = 0;
return true;
}
示例4: init
bool DailyDaysCompletePopup::init(uint32_t days, uint32_t reward)
{
if (!CCLayer::init()) return false;
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCSprite* back = CCSprite::create("Interfeiss/challenges/complete_popup/dont_leave.png");
back->setPosition(ccp(visibleSize.width / 2, visibleSize.height / 2));
addChild(back);
CCMenuItemImage* closeBt = CCMenuItemImage::create("Interfeiss/level_end/level_up_popup/x_btn0001.png",
"Interfeiss/level_end/level_up_popup/x_btn0002.png",
this, menu_selector(DailyDaysCompletePopup::close));
CCMenu* closeMenu = CCMenu::create(closeBt, NULL);
closeMenu->setPosition(ccp(730, 530));
addChild(closeMenu);
CCMenuItemImage* shareBt =
CCMenuItemImage::create("Interfeiss/challenges/complete_popup/share_btn_still0001.png",
"Interfeiss/challenges/complete_popup/share_btn_still0002.png",
this, menu_selector(DailyDaysCompletePopup::share));
CCMenu* shareMenu = CCMenu::create(shareBt, NULL);
shareMenu->setPositionY(200);
shareMenu->setPositionX(visibleSize.width / 2 + 0);
addChild(shareMenu);
CCLabelTTF* titleTxt = CCLabelTTF::create(("Daily challenge completed " + toString(days) + " days in a row!").c_str(),
FONT_SKRANJI_BOLD,
TITLE_FONT_SIZE*0.6, CCSize(320, 180),
kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop);
titleTxt->setColor(ccc3(0x3E, 0x16, 0x04));
titleTxt->setRotation(-2);
titleTxt->setPosition(ccp(visibleSize.width / 2+80, visibleSize.height / 2 + 70));
addChild(titleTxt);
// title
CCLabelTTF* levelTxt = CCLabelTTF::create("reward", FONT_SKRANJI_BOLD,
TITLE_FONT_SIZE*0.6, CCSize(130, 120),
kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop);
levelTxt->setColor(ccc3(0x4F, 0x98, 0x8B));
levelTxt->setRotation(-6);
levelTxt->setPosition(ccp(visibleSize.width / 2 + 40, visibleSize.height / 2 - 70));
addChild(levelTxt);
// reward
CCLabelTTF* rewardSh = CCLabelTTF::create(toString(reward).c_str(), FONT_SKRANJI_BOLD, TITLE_FONT_SIZE*1,
CCSize(100, 55), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
rewardSh->setAnchorPoint(ccp(0,0));
rewardSh->cocos2d::CCNode::setPosition(ccp(580, 2));
rewardSh->setColor(ccc3(0xff, 0xff, 0xff));
rewardSh->enableShadow(CCSize(3,3), 0.5, 3, true);
rewardSh->setRotation(-6);
rewardSh->setPosition(ccp(visibleSize.width / 2 - 70, 245));
addChild(rewardSh);
CCLabelTTF* rewardT = CCLabelTTF::create(toString(reward).c_str(), FONT_SKRANJI_BOLD, TITLE_FONT_SIZE*1,
CCSize(100, 55), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
rewardT->setAnchorPoint(ccp(0,0));
rewardT->setColor(ccc3(0xff, 0xff, 0xff));
rewardT->cocos2d::CCNode::setPosition(ccp(580, 2));
rewardT->setRotation(-6);
rewardT->setPosition(ccp(visibleSize.width / 2 - 70, 245));
addChild(rewardT);
// animation
TimedSpriteAnimation* check = TimedSpriteAnimation::create("Interfeiss/challenges/ingame_pop_up/check.plist", 3);
check->setAnchorPoint(ccp(0, 1));
check->setPosition(ccp(visibleSize.width / 2 + 190, 460));
addChild(check);
// icon
char rewardStr[10];
std::string iconStr;
sprintf(rewardStr, "+%d", reward);
iconStr = "Interfeiss/challenges/award_diamond.png";
rewardSh->setString(rewardStr);
rewardT->setString(rewardStr);
// icon
CCSprite* icon = CCSprite::create(iconStr.c_str());
icon->setAnchorPoint(ccp(0.5,0.5));
icon->setScale(0.8);
icon->setPosition(ccp(visibleSize.width / 2 + 80, 280));
addChild(icon);
return true;
}