当前位置: 首页>>代码示例>>C++>>正文


C++ MenuItemFont类代码示例

本文整理汇总了C++中MenuItemFont的典型用法代码示例。如果您正苦于以下问题:C++ MenuItemFont类的具体用法?C++ MenuItemFont怎么用?C++ MenuItemFont使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MenuItemFont类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MenuItemFont

// XXX: deprecated
MenuItemFont * MenuItemFont::create(const char *value, Object* target, SEL_MenuHandler selector)
{
    MenuItemFont *pRet = new MenuItemFont();
    pRet->initWithString(value, target, selector);
    pRet->autorelease();
    return pRet;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:8,代码来源:CCMenuItem.cpp

示例2: new

MenuItemFont * MenuItemFont::create(const std::string& value)
{
    MenuItemFont *ret = new (std::nothrow) MenuItemFont();
    ret->initWithString(value, (const ccMenuCallback&)nullptr);
    ret->autorelease();
    return ret;
}
开发者ID:Ratel13,项目名称:WarriorQuest,代码行数:7,代码来源:CCMenuItem.cpp

示例3: gameOver

// Menus
void GameLevelLayer::gameOver(bool playerDidWin)
{
	m_isGameOver = true;
    std::string gameText;
    
	if (playerDidWin)
    {
		gameText = "You Won!";
	}
    else
    {
		gameText = "You have Died!";
        CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("hurt.wav");
	}
    
    Menu* pMenu = CCMenu::create();
    pMenu->setPosition(Vec2(240, -100));
    
    MenuItemFont *diedLabel = MenuItemFont::create(gameText);
    diedLabel->setFontName("Marker Felt");
    diedLabel->setFontSize(24);
    diedLabel->setPosition(Vec2(240, 200));
    pMenu->addChild(diedLabel);
    
    MoveBy *slideIn = MoveBy::create(1.0, Vec2(0,250));
    
    MenuItemImage *replay = MenuItemImage::create("replay.png", "replay.png", "replay.png");
    replay->setPosition(Point::ZERO);
    replay->setCallback(CC_CALLBACK_1(GameLevelLayer::replayButtonCallback, this));
    pMenu->addChild(replay);
    
    this->addChild(pMenu, 1);
    
    pMenu->runAction(slideIn);
}
开发者ID:bluemaxmb,项目名称:SuperKoalio_Cocos2D-X_3.1,代码行数:36,代码来源:GameLevelLayer.cpp

示例4: CC_CALLBACK_1

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
 //   auto closeItem = MenuItemImage::create(
 //                                          "CloseNormal.png",
 //                                          "CloseSelected.png",
 //                                          CC_CALLBACK_1(HelloWorld::menuCloseCallback, this));
 //   
	//closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2 ,
 //                               origin.y + closeItem->getContentSize().height/2));

	MenuItemFont* buttonItem = MenuItemFont::create("menu item font", CC_CALLBACK_1(HelloWorld::showNewLayer, this));
	buttonItem->setPosition(visibleSize.width/2, visibleSize.height/2);

    // create menu, it's an autorelease object
	auto menu = Menu::create(buttonItem, NULL);
    menu->setPosition(Vec2::ZERO);
    this->addChild(menu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    auto label = Label::createWithTTF("Hello World", "fonts/Marker Felt.ttf", 24);
    
    // position the label on the center of the screen
    label->setPosition(Vec2(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - label->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(label, 1);

    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(sprite, 0);

    
    return true;
}
开发者ID:junhaesung,项目名称:newLayerTest,代码行数:61,代码来源:HelloWorldScene.cpp

示例5: Vec2

void TitleScene::displayBG()
{
	auto wall = DrawNode::create();
	wall->drawSolidRect(Vec2(0, 0), Vec2(m_visibleSize.width, m_visibleSize.height), Color4F::WHITE);
	this->addChild(wall);

	auto title = Sprite::create("img/title.png");

	// position the sprite on the center of the screen
	title->setScale(m_visibleSize.width / m_visibleSize.height);
	title->setPosition(Point(m_visibleSize.width / 2, m_visibleSize.height / 1.3));

	// add the sprite as a child to this layer
	this->addChild(title);

	MenuItemFont::setFontSize(60);
	MenuItemFont* newGameItem = MenuItemFont::create("START", CC_CALLBACK_1(TitleScene::menuSceneTransition, this));

	auto label1 = Label::createWithTTF("START", "fonts/arial.ttf", 55);
	label1->setColor(Color3B::BLACK);
	label1->enableOutline(Color4B::BLACK, 2);
	newGameItem->setLabel(label1);

	auto menu = Menu::create(newGameItem, NULL);
	menu->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height / 3.7));
	this->addChild(menu);
}
开发者ID:riverreal,项目名称:The-Shepherd,代码行数:27,代码来源:TitleScene.cpp

示例6: addChild

bool GameOver::init()
{
	LayerColor::initWithColor(Color4B::WHITE);

	Size size = Director::getInstance()->getVisibleSize();
	auto label = LabelTTF::create("Game Over","arial",36);

	label->setColor(Color3B::BLACK);
	
	label->setPosition(size.width/2,size.height/2);
	addChild(label);

	
	MenuItemFont::setFontSize(60);
	MenuItemFont::setFontName("arial");


	MenuItemFont* item = MenuItemFont::create("play again", CC_CALLBACK_1(GameOver::onMenuCallBack, this));

	item->setColor(Color3B::BLACK);
	Menu* mu = Menu::create(item, nullptr);

	mu->setPosition(size.width / 2, size.height / 2 - 60);
	addChild(mu);
	
	return true;
}
开发者ID:slienthuang,项目名称:MyGame,代码行数:27,代码来源:GameOver.cpp

示例7: Size

// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::getInstance()->getWinSize();

    TableView* tableView = TableView::create(this, Size(250, 60));
    tableView->setDirection(ScrollView::Direction::HORIZONTAL);
    tableView->setPosition(Point(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, Size(60, 250));
	tableView->setDirection(ScrollView::Direction::VERTICAL);
	tableView->setPosition(Point(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(Point(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(Point::ZERO);
	addChild(menuBack);

    return true;
}
开发者ID:aberaud,项目名称:cocos2d-x,代码行数:34,代码来源:TableViewTestScene.cpp

示例8: menuCallback

void CocosGUITestScene::menuCallback(Object *pSender)
{
    MenuItemFont* pItem = dynamic_cast<MenuItemFont*>(pSender);
    
    switch (pItem->getTag())
    {
        case 0:
        {
            UISceneManager* pManager = UISceneManager::sharedUISceneManager();
            Scene* pScene = pManager->currentUIScene();
            CCDirector::getInstance()->replaceScene(pScene);
        }
            break;
            
            /*
        case 1:
        {
            CocosGUIExamplesRegisterScene* pScene = new CocosGUIExamplesRegisterScene();
            pScene->runThisTest();
            pScene->release();
        }
             */
            break;
            
        default:
            break;
    }
}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:28,代码来源:CocosGUIScene.cpp

示例9: CCSizeMake

// on "init" you need to initialize your instance
bool TableViewTestLayer::init()
{
    if ( !Layer::init() )
    {
        return false;
    }

	Size winSize = Director::sharedDirector()->getWinSize();

    TableView* tableView = TableView::create(this, CCSizeMake(250, 60));
    tableView->setDirection(kScrollViewDirectionHorizontal);
    tableView->setPosition(ccp(20,winSize.height/2-30));
    tableView->setDelegate(this);
    this->addChild(tableView);
    tableView->reloadData();

	tableView = TableView::create(this, CCSizeMake(60, 250));
	tableView->setDirection(kScrollViewDirectionVertical);
	tableView->setPosition(ccp(winSize.width-150,winSize.height/2-120));
	tableView->setDelegate(this);
	tableView->setVerticalFillOrder(kTableViewFillTopDown);
	this->addChild(tableView);
	tableView->reloadData();

	// Back Menu
	MenuItemFont *itemBack = MenuItemFont::create("Back", CC_CALLBACK_1(TableViewTestLayer::toExtensionsMainLayer, this));
	itemBack->setPosition(ccp(VisibleRect::rightBottom().x - 50, VisibleRect::rightBottom().y + 25));
	Menu *menuBack = Menu::create(itemBack, NULL);
	menuBack->setPosition(PointZero);
	addChild(menuBack);

    return true;
}
开发者ID:bassarisse,项目名称:LostInCaves,代码行数:34,代码来源:TableViewTestScene.cpp

示例10: MenuItemFont

MenuItemFont * MenuItemFont::create(const std::string& value, const ccMenuCallback& callback)
{
    MenuItemFont *ret = new MenuItemFont();
    ret->initWithString(value, callback);
    ret->autorelease();
    return ret;
}
开发者ID:253627764,项目名称:WagonWar,代码行数:7,代码来源:CCMenuItem.cpp

示例11: CC_CALLBACK_1

void TutorialScene::setConfirm()
{
	const int maxNumMonsters = 3;
	const int maxNumEquip = 10;

	if (Generic::checkSaveData())//If there is data - Display confirmation menu to reset it
	{
		
		auto confirmText = Label::createWithTTF("データを消してもよろしいですか", "fonts/ant-maru.ttf", 45);
		confirmText->enableOutline(Color4B::WHITE, 2);
		confirmText->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 1.5));
		this->addChild(confirmText);
		
		MenuItemFont::setFontSize(60);
		MenuItemFont* yesItem = MenuItemFont::create("YES", CC_CALLBACK_1(TutorialScene::menuSceneTransition, this));
		MenuItemFont* noItem = MenuItemFont::create("NO", CC_CALLBACK_1(TutorialScene::rtrnTitleScene, this));
		auto label1 = Label::createWithTTF("はい", "fonts/ant-maru.ttf", 45);
		auto label2 = Label::createWithTTF("いいえ", "fonts/ant-maru.ttf", 45);
		label1->enableOutline(Color4B::WHITE, 2);
		label2->enableOutline(Color4B::WHITE, 2);
		yesItem->setLabel(label1);
		noItem->setLabel(label2);

		confirmMenu = Menu::create(yesItem, noItem, NULL);
		confirmMenu->setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 3));
		confirmMenu->alignItemsVerticallyWithPadding(30);
		this->addChild(confirmMenu);
	}
	else
	{
        
		/*
		resetSaveData();
        auto listener = EventListenerTouchOneByOne::create();
        listener->setSwallowTouches(true);
        
        listener->onTouchBegan = [](Touch* touch, Event* event)
        {
            return true;
        };
        
        listener->onTouchEnded = [](Touch* touch, Event* event)
        {
            auto nextScene = MenuScene::createScene();
            auto pScene = TransitionFade::create(1.0f, nextScene);
            Director::getInstance()->replaceScene(MenuScene::createScene());
            CCLOG("Test");
        };
        
        
        this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
		*/
		auto tmpNode = Node::create();
		auto transition = CallFunc::create([this](){this->continueToMenu(); });
		tmpNode->runAction(transition);
	}
}
开发者ID:riverreal,项目名称:MillionCode,代码行数:57,代码来源:TutorialScene.cpp

示例12: addChild

bool TMenu::init()
{
	Layer::init();

	Menu * menu = Menu::create();
	addChild(menu);
	
	for (int i = 0; i < sizeof(title) / sizeof(*title); ++i)
	{
		MenuItemFont * item = MenuItemFont::create(title[i], [](Ref * sender){
			MenuItem * item = (MenuItem *)sender;
			int i = item->getTag() - 1000;
			Layer * l = NULL;
			if (title[i] == "T01CPP11") l = T01CPP11::create();
			else if (title[i] == "T02Vector") l = T02Vector::create();
			else if (title[i] == "T03Map") l = T03Map::create();
			else if (title[i] == "T04Label") l = T04Label::create();
			else if (title[i] == "T05Touch") l = T05Touch::create();
			else if (title[i] == "T06Box2D") l = T06Box2D::create();
			else if (title[i] == "T07PhysicsWorld") l = T07PhysicsWorld::create();
			else if (title[i] == "T08RayCast") l = T08RayCast::create();
			else if (title[i] == "T09Joint") l = T09Joint::create();
			else if (title[i] == "T10MultiShapes") l = T10MultiShapes::create();
			else if (title[i] == "T11FlyppyBird") l = T11FlyppyBird::create();
			if (l != NULL)
			{
				TBack * b = TBack::create();
				//Scene * s = Scene::create();
				Scene * s = Scene::createWithPhysics(); // 3.x ÎïÀíÊÀ½ç
				PhysicsWorld * world = s->getPhysicsWorld();
				world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
				s->addChild(b);
				s->addChild(l);
				Director::getInstance()->pushScene(s);

			}
		});
		menu->addChild(item);
		item->setTag(1000 + i);
	}

	menu->alignItemsVertically();

	// ´¥Ãþ
	auto ev = EventListenerTouchOneByOne::create();
	//ev->onTouchBegan = std::bind(&TMenu::touchBegan, this, std::placeholders::_1, std::placeholders::_2);
	ev->onTouchBegan = CC_CALLBACK_2(TMenu::touchBegan, this);
	ev->onTouchMoved = [&](Touch * touch, Event *){
		setPositionY(getPositionY() + touch->getDelta().y);
	};
	_eventDispatcher->addEventListenerWithSceneGraphPriority(ev, this);

	return true;
}
开发者ID:hcy12321,项目名称:cocos2dx3xTest,代码行数:54,代码来源:TMenu.cpp

示例13: Point

// on "init" you need to initialize your instance
bool TestIAP::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    MyPurchase::getInstance()->loadIAPPlugin();

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    auto pEGLView = Director::getInstance()->getOpenGLView();
    Point posBR = Point(pEGLView->getVisibleOrigin().x + pEGLView->getVisibleSize().width, pEGLView->getVisibleOrigin().y);
    Point posTL = Point(pEGLView->getVisibleOrigin().x, pEGLView->getVisibleOrigin().y + pEGLView->getVisibleSize().height);

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestIAP::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );
    this->addChild(pMenu, 1);

    Point posStep = Point(220, -150);
    Point beginPos = posTL + (posStep * 0.5f);
    int line = 0;
    int row = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
    	MenuItemImage* pMenuItem = MenuItemImage::create(s_EventMenuItem[i].id.c_str(), s_EventMenuItem[i].id.c_str(),
    			CC_CALLBACK_1(TestIAP::eventMenuCallback, this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);

        Point pos = beginPos + Point(posStep.x * row, posStep.y * line);
        Size itemSize = pMenuItem->getContentSize();
        if ((pos.x + itemSize.width / 2) > posBR.x)
		{
			line += 1;
			row = 0;
			pos = beginPos + Point(posStep.x * row, posStep.y * line);
		}
        row += 1;
        pMenuItem->setPosition(pos);
    }

    return true;
}
开发者ID:LeeWei92,项目名称:cocos2dx-3.2-qt,代码行数:53,代码来源:TestIAPScene.cpp

示例14: onClick

void MenuScene::onClick(Ref* sender)
{
	MenuItemFont* pFont = (MenuItemFont*) sender;
	switch( pFont->getTag() )
	{
	case 1:
		{
			CSceneManager::getInstance()->pushScene(
				CCSceneExTransitionFade::create(1.0f, LoadScene("BasicSceneTest"))
				);
		}
		break;
	}
}
开发者ID:110440,项目名称:Tui-x,代码行数:14,代码来源:MenuScene.cpp

示例15: loadPlugins

// on "init" you need to initialize your instance
bool TestAnalytics::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

    _pluginAnalytics = NULL;
    loadPlugins();

    Size visibleSize = Director::getInstance()->getVisibleSize();
    Point origin = Director::getInstance()->getVisibleOrigin();
    Point posBR = Point(origin.x + visibleSize.width, origin.y);

    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
    MenuItemFont *pBackItem = MenuItemFont::create("Back", CC_CALLBACK_1(TestAnalytics::menuBackCallback, this));
    Size backSize = pBackItem->getContentSize();
    pBackItem->setPosition(posBR + Point(- backSize.width / 2, backSize.height / 2));

    // create menu, it's an autorelease object
    Menu* pMenu = Menu::create(pBackItem, NULL);
    pMenu->setPosition( Point::ZERO );
    this->addChild(pMenu, 1);

    float yPos = 0;
    for (int i = 0; i < sizeof(s_EventMenuItem)/sizeof(s_EventMenuItem[0]); i++) {
        LabelTTF* label = LabelTTF::create(s_EventMenuItem[i].id.c_str(), "Arial", 24);
        MenuItemLabel* pMenuItem = MenuItemLabel::create(label, CC_CALLBACK_1(TestAnalytics::eventMenuCallback, this));
        pMenu->addChild(pMenuItem, 0, s_EventMenuItem[i].tag);
        yPos = visibleSize.height - 35*i - 100;
        pMenuItem->setPosition( Point(visibleSize.width / 2, yPos));
    }

    std::string strName = _pluginAnalytics->getPluginName();
    std::string strVer = _pluginAnalytics->getSDKVersion();
    char ret[256] = { 0 };
    sprintf(ret, "Plugin : %s, Ver : %s", strName.c_str(), strVer.c_str());
    LabelTTF* pLabel = LabelTTF::create(ret, "Arial", 18, Point(visibleSize.width, 0), Label::HAlignment::CENTER);
    pLabel->setPosition(Point(visibleSize.width / 2, yPos - 80));
    addChild(pLabel);

    return true;
}
开发者ID:CBanDa,项目名称:cocos2d-x-3.0alpha0-pre,代码行数:50,代码来源:TestAnalyticsScene.cpp


注:本文中的MenuItemFont类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。