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; }
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; }