本文整理汇总了C++中MenuItemLabel::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemLabel::setName方法的具体用法?C++ MenuItemLabel::setName怎么用?C++ MenuItemLabel::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuItemLabel
的用法示例。
在下文中一共展示了MenuItemLabel::setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool MapEditer::init()
{
if (!Layer::init())
return false;
m_layer = Layer::create();
this->addChild(m_layer, 1);
Sprite* background = Sprite::create(FileStuff::BACKGROUND_BOTTOM);
float scale = (Director::getInstance()->getVisibleSize().width) / (background->getContentSize().width);
background->setAnchorPoint(Point::ZERO);
background->setScale(scale);
this->addChild(background);
Sling* sling = Sling::create();
this->addChild(sling);
EventListenerMouse* mouseListener = EventListenerMouse::create();
mouseListener->onMouseDown = CC_CALLBACK_1(MapEditer::onMouseDown, this);
mouseListener->onMouseScroll = CC_CALLBACK_1(MapEditer::OnMouseScroll, this);
m_clicked_sprite = nullptr;
_eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this);
EventListenerKeyboard* keyboardListener = EventListenerKeyboard::create();
keyboardListener->onKeyPressed = CC_CALLBACK_1(MapEditer::OnKeyPressed, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyboardListener, this);
m_pressedKey = static_cast<EventKeyboard::KeyCode>(-1);
MenuItemLabel* saveButton = MenuItemLabel::create(Label::create("Save", FileStuff::FONT_ARIAL, 20));
saveButton->setPosition(170, 10);
saveButton->setName("saveButton");
this->addChild(saveButton);
MenuItemLabel* playButton = MenuItemLabel::create(Label::create("Play", FileStuff::FONT_ARIAL, 20));
playButton->setPosition(220, 10);
playButton->setName("playButton");
this->addChild(playButton);
MenuItemLabel* backButton = MenuItemLabel::create(Label::create("Back", FileStuff::FONT_ARIAL, 20));
backButton->setPosition(270, 10);
backButton->setName("backButton");
this->addChild(backButton);
MenuItemLabel* warning = MenuItemLabel::create(Label::create("If complete making level\nCHANGE FILE NAME", FileStuff::FONT_ARIAL, 15));
warning->setPosition(200, 40);
warning->setName("warning");
this->addChild(warning);
vector<TargetInfo> infoList;
string fileName = FileStuff::EDITING_FILENAME;
//load from file
if (!cppson::loadFile(infoList, fileName))
{
CCLOG("Target Load Fail.");
return true;
}
else
{
for (TargetInfo targetInfo : infoList)
{
Sprite* sprite = nullptr;
Point point;
switch (targetInfo.m_name.get())
{
case TargetInfo::BUBBLE:
sprite = Sprite::create(FileStuff::BUBBLE);
break;
case TargetInfo::ENEMY:
sprite = Sprite::create(FileStuff::ENEMY);
break;
case TargetInfo::MIRROR:
sprite = Sprite::create(FileStuff::MIRROR);
break;
case TargetInfo::VIRTICAL_MIRROR:
sprite = Sprite::create(FileStuff::VIRTICAL_MIRROR);
break;
case TargetInfo::STAR:
sprite = Sprite::create(FileStuff::BRICK);
break;
default:
sprite = Sprite::create(FileStuff::ENEMY); //default sprite
}
sprite->setTag(targetInfo.m_name.get());
point = Point(targetInfo.m_position.get().x.get(), targetInfo.m_position.get().y.get());
sprite->setPosition(point);
sprite->setRotation(targetInfo.m_rotation.get());
sprite->setScaleX(targetInfo.m_scale.get().x.get());
sprite->setScaleY(targetInfo.m_scale.get().y.get());
if (sprite)
{
m_layer->addChild(sprite);
}
//.........这里部分代码省略.........