本文整理汇总了C++中Counter::create_label方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::create_label方法的具体用法?C++ Counter::create_label怎么用?C++ Counter::create_label使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::create_label方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MainLayer::init()
{
/*-- 设置整体层属性 --*/
this->setTouchMode(kCCTouchesOneByOne);
this->setTouchEnabled(true);
this->scheduleUpdate();
CCSize s = CCDirector::sharedDirector()->getWinSize();
this->ignoreAnchorPointForPosition(true);
setAnchorPoint(ccp(0.5f, 0.5f));
this->setContentSize(s);
setPosition(ccp(s.width / 2, s.height / 2));
CCSize vsize = CCDirector::sharedDirector()->getVisibleSize();
float width = vsize.width / 2;
float height = vsize.height / 2;
Counter *counter = Counter::sharedCounter();
counter->clearScore();
if (counter->isSound()
&& !SimpleAudioEngine::sharedEngine()->isBackgroundMusicPlaying())
{
SimpleAudioEngine::sharedEngine()->playBackgroundMusic("bgm.mp3", true);
}
/*-- door --*/
CCAnimation *doorAnimation =
CCAnimationCache::sharedAnimationCache()->animationByName("door");
//左侧
CCSprite *leftDoor = CCSprite::createWithSpriteFrameName("door_1.png");
leftDoor->setPosition(ccp(-200, -50));
leftDoor->setAnchorPoint(ccp(0.5, 0.5));
this->addChild(leftDoor);
leftDoor->runAction(
CCRepeatForever::create(CCAnimate::create(doorAnimation)));
//右侧
CCSprite *rightDoor = CCSprite::createWithSpriteFrameName("door_1.png");
rightDoor->setPosition(ccp(200, -50));
rightDoor->setAnchorPoint(ccp(0.5, 0.5));
this->addChild(rightDoor);
rightDoor->runAction(
CCRepeatForever::create(CCAnimate::create(doorAnimation)));
/*-- 分数 --*/
CCLabelTTF *titletxt = CCLabelTTF::create(counter->getStringByKey("score"),
counter->getStringByKey("font"), 46);
titletxt->setColor(ccc3(98, 104, 191));
titletxt->setAnchorPoint(ccp(0.5, 0.5));
titletxt->setPosition(ccp(0, height - 130));
this->addChild(titletxt);
CCNode *scoreLabel = counter->create_label();
scoreLabel->setPosition(ccp(0, height - 200));
scoreLabel->setAnchorPoint(ccp(0.5, 1));
this->addChild(scoreLabel, 3, TAG_SCORE);
/*-- role --*/
return true;
}