本文整理汇总了C++中MenuItemFont::initWithString方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemFont::initWithString方法的具体用法?C++ MenuItemFont::initWithString怎么用?C++ MenuItemFont::initWithString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemFont
的用法示例。
在下文中一共展示了MenuItemFont::initWithString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
// XXX: deprecated
MenuItemFont * MenuItemFont::create(const std::string& value, Ref* target, SEL_MenuHandler selector)
{
MenuItemFont *ret = new (std::nothrow) MenuItemFont();
ret->initWithString(value, target, selector);
ret->autorelease();
return ret;
}
示例2: MenuItemFont
MenuItemFont * MenuItemFont::create(const std::string& value, const ccMenuCallback& callback)
{
MenuItemFont *ret = new MenuItemFont();
ret->initWithString(value, callback);
ret->autorelease();
return ret;
}
示例3: MenuItemFont
MenuItemFont * MenuItemFont::create(const char *value)
{
MenuItemFont *pRet = new MenuItemFont();
pRet->initWithString(value, (const ccMenuCallback&)nullptr);
pRet->autorelease();
return pRet;
}
示例4: init
bool PlayersSelectLayer::init()
{
if (!Layer::init())
return false;
//return true;
Size visibleSize = Director::sharedDirector()->getVisibleSize();
Menu* menu = Menu::create();
// Add all possibilities
int position = 0;
for(unsigned int i = 1; i <= 2; i++ )
{
std::string label = std::to_string(i);
label += (i == 1) ? " Player" : " Players";
ccMenuCallback callback = std::bind(&PlayersSelectLayer::newGame, this, this, i);
MenuItemFont *newLevel = new MenuItemFont();
newLevel->initWithString(
label.c_str(),
callback
);
newLevel->setPosition(ccp(0, position));
menu->addChild(newLevel);
position -= 50;
}
// Add menu to layer
this->addChild(menu, 1);
menu->setPosition(
ccp(
visibleSize.width/2,
visibleSize.height - 100
)
);
this->setTouchEnabled(true);
return true;
}
示例5: init
bool LevelSelectLayer::init()
{
if (!Layer::init())
return false;
// map filenames to level names
_levelNameMap["00.tmx"] = "0. Test Level";
_levelNameMap["01.tmx"] = "1. Test Level";
_levelNameMap["02.tmx"] = "2. Test Level";
_levelNameMap["03.tmx"] = "3. Test Level";
Size visibleSize = Director::sharedDirector()->getVisibleSize();
Menu* menu = Menu::create();
// Scan directory
DIR *dp;
struct dirent *ep;
std::vector<std::string> files;
std::vector<std::string> dirs;
dirs.push_back("../Resources/levels");
dirs.push_back("./Resources/levels");
dirs.push_back("./levels");
for (auto path : dirs)
{
std::cout << "Searching for levels in " << path << std::endl;
dp = opendir(path.c_str());
if (dp != NULL)
{
while (ep = readdir(dp))
{
std::string name(ep->d_name);
// Must contain .tmx and must not be dir or hidden file
if (name[0] != '.' && name.find(".tmx") != std::string::npos)
files.push_back(name);
}
(void) closedir(dp);
std::sort(files.begin(), files.end());
}
if (files.size() > 0)
{
std::cout << "Directory OK!" << std::endl;
break;
}
}
if (files.size() == 0)
{
std::cerr << "Couldn't open the directory containing maps!" << std::endl;
}
int position = 0;
Bomber::Common::XMLStorage *storage = Bomber::Common::XMLStorage::getInstance();
for (auto filename : files)
{
if (_levelNameMap.count(filename) == 0)
{
std::cerr << "Not defined name for " << filename << std::endl;
//continue;
_levelNameMap[filename] = "Not defined name for " + filename;
}
ccMenuCallback callback = std::bind(&LevelSelectLayer::playersSelect, this, this, filename);
MenuItemFont *newLevel = new MenuItemFont();
std::string nameToDisplay(_levelNameMap[filename]);
if (storage->get("level_status", filename) != "")
{
nameToDisplay += " - ";
nameToDisplay += storage->get("level_status", filename);
}
newLevel->initWithString(
nameToDisplay.c_str(),
callback
);
newLevel->setPosition(ccp(0, position));
menu->addChild(newLevel);
position -= 50;
}
this->addChild(menu, 1);
menu->setPosition(
ccp(
visibleSize.width/2,
visibleSize.height - 100
)
);
this->setTouchEnabled(true);
//.........这里部分代码省略.........