本文整理汇总了C++中LabelAtlas类的典型用法代码示例。如果您正苦于以下问题:C++ LabelAtlas类的具体用法?C++ LabelAtlas怎么用?C++ LabelAtlas使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LabelAtlas类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showHistorySorceNumber
void GameStart::showHistorySorceNumber()
{
// Game Data
int sorceNumber = 100;
LabelAtlas * labelNumber = LabelAtlas::create(String::createWithFormat("%d",sorceNumber)->_string,"fh_shuzi.png",22,32,48);
labelNumber->setAnchorPoint(Vec2(0.0, 0.5));
labelNumber->setPosition(Vec2(visibleSize.width / 2 + 50, visibleSize.height / 2 - 150));
addChild(labelNumber);
}
示例2: showGoldNumber
void GameShopLayer::showGoldNumber()
{
// GameData
int goldNumber = 1000;
LabelAtlas * goldLabel = LabelAtlas::create(String::createWithFormat("%d", goldNumber)->_string, "gameShop/sc_shuzi.png",14,19,48);
goldLabel->setAnchorPoint(Vec2(0.0, 0.5));
goldLabel->setPosition(Vec2(visibleSize.width / 2 - 120, visibleSize.height / 2 + 157));
addChild(goldLabel);
}
示例3: showCurrcertSorceNumber
void GameStart::showCurrcertSorceNumber()
{
// GameData
int currcertSorce = GameData::getInstance()->getCurrcertSorce();
LabelAtlas * CurrcertSorce = LabelAtlas::create(String::createWithFormat("%d", currcertSorce)->_string, "yx_shuzi.png", 18, 24, 48);
CurrcertSorce->setAnchorPoint(Vec2(0.0, 0.5));
CurrcertSorce->setPosition(Vec2(visibleSize.width / 2 + 120, visibleSize.height / 2 + 330));
addChild(CurrcertSorce);
}
示例4: getChildByTag
void ParticleMainScene::step(float dt)
{
LabelAtlas *atlas = (LabelAtlas*) getChildByTag(kTagLabelAtlas);
ParticleSystem *emitter = (ParticleSystem*) getChildByTag(kTagParticleSystem);
char str[10] = {0};
sprintf(str, "%4d", emitter->getParticleCount());
atlas->setString(str);
}
示例5: CCASSERT
bool MenuItemAtlasFont::initWithString(const std::string& value, const std::string& charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
{
CCASSERT( value.size() != 0, "value length must be greater than 0");
LabelAtlas *label = LabelAtlas::create();
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
if (MenuItemLabel::initWithLabel(label, callback))
{
// do something ?
}
return true;
}
示例6: LabelAtlas
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, int itemWidth, int itemHeight, int startCharMap)
{
LabelAtlas* ret = new LabelAtlas();
if(ret && ret->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
{
ret->autorelease();
return ret;
}
CC_SAFE_DELETE(ret);
return nullptr;
}
示例7: LabelAtlas
LabelAtlas* LabelAtlas::create()
{
LabelAtlas* widget = new LabelAtlas();
if (widget && widget->init())
{
widget->autorelease();
return widget;
}
CC_SAFE_DELETE(widget);
return NULL;
}
示例8: CCAssert
bool MenuItemAtlasFont::initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, const ccMenuCallback& callback)
{
CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
LabelAtlas *label = new LabelAtlas();
label->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap);
label->autorelease();
if (MenuItemLabel::initWithLabel(label, callback))
{
// do something ?
}
return true;
}
示例9: LabelAtlas
NS_CC_BEGIN
//CCLabelAtlas - Creation & Init
LabelAtlas* LabelAtlas::create(const std::string& string, const std::string& charMapFile, long itemWidth, long itemHeight, long startCharMap)
{
LabelAtlas *pRet = new LabelAtlas();
if(pRet && pRet->initWithString(string, charMapFile, itemWidth, itemHeight, startCharMap))
{
pRet->autorelease();
return pRet;
}
CC_SAFE_DELETE(pRet);
return NULL;
}
示例10: CC_CALLBACK_0
bool GameGuiLayer::init() {
if (!Layer::init())
{
return false;
}
gotoResultLayer = false;
Size visibleSize = Director::getInstance()->getVisibleSize();
//add pause btn to this layer
MenuItemImage* start_btn = MenuItemImage::create(
"btn_setting.png", "btn_setting.png", CC_CALLBACK_0(GameGuiLayer::pauseGame, this));
Menu* start_game = Menu::create(start_btn, NULL);
start_game->setPosition(visibleSize.width - 30, visibleSize.height - 30);
this->addChild(start_game);
//add player score
playerScore = LabelAtlas::create(
cocos2d::String::createWithFormat("%d", GAMEDATA::getInstance()->getScore())->_string, "game_result_score_num.png", 49, 70, '0');
playerScore->setScale(0.8f);
playerScore->setAnchorPoint(ccp(0.5, 0.5));
playerScore->setPosition(ccp(240, 760));
this->addChild(playerScore);
//init palyer time
initTime();
//add time progress
gameSlioder = GameSlioder::create();
gameSlioder->setAnchorPoint(ccp(0, 0));
gameSlioder->setPosition(ccp(0, 0));
this->addChild(gameSlioder);
//add play time
LabelAtlas* zero = LabelAtlas::create("00", "time_num.png", 17, 20, '0');
zero->setPosition(ccp(195, 695));
this->addChild(zero);
Sprite* devide = Sprite::create("time_devide_icon.png");
devide->setPosition(ccp(234, 707));
this->addChild(devide);
std::string time_string = "";
if (totalTime - passTime < 10) {
std::string time_string = "0";
}
palyTime = LabelAtlas::create(time_string +
cocos2d::String::createWithFormat("%d", (int)(totalTime - passTime))->_string, "time_num.png", 17, 20, '0');
palyTime->setPosition(ccp(240, 695));
this->addChild(palyTime);
scheduleUpdate();
schedule(schedule_selector(GameGuiLayer::updateTime), 1.0f, kRepeatForever, 0);
return true;
}
示例11: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
if ( !Layer::init() )
{
return false;
}
Size visibleSize = Director::getInstance()->getVisibleSize();
MenuItemFont* pIncrease = MenuItemFont::create("increase 20",CC_CALLBACK_1(HelloWorld::increaseCallback,this));
pIncrease->setAnchorPoint(Vec2(0.0f,1.0f));
pIncrease->setPosition(0.0f,visibleSize.height - 0.0f);
MenuItemFont* pReduce = MenuItemFont::create("reduce 20",CC_CALLBACK_1(HelloWorld::reduceCallback,this));
pReduce->setAnchorPoint(Vec2(0.0f,1.0f));
pReduce->setPosition(0.0f,visibleSize.height - 40.0f);
MenuItemFont* pGoto = MenuItemFont::create("goto 100",CC_CALLBACK_1(HelloWorld::gotoCallback,this));
pGoto->setAnchorPoint(Vec2(0.0f,1.0f));
pGoto->setPosition(0.0f,visibleSize.height - 80.0f);
Menu* pMenu = Menu::create(pIncrease,pReduce,pGoto, NULL);
pMenu->setPosition(Vec2(0.0f,0.0f));
this->addChild(pMenu, 1);
LabelAtlas* pNumber = LabelAtlas::create("","number.png",55,84,'0');
pNumber->setAnchorPoint(Vec2(0.5f,0.5f));
pNumber->setPosition(Vec2(visibleSize.width/2.0f,
visibleSize.height/2.0f));
this->addChild(pNumber);
m_numberCount.setLabelAtlas(pNumber); //如果是从cocostudio导出的话请调用NumberCount::setTextAtlas
//将数字每一步的增量初始化为3
m_numberCount.setNumberDelta(3);
//将数字增加时间间隔设置为0.1秒
m_numberCount.setTimeDelta(0.1f);
//将数字初始化为100
m_numberCount.setNumber(100,false);
return true;
}
示例12: updateQuantityLabel
////////////////////////////////////////////////////////
//
// ParticleMainScene
//
////////////////////////////////////////////////////////
void ParticleMainScene::initWithSubTest(int asubtest, int particles)
{
//srandom(0);
subtestNumber = asubtest;
Size s = Director::getInstance()->getWinSize();
lastRenderedCount = 0;
quantityParticles = particles;
MenuItemFont::setFontSize(65);
MenuItemFont *decrease = MenuItemFont::create(" - ", [&](Object *sender) {
quantityParticles -= kNodesIncrease;
if( quantityParticles < 0 )
quantityParticles = 0;
updateQuantityLabel();
createParticleSystem();
});
decrease->setColor(Color3B(0,200,20));
MenuItemFont *increase = MenuItemFont::create(" + ", [&](Object *sender) {
quantityParticles += kNodesIncrease;
if( quantityParticles > kMaxParticles )
quantityParticles = kMaxParticles;
updateQuantityLabel();
createParticleSystem();
});
increase->setColor(Color3B(0,200,20));
Menu *menu = Menu::create(decrease, increase, NULL);
menu->alignItemsHorizontally();
menu->setPosition(Point(s.width/2, s.height/2+15));
addChild(menu, 1);
LabelTTF *infoLabel = LabelTTF::create("0 nodes", "Marker Felt", 30);
infoLabel->setColor(Color3B(0,200,20));
infoLabel->setPosition(Point(s.width/2, s.height - 90));
addChild(infoLabel, 1, kTagInfoLayer);
// particles on stage
LabelAtlas *labelAtlas = LabelAtlas::create("0000", "fps_images.png", 12, 32, '.');
addChild(labelAtlas, 0, kTagLabelAtlas);
labelAtlas->setPosition(Point(s.width-66,50));
// Next Prev Test
ParticleMenuLayer* menuLayer = new ParticleMenuLayer(true, TEST_COUNT, s_nParCurIdx);
addChild(menuLayer, 1, kTagMenuLayer);
menuLayer->release();
// Sub Tests
MenuItemFont::setFontSize(40);
Menu* pSubMenu = Menu::create();
for (int i = 1; i <= 6; ++i)
{
char str[10] = {0};
sprintf(str, "%d ", i);
MenuItemFont* itemFont = MenuItemFont::create(str, CC_CALLBACK_1(ParticleMainScene::testNCallback, this));
itemFont->setTag(i);
pSubMenu->addChild(itemFont, 10);
if (i <= 3)
{
itemFont->setColor(Color3B(200,20,20));
}
else
{
itemFont->setColor(Color3B(0,200,20));
}
}
pSubMenu->alignItemsHorizontally();
pSubMenu->setPosition(Point(s.width/2, 80));
addChild(pSubMenu, 2);
LabelTTF *label = LabelTTF::create(title().c_str(), "Arial", 40);
addChild(label, 1);
label->setPosition(Point(s.width/2, s.height-32));
label->setColor(Color3B(255,255,40));
updateQuantityLabel();
createParticleSystem();
schedule(schedule_selector(ParticleMainScene::step));
}