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


C++ CCMenuItemSprite::boundingBox方法代码示例

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


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

示例1: init

bool OptionsLayer::init()
{
	bool bRet = false;
	
	do 
	{
		CC_BREAK_IF(! OverlayBase::init());
        
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		int leftSpace = 100;

		setTouchEnabled(true);
	
		CCSprite* bg = CCSprite::create(SETTINGS_BG_NAME.c_str());
		
		bg->setAnchorPoint(ccp(0,0));
        bg->setPosition(ccp(0, 0));
		addChild(bg, -1);

		//Cancel - Go Menu
        CCMenuItemSprite* mRightArrow = sgl_SpriteFactory.createMenuItemSprite("btnArrow_Back128x128.png", "btnArrow_Back128x128Pressed.png", menu_selector(OverlayBase::onQuit), this);
        CCMenu* menuReturn = CCMenu::create(mRightArrow, NULL);
        
        CCMenuItemSprite* mLeftArrow = 
			sgl_SpriteFactory.createMenuItemSprite("btnArrow128x128.png", "btnArrow128x128.png", menu_selector(OptionsLayer::onApply), this);
        CCMenu* mStartGame = CCMenu::create(mLeftArrow, NULL);
        
		menuReturn->setPosition(leftSpace, 150);
		mStartGame->setPosition(size.width - leftSpace - mLeftArrow->boundingBox().size.width * 0.5f, 150);
        
        addChild(mStartGame);
        addChild(menuReturn);

		initControls();

		bRet = true;
	} while (0);

	return bRet;
}
开发者ID:koboldul,项目名称:Football,代码行数:40,代码来源:OptionsLayer.cpp

示例2: init

bool MultiplayerLayer::init()
{
    bool bRet = false;
	do
	{
		CC_BREAK_IF(! OverlayBase::init());
		
		CCSize size = CCDirector::sharedDirector()->getWinSize();
		int leftSpace = 100;

        _opponentType = kHuman;
        
        CCMenuItemSprite* hItem = createMenuItemSprite((char*)"btnHotSeat128x128.png",
                                                       (char*)"btnHotSeatPressed.png",
                                                       menu_selector(MultiplayerLayer::onHotSeat));
        CCMenuItemSprite* onlineItem = createMenuItemSprite((char*)"btnOnlineGame128x128.png",
                                                       (char*)"btnOnlineGamePressed.png",
                                                       menu_selector(MultiplayerLayer::onOnlineGame));
        
        CCMenu* menu = CCMenu::create(hItem, onlineItem, NULL);
        menu->alignItemsVertically();
		menu->setPosition(ccp(leftSpace, size.height - 2 * leftSpace));
		addChild(menu, 1);
        
        
        if (!sgl_ConnectionManager.getRoomNumber().empty())
        {
            CCMenuItemSprite* onlineReconnectItem = createMenuItemSprite((char*)"btnOnlineGameReconnect.png",
                                                                (char*)"btnOnlineGamePressed.png",
                                                                menu_selector(MultiplayerLayer::onOnlineGame));
            
            menu->cocos2d::CCNode::addChild(onlineReconnectItem);
        }
        
		float menuLimit = hItem->getPosition().x + hItem->boundingBox().size.width + 20;

		CCLabelTTF* lH = new CCLabelTTF();
		lH->initWithString("Hot seat", S_F_TYPE.c_str(), 32);
		lH->setPosition(ccp(menuLimit, hItem->getPosition().y));
		lH->setAnchorPoint(ccp(0,0));
        hItem->addChild(lH);
        
        CCLabelTTF* lO = new CCLabelTTF();
        lO->initWithString("Random online game", S_F_TYPE.c_str(), 32);
        lO->setPosition(ccp(menuLimit, hItem->getPosition().y));
		lO->setAnchorPoint(ccp(0,0));
        onlineItem->addChild(lO);

        //Cancel - Go Menu
        CCMenuItemSprite* mRightArrow =
            sgl_SpriteFactory.createMenuItemSprite("btnArrow_Back128x128.png", "btnArrow_Back128x128Pressed.png", menu_selector(MultiplayerLayer::onQuit), this);
        CCMenu* menuReturn = CCMenu::create(mRightArrow, NULL);
        
        CCMenuItemSprite* mLeftArrow =
            sgl_SpriteFactory.createMenuItemSprite("btnArrow128x128.png", "btnArrow128x128Pressed.png", menu_selector(MultiplayerLayer::onConnect), this);
        
        CCMenu* mStartGame = CCMenu::create(mLeftArrow, NULL);
        
		menuReturn->setPosition(leftSpace, 150);
		mStartGame->setPosition(size.width - leftSpace - mLeftArrow->boundingBox().size.width * 0.5f, 150);
        
        addChild(mStartGame);
        addChild(menuReturn);
        
        
        _connectionStatus = CCLabelTTF::create("", S_F_TYPE.c_str(), 32);
		_connectionStatus->setPosition(ccp(size.width/2, 150));
        
        this->addChild(_connectionStatus);
        
		bRet = true;
	} while (0); 
    
	return bRet;
}
开发者ID:koboldul,项目名称:Football,代码行数:75,代码来源:MultiplayerLayer.cpp


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