Ejemplo n.º 1
0
bool HSGameFrisbee::init()
{
	CCMenu* pSetingMenu = HS_FIND_UI_MENU("UI_HEbinggaojiduchangxin_Xitongtuibiao_01");

	//ÒôЧ
	HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_0",this,HSGameFrisbee::Call_Muisc);
	//ÒôÀÖ
	HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_1",this,HSGameFrisbee::Call_Sound);
	//°ïÖú
	HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_2",this,HSGameFrisbee::Call_Help);
	//¹ØÓÚ
	HS_SET_MENU_TARGET("UI_HEbinggaojiduchangxin_shezhi_3",this,HSGameFrisbee::Call_About);

	for (int i=0;i<50;++i)
	{
		CCString* ui = CCString::createWithFormat("UI_HEbinggaojiduchangxin_shezhi_%d",i);
		CCMenu* otherMenu = HS_FIND_UI_MENU(ui->getCString());
		if (!otherMenu)
		{
			continue;
		}
		
		_MenuItem tempMenuItem;
		tempMenuItem.pNode = otherMenu;
		tempMenuItem.srcPos = pSetingMenu->getPosition();
		tempMenuItem.endPos = otherMenu->getPosition();
		m_menuList.push_back(tempMenuItem);

		otherMenu->setPosition(pSetingMenu->getPosition());
		otherMenu->setVisible(false);
	}

	return true;
}
Ejemplo n.º 2
0
void ControllPanel::createAttackButton()
{
	std::string nameOne = "";
	std::string nameTwo = "";
	nameOne = s_touchfile + s_language + "actor_btn_noramlAtt.png";
	nameTwo = s_touchfile + s_language + "actor_btn_magicAtt.png";
	//普通攻击item
	CCMenuItemImage *pNormalItem = CCMenuItemImage::itemFromNormalImage(
		nameOne.c_str(),
		nameOne.c_str(),
		this,
		menu_selector(ControllPanel::normalAttackClick));
	//魔法攻击item
	m_pMagicItem = CCMenuItemImage::itemFromNormalImage(
		nameTwo.c_str(),
		nameTwo.c_str(),
		this,
		menu_selector(ControllPanel::magicAttackClick));

	CCMenu *pNormalAttMenu = CCMenu::menuWithItem(pNormalItem);
	CCMenu *pMagicAttMenu = CCMenu::menuWithItem(m_pMagicItem);

	CCSize bgSize = this->m_pBg->getContentSize();


	pNormalAttMenu->setPosition(ccp(bgSize.width - 200, bgSize.height / 2));
	pMagicAttMenu->setPosition(ccp(pNormalAttMenu->getPosition().x + 120, pNormalAttMenu->getPosition().y));

	this->addChild(pNormalAttMenu);
	this->addChild(pMagicAttMenu);

}
Ejemplo n.º 3
0
void Bug422Layer::reset()
{
	static int localtag = 0;
	localtag++;

	// TO TRIGGER THE BUG:
	// remove the itself from parent from an action
	// The menu will be removed, but the instance will be alive
	// and then a new node will be allocated occupying the memory.
	// => CRASH BOOM BANG
	CCNode *node = getChildByTag(localtag-1);
	CCLog("Menu: %p", node);
	removeChild(node, false);
//	[self removeChildByTag:localtag-1 cleanup:NO];

    CCMenuItem *item1 = CCMenuItemFont::itemFromString("One", this, menu_selector(Bug422Layer::menuCallback));
	CCLog("MenuItemFont: %p", item1);
    CCMenuItem *item2 = CCMenuItemFont::itemFromString("Two", this, menu_selector(Bug422Layer::menuCallback));
    CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL);
	menu->alignItemsVertically();

	float x = CCRANDOM_0_1() * 50;
	float y = CCRANDOM_0_1() * 50;
	menu->setPosition(ccpAdd( menu->getPosition(), ccp(x,y)));
    addChild(menu, 0, localtag);	

    //[self check:self];
}
Ejemplo n.º 4
0
//------------------------------------------------------------------
//
// MenuLayer2
//
//------------------------------------------------------------------
MenuLayer2::MenuLayer2()
{
    for( int i=0;i < 2;i++ ) 
    {
        CCMenuItemImage* item1 = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect, this, menu_selector(MenuLayer2::menuCallback));
        CCMenuItemImage* item2 = CCMenuItemImage::create(s_HighNormal, s_HighSelect, this, menu_selector(MenuLayer2::menuCallbackOpacity) );
        CCMenuItemImage* item3 = CCMenuItemImage::create(s_AboutNormal, s_AboutSelect, this, menu_selector(MenuLayer2::menuCallbackAlign) );
        
        item1->setScaleX( 1.5f );
        item2->setScaleX( 0.5f );
        item3->setScaleX( 0.5f );
        
        CCMenu* menu = CCMenu::create(item1, item2, item3, NULL);
        
        CCSize s = CCDirector::sharedDirector()->getWinSize();
        menu->setPosition(ccp(s.width/2, s.height/2));

        menu->setTag( kTagMenu );
        
        addChild(menu, 0, 100+i);

        m_centeredMenu = menu->getPosition();
    }

    m_alignedH = true;
    alignMenusH();
}
Ejemplo n.º 5
0
void GameHud::soldier4_Select(CCNode *pSender){
    CCMenu* menu =(CCMenu*) this->getChildByTag(10);
    CCPoint pos = ccpAdd(menu->getPosition(), pSender->getPosition());
    selectFlag->setPosition(pos);
    CCLabelTTF* lab =(CCLabelTTF*) this->getChildByTag(101);
    lab->setString("所需 150 援兵");
    selectPro = Pikeman;
    selectID = "A4";
}
Ejemplo n.º 6
0
void MenuLayer2::alignMenusV()
{
	for(int i=0;i<2;i++) 
	{
		CCMenu *menu = (CCMenu*)getChildByTag(100+i);
		menu->setPosition( m_centeredMenu );
		if(i==0) 
		{
			// TIP: if no padding, padding = 5
			menu->alignItemsVertically();			
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpAdd(p, CGPointMake(100,0)) );			
		} 
		else 
		{
			// TIP: but padding is configurable
			menu->alignItemsVerticallyWithPadding(40);	
			CGPoint p = menu->getPosition();
			menu->setPosition( ccpSub(p, CGPointMake(100,0)) );
		}		
	}
}
Ejemplo n.º 7
0
	void UIScrollLayer::checkChildrenPos()
	{
		//CCArray* array = m_PageLayer->getChildren();
		CCObject* obj;
		CCARRAY_FOREACH(m_PageLayer,obj)
		{		
			CCLayer* layer = dynamic_cast<CCLayer*>(obj);
			if(layer)
			{
				CCArray* itemArray = layer->getChildren();
				CCObject* itemObj;
				CCARRAY_FOREACH(itemArray,itemObj)
				{
					CCNode* iconButton = dynamic_cast<CCNode*>(itemObj);
					if(iconButton)
					{
						CCArray* menuArray = iconButton->getChildren();
						CCObject* menuObj;
						CCARRAY_FOREACH(menuArray,menuObj)
						{
							CCMenu* menu = dynamic_cast<CCMenu*>(menuObj);
							if(menu)
							{
								CCArray* menuItemArray = menu->getChildren();
								CCObject* menuItmeObj;
								bool claim = false;
								CCARRAY_FOREACH(menuItemArray,menuItmeObj)
								{
									CCMenuItem* item = dynamic_cast<CCMenuItem*>(menuItmeObj);
									if(item)
									{
										CCPoint pt = layer->convertToWorldSpace(menu->getPosition());
										claim = touchIsInContent(pt);
										if(claim)
										{
											break;
										}
									}
								}
								menu->setEnabled(claim);
							}
						}
					}
Ejemplo n.º 8
0
//---------------------------------------------------------
//
//
void CMessageBoxYesNo::onEnter()
{
    CCXMLLayer::onEnter();
    
    LoadPlist( "tip_1.plist" );
    
    const char *MenuButton[] = { "button_yes", "button_no" };
    
    const char *YesNo[] = { "YES", "NO" };
    for( int i = 0; i < 2; i++ )
	{
		CCSprite *pSprite= (CCSprite*)GetXMLNodeFromKey( MenuButton[i] );
		CCMenu *pMenu = CreatGameUIWithSprite( pSprite, menu_selector(CMessageBoxYesNo::menuCallback), i, this, pSprite->getPosition() );
		addChild( pMenu, pSprite->getZOrder() );
        removeChild( pSprite, true );
        
        
        CCLabelTTF* pLabelTTF = CCLabelTTF::labelWithString( YesNo[i], kFontSystem[FONT_GRAND].fontName, kFontSystem[FONT_GRAND].fontSize );
        pLabelTTF->setPosition( pMenu->getPosition() );
        CCRenderTexture* pstroke = createStroke(pLabelTTF, 1, kFontSystem[FONT_GRAND].strokeColor);
        addChild( pstroke,100 );
        addChild( pLabelTTF,100 );
	}
    
    CCNode *pNode =  GetXMLNodeFromKey( "t2dSceneObject_Message" );
	CCLabelTTF* pLabelTTF = CCLabelTTF::labelWithString( m_szBuffer, kFontSystem[FONT_THIN].fontName, kFontSystem[FONT_THIN].fontSize );
	pLabelTTF->setPosition( pNode->getPosition() );
    CCRenderTexture* pstroke = createStroke(pLabelTTF, 1, kFontSystem[FONT_THIN].strokeColor);
    addChild( pstroke,100 );
	addChild( pLabelTTF,100 );
    
    //pNode =  GetXMLNodeFromKey( "t2dSceneObject_tipname" );
	//pLabelTTF = CCLabelTTF::labelWithString( m_TitleBuffer, kFontSystem[FONT_THIN].fontName, kFontSystem[FONT_THIN].fontSize );
	//pLabelTTF->setPosition( pNode->getPosition() );
    //pstroke = createStroke(pLabelTTF, 1, kFontSystem[FONT_THIN].strokeColor);
    //addChild( pstroke,100 );
	//addChild( pLabelTTF,100 );
}
Ejemplo n.º 9
0
//------------------------------------------------------------------
//
// MenuLayer2
//
//------------------------------------------------------------------
MenuLayer2::MenuLayer2()
{
	for( int i=0;i < 2;i++ ) 
	{
		CCMenuItemImage* item1 = CCMenuItemImage::itemFromNormalImage(s_PlayNormal, s_PlaySelect, this, menu_selector(MenuLayer2::menuCallback));
		CCMenuItemImage* item2 = CCMenuItemImage::itemFromNormalImage(s_HighNormal, s_HighSelect, this, menu_selector(MenuLayer2::menuCallbackOpacity) );
		CCMenuItemImage* item3 = CCMenuItemImage::itemFromNormalImage(s_AboutNormal, s_AboutSelect, this, menu_selector(MenuLayer2::menuCallbackAlign) );
		
		item1->setScaleX( 1.5f );
		item2->setScaleX( 0.5f );
		item3->setScaleX( 0.5f );
		
		CCMenu* menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
		
		menu->setTag( kTagMenu );
		
		addChild(menu, 0, 100+i);

		m_centeredMenu = menu->getPosition();
	}

	m_alignedH = true;
	alignMenusH();
}
Ejemplo n.º 10
0
bool GameHud::init()
{
    bool ret = false;
    do {
        CC_BREAK_IF(!CCLayer::init());
        CCSize winsize = CCDirector::sharedDirector()->getWinSize();
       CCSprite* background = CCSprite::create("hud.png");
		background->setAnchorPoint(CCPointZero);
        float saclex = winsize.width/background->boundingBox().size.width;
        background->setScaleX(saclex);
		this->addChild(background);

        CCMenuItemSprite * item1 = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("A1_0.png"), CCSprite::createWithSpriteFrameName("A1_0.png"), this, menu_selector(GameHud::soldier1_Select));
        item1->setPosition(ccp(10,10));
        CCMenuItemSprite * item2 = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("A2_0.png"), CCSprite::createWithSpriteFrameName("A2_0.png"), this, menu_selector(GameHud::soldier2_Select));
        item2->setPosition(ccp(110, 10));
        CCMenuItemSprite * item3 = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("A3_0.png"), CCSprite::createWithSpriteFrameName("A3_0.png"), this, menu_selector(GameHud::soldier3_Select));
        item3->setPosition(ccp(210, 10));
        CCMenuItemSprite * item4 = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("A4_0.png"), CCSprite::createWithSpriteFrameName("A4_0.png"), this, menu_selector(GameHud::soldier4_Select));
        item4->setPosition(ccp(310, 10));
        CCMenu* menu = CCMenu::create(item1,item2,item3,item4,NULL);
        menu->setPosition(ccp(100,30));
        menu->setTag(10);
        this->addChild(menu);
        selectFlag = CCSprite::create("aim.png");
        selectFlag->retain();
        selectFlag->setScale(0.5f);
        selectFlag->setPosition( ccpAdd(item1->getPosition(), menu->getPosition()));
        this->addChild(selectFlag);
        CCLabelTTF* lab = CCLabelTTF::create("所需 100 援兵", "Arial-BoldMT", 20);
        lab->setColor(ccRED);
        lab->setTag(101);
        lab->setPosition(ccp(600, 40));
        this->addChild(lab);
        CCMenuItemFont *add = CCMenuItemFont::create("增援", this, menu_selector(GameHud::click_addSoldier));
        
        add->setPosition(CCPointZero);
        add->setFontSizeObj(35);
        add->setColor(ccRED);
        CCMenu *menu0 = CCMenu::createWithItem(add);
        menu0->setPosition( winsize.width-200, 40);
        this->addChild(menu0);
        
        CCMenuItemSprite* btn_attack = CCMenuItemSprite::create(
                                                                CCSprite::createWithSpriteFrameName("btn_soldierattack1.png"),
                                                                CCSprite::createWithSpriteFrameName("btn_soldierattack2.png"),
                                                                this, menu_selector(GameHud::click_attack));
        CCMenu* menu1 = CCMenu::createWithItem(btn_attack);
        menu1->setPosition(ccp(winsize.width-100,40));
        this->addChild(menu1);
        soldier1_Select(item1);
        
        timerLab = CCLabelTTF::create("5", "Arial-BoldMT", 50);
        timerLab->setPosition(ccp(winsize.width/2, winsize.height/2));
        this->addChild(timerLab);
        
        this->setTouchEnabled(true);

        
        this->schedule(schedule_selector(GameHud::countDown), 1.0f);
        
        MaskLayer*  mask = MaskLayer::create();
        
        this->addChild(mask);
        mask->setTag(11);
        GameRoot::shareGameRoot()->sethasStart(false);
        count =3;
        ret = true;
    } while (0);
    return ret;
}
Ejemplo n.º 11
0
// on "init" you need to initialize your instance
bool HelloWorld::init()
{   
	if ( !CCLayer::init() )
    {
        return false;
    }

	CCLog(" HelloWorld  init --->");

	/*CCLog(" SCALE_FACTOR --->%f " , SCALE_FACTOR);*/

	top_distance = SCALE_FACTOR * 16;


    /*CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
 
    pCloseItem->setPosition(ccpAdd(VisibleRect::rightBottom(), 
                                ccp(-pCloseItem->getContentSize().width/2, pCloseItem->getContentSize().height/2)));
 
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);*/
 
    CCLabelTTF* pLabel = CCLabelTTF::create("hello cocos2d-x", "Arial", SCALE_FACTOR * 36 );
    pLabel->setPosition(ccpAdd(VisibleRect::top(),ccp(0, -pLabel->getContentSize().height)));
    this->addChild(pLabel, 1);
 
	//载入主菜单的pic list
	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("main_menu.plist", "main_menu.png");


	//背景图片
    CCSprite* pSprite = CCSprite::create("bg.jpg");
    pSprite->setPosition(VisibleRect::center());
    this->addChild(pSprite, 0);
	
	//两片树叶
	//树叶1
	CCSprite* pSprite_leaf1 = CCSprite::createWithSpriteFrameName("leaf1.png");
	pSprite_leaf1->setPosition( ccpAdd(VisibleRect::center(), ccp(0,pSprite_leaf1->getContentSize().height/2*3)) );
	this->addChild(pSprite_leaf1);

	pSprite_leaf1->setAnchorPoint(ccp(0.5f,0.0f)); //设置锚点为中下点

	//不停摆动的动画
	CCActionInterval* rotateAction1 = CCRotateBy::create(0.1f,25.0f);
    CCActionInterval* rotateAction2 = CCRotateTo::create(0.1f, -25.0f);
	CCDelayTime* sleep_rotate = CCDelayTime::create(4.0f);

	pSprite_leaf1->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(rotateAction1, rotateAction2,rotateAction1, rotateAction2,sleep_rotate, NULL))));

	//树叶2
	CCSprite* pSprite_leaf2 = CCSprite::createWithSpriteFrameName("leaf2.png");
	pSprite_leaf2->setPosition( ccpAdd(VisibleRect::center(), ccp(pSprite_leaf1->getContentSize().width,pSprite_leaf1->getContentSize().height/2*3)) );
	this->addChild(pSprite_leaf2);
	pSprite_leaf2->setAnchorPoint(ccp(0.5f,0.0f)); //设置锚点为中下点


	CCDelayTime* sleep_rotate_2 = CCDelayTime::create(2.0f);
	
	pSprite_leaf2->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(sleep_rotate_2,rotateAction1, rotateAction2,rotateAction1, rotateAction2,sleep_rotate_2, NULL))));


	//小岛
	CCSprite* pSprite_Island = CCSprite::create("island.png");
    pSprite_Island->setPosition(VisibleRect::center());
    this->addChild(pSprite_Island, 0);



	//设置选项(左)
	CCMenuItemSprite* pMenuItemSprite_small_left = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("small_item_normal.png"), CCSprite::createWithSpriteFrameName("small_item_pressed.png") , this, menu_selector(HelloWorld::menuCallback));   
	
	CCMenu* pSpriteMenu_small_left = CCMenu::create(pMenuItemSprite_small_left,NULL);
	pSpriteMenu_small_left->setPosition( ccpAdd(VisibleRect::center(),ccp( - pSprite_Island->getContentSize().width / 2   ,- pSprite_Island->getContentSize().height/3)) );  
	this->addChild(pSpriteMenu_small_left ,1);

	
	//帮助选项(右)
	CCMenuItemSprite* pMenuItemSprite_small_right = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("small_item_normal.png"), CCSprite::createWithSpriteFrameName("small_item_pressed.png") , this,menu_selector(HelloWorld::menuCallback));   
	
	CCMenu* pSpriteMenu_small_right = CCMenu::create(pMenuItemSprite_small_right,NULL);
	pSpriteMenu_small_right->setPosition( ccpAdd(VisibleRect::center(),ccp(  pSprite_Island->getContentSize().width / 2   ,- pSprite_Island->getContentSize().height/3)) );  
	this->addChild(pSpriteMenu_small_right ,1);


	//开始游戏选项

	CCMenuItemSprite* pMenuItemSprite = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("start_normal.png"),  CCSprite::createWithSpriteFrameName("start_pressed.png"), this,menu_selector(HelloWorld::menuCallback));   
	pMenuItemSprite->setTag(MENU_ID_START);
	
	CCMenu* pSpriteMenu = CCMenu::create(pMenuItemSprite,NULL);    
	pSpriteMenu->setPosition( ccpAdd(VisibleRect::bottom(),ccp(0,pMenuItemSprite->getContentSize().height/2*3)) );   
	this->addChild(pSpriteMenu ,1); 


	//关于我们选项
	CCMenuItemSprite* pMenuItemSprite_about = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("about_us_normal.png"), CCSprite::createWithSpriteFrameName("about_us_pressed.png"), this,menu_selector(HelloWorld::menuCallback));   
	pMenuItemSprite_about->setTag(MENU_ID_ABOUT);

	CCMenu* pSpriteMenu_about = CCMenu::create(pMenuItemSprite_about,NULL);    
	pSpriteMenu_about->setPosition( ccpAdd(pSpriteMenu->getPosition(),ccp(- (pMenuItemSprite_about->getContentSize().width+(36*SCALE_FACTOR)),0 )) );   
	this->addChild(pSpriteMenu_about ,1); 


	//左上角心跳选项
	CCMenuItemSprite* pMenuItemSprite_heart = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("heart_normal.png"), CCSprite::createWithSpriteFrameName("heart_pressed.png") , this,menu_selector(HelloWorld::menuCallback));   
	
	CCMenu* pSpriteMenu_heart = CCMenu::create(pMenuItemSprite_heart,NULL);
	pSpriteMenu_heart->setPosition( ccpAdd(VisibleRect::leftTop(),ccp(pMenuItemSprite_heart->getContentSize().width / 2 + top_distance  , -pMenuItemSprite_heart->getContentSize().height / 2 - top_distance)) );  
	this->addChild(pSpriteMenu_heart ,1);

	//添加跳动的动画效果
	CCActionInterval* scaleAction1 = CCScaleTo::create(0.1f, 1.2f, 1.2f);
    CCActionInterval* scaleAction2 = CCScaleTo::create(0.1f, 1.0f, 1.0f);
	CCDelayTime* sleep = CCDelayTime::create(1.0f);

	CCActionInterval* seq = (CCActionInterval*)(CCSequence::create(scaleAction1, scaleAction2,scaleAction1, scaleAction2,sleep, NULL));
	CCActionInterval* rep = CCRepeatForever::create(seq);

	pMenuItemSprite_heart->runAction(rep);


	//小飞块 
	CCSprite* pS_fly = CCSprite::createWithSpriteFrameName("fly.png");
	pS_fly->setPosition( ccpAdd( pSpriteMenu_heart->getPosition() , ccp(pS_fly->getContentSize().width, -pS_fly->getContentSize().height*2) ) );

	this->addChild(pS_fly);

	//添加上下来回移动的动画效果
	CCMoveBy *move = CCMoveBy::create(3.5f,ccp(0,pS_fly->getContentSize().height));  
    pS_fly->runAction(CCRepeatForever::create(static_cast<CCSequence *>(CCSequence::create(move,move->reverse(),NULL))));  


    return true;
}
Ejemplo n.º 12
0
bool VVAlertView::initWithTitle(const char* aTitle, const char* aMessage, VVAlertViewDelegate* aDelegate, const char* aCancelBtnTitle, const char* aOtherBtnTitle)
{
    if ( !VVPopupLayer::init() )
		return false;
    
    delegate = aDelegate;
    
    overlayLayer->removeFromParentAndCleanup(true);
    
    CCLabelTTF *titleLabel = NULL;
    
    if( aTitle != NULL )
    {
        titleLabel = CCLabelTTF ::labelWithString(aTitle ,fontName.c_str(), titleFontSize);
    }
    
    CCScale9Sprite *bg = CCScale9Sprite::scale9SpriteWithFile(alertBG_name.c_str(), alert9patch_rect);
    
    
    CCLabelTTF *msgLabel = CCLabelTTF::labelWithString(aMessage, CCSizeMake(maxWidth-borderPadding*4, 0), CCTextAlignmentCenter, fontName.c_str(), messageFontSize);
    
    
    CCMenuItemSprite* btnCancel = CCMenuItemDynamic::dynamicItemWithTTFLabel(aCancelBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this,
                                                                             menu_selector(VVAlertView::onBtnCancel), 
                                                                             btn9patch_rect, 255);
    CCMenu *menu;
    if (aOtherBtnTitle == NULL) 
    {
        menu = CCMenu::menuWithItems(btnCancel, NULL);
    }
    else
    {
        CCMenuItemSprite* btnOk = CCMenuItemDynamic::dynamicItemWithTTFLabel(aOtherBtnTitle, fontName.c_str(), messageFontSize, btnSize, btnBG_name.c_str(), NULL, this,
                                                                                 menu_selector(VVAlertView::onBtnOk), 
                                                                                 btn9patch_rect, 255);

        menu = CCMenu::menuWithItems(btnCancel, btnOk, NULL);
        menu->alignItemsHorizontallyWithPadding(betweenBtnPadding);
    }
     
    
    menu->setTouchPriority(VVTouchPriorityMenuOnPopupLayer);
    
    addChild(bg);
    if (titleLabel) 
        addChild(titleLabel);            

    addChild(msgLabel);    
    addChild(menu);
    
    
    if (titleLabel)     
        totalHeight += titleLabel->getContentSize().height;    
    
    totalHeight += msgLabel->getContentSize().height;    
    totalHeight += btnCancel->getContentSize().height;
    totalHeight += centerPadding;
    
    totalHeight += messagePadding*2;
    totalHeight += borderPadding*2;
    
    float halfHeight = totalHeight/2;
    
    if (titleLabel) 
    {
        titleLabel  ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height/2)); // -15 : top padding
        msgLabel    ->setPosition(ccp(0, halfHeight - borderPadding - titleLabel->getContentSize().height - messagePadding - msgLabel->getContentSize().height/2 ));
    }
    else
    {
        msgLabel    ->setPosition(ccp(0, halfHeight - borderPadding - msgLabel->getContentSize().height/2 ));
    }
    menu        ->setPosition(ccp(0, -halfHeight + borderPadding + btnCancel->getContentSize().height/2));
    
    bg->setContentSize(CCSizeMake(maxWidth, totalHeight));
    
    
    // will be used for placing text field in the middle
    centerOfMargin = (msgLabel->getPosition().y + menu->getPosition().y)/2;
    
    return true;
}