Esempio n. 1
0
//private
void RPGMapSceneLayer::startPlay(float delay)
{
    CCTMXTiledMap *bgMap = (CCTMXTiledMap*)this->getChildByTag(kRPGMapSceneLayerTagBgMap);
    
    //数据库部分,读取npc数据
    CppSQLite3Query query = this->m_db.execQuery(CCString::createWithFormat(NPC_QUERY, this->m_mapData.mapId)->getCString());
    while(!query.eof())
    {
        float x = (stringToNumber<float>(query.getStringField("tmx_x")) + 0.5) * GAME_TMX_ROLE_WIDTH;
        float y = (stringToNumber<float>(query.getStringField("tmx_y")) + 0.5) * GAME_TMX_ROLE_HEIGHT;
        bool autoMove = query.getIntField("auto_move") == 1 ? true : false;
        
        RPGMapNPCRoleSprite *npc = RPGMapNPCRoleSprite::create(query.getIntField("id"), CCString::create(query.getStringField("map_texture")), CCString::create("head_texture"), CCString::create(query.getStringField("name_cns")), CCString::create(query.getStringField("content_cns")), 1, autoMove);
        npc->setTag(kRPGMapSceneLayerTagNPC + query.getIntField("id"));
        npc->setPosition(ccp(x, y));
        bgMap->addChild(npc);
        
        query.nextRow();
    }
    query.finalize();
    
    //player
    int defaultSpriteFrameIndex = 1; //默认为向下
    if(this->m_mapData.playerDirection.compare("up") == 0)
    {
        defaultSpriteFrameIndex = 10;
    }
    else if(this->m_mapData.playerDirection.compare("left") == 0)
    {
        defaultSpriteFrameIndex = 4;
    }
    else if(this->m_mapData.playerDirection.compare("right") == 0)
    {
        defaultSpriteFrameIndex = 7;
    }
    RPGMapRoleSprite *player = RPGMapRoleSprite::create(CCString::create("actor4_0.png"), CCString::create("Player"), true, defaultSpriteFrameIndex);
    player->setPosition(ccp(this->m_mapData.playerToX * GAME_TMX_ROLE_WIDTH, this->m_mapData.playerToY * GAME_TMX_ROLE_HEIGHT));
    player->setTag(kRPGMapSceneLayerTagPlayer);
    player->m_type = kRPGMapRoleSpriteTypePlayer;
    bgMap->addChild(player);
    
    CCSprite *spJoystick = CCSprite::createWithSpriteFrameName("Ball.png");
    CCSprite *joystickBg = CCSprite::createWithSpriteFrameName("Dock.png");
    OzgJoystickLayer *joystick = OzgJoystickLayer::layerActivityJoystick(50, spJoystick, joystickBg, false);
    joystick->setTag(kRPGMapSceneLayerTagJoystick);
    joystick->m_target = this;
    joystick->m_endedSelector = callfunc_selector(RPGMapSceneLayer::joystickEndedFunc);
    this->addChild(joystick);
    
    //menu
    CCMenu *mainMenu = CCMenu::create();
    mainMenu->setTag(kRPGMapSceneLayerTagMainMenu);
    mainMenu->setAnchorPoint(ccp(0.5, 0.5));
    mainMenu->setPosition(CCPointZero);
    mainMenu->setContentSize(bgMap->getContentSize());
    bgMap->addChild(mainMenu);

    CCMenuItemSprite *menuCommand = CCMenuItemSprite::create(CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), CCSprite::createWithSpriteFrameName("commons_btn_back_04.png"), this, menu_selector(RPGMapSceneLayer::onMenu));
    menuCommand->setPosition(ccp(mainMenu->getContentSize().width - 35, mainMenu->getContentSize().height - 35));
    menuCommand->setTag(kRPGMapSceneLayerTagMainMenuCommand);
    menuCommand->setRotation(180);
    menuCommand->setScale(0.75);
    mainMenu->addChild(menuCommand);

//    CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo();
    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 1, true);
    this->scheduleUpdate();
    
}
Esempio n. 2
0
bool LevelScenePopUp::init()
{
    /*if ( !CCLayer::init() )
    {
        return false;
    }*/
    Level* current_level = _parent->getLevel();
    //Get the size of the screen we can see
    CCSize visibleSize = ADScreen::getVisibleSize();
    //Get the screen start of cordinates
    CCPoint origin = ADScreen::getOrigin();
    float scaled = ADScreen::getScaleFactor();

    //Create the sheet
    //_sheet_menu = CCNode::create();
    //this->addChild(_sheet_menu);
    _sheet_menu = this;
    SpritesLoader spl = GraphicsManager::getLoaderFor(_sheet_menu,
                                                      "level/level_end_menu.plist",
                                                      "level/level_end_menu.png");
    spl->inject(true);
    CCSprite* sheet = spl->loadSprite("sheet-horizontal.png");
    //const unsigned int ELEMENTS_LAYER=100;
    //sheet->setVisible(false);

    //Create the zone for menu
    float banner_padding = 15/scaled;
    float zone_margin = 0;

    CCSize menu_zone_size(sheet->getContentSize());
    float free_space = (visibleSize.height - menu_zone_size.height*1.1)/2;
    float max_space = free_space * 1.8;
    float move_up = 0;
    CCSize banner_size(visibleSize.width*0.9, max_space - banner_padding);

//    _pause_banner = ads::AdsManager::getInstance().getBanner(banner_size);
//    if(_pause_banner)
//    {
//        _parent->getParentScene()->addChild(_pause_banner);
//        _pause_banner->setAnchorPoint(ccp(0.5,0));
//        _pause_banner->setPosition(origin.x + visibleSize.width/2,
//                                   origin.y + banner_padding);
//        //_pause_banner->showAds();

//        float banner_height = _pause_banner->getContentSize().height + banner_padding;
//        if(banner_height > free_space)
//            move_up = banner_height - free_space;
//        zone_margin = move_up;
//    }


    _sheet_target_position = ccp(visibleSize.width/2+origin.x,
                                (visibleSize.height-zone_margin)/2+zone_margin+origin.y);
    _sheet_menu->setPosition(ccp(_sheet_target_position.x,
                                 _sheet_target_position.y-visibleSize.height));
    _sheet_menu->setContentSize(menu_zone_size);
    _sheet_menu->setAnchorPoint(ccp(0.5,0.5));
    _sheet_menu->runAction(CCMoveTo::create(0.2f, _sheet_target_position));

    //sheet->setRotation(-90);
    sheet->setAnchorPoint(ccp(0,0));
    //sheet->removeFromParent();

    //Place buttons
    CCMenu* menu = CCMenu::create();
    menu->setPosition(sheet->getPosition());
    menu->setAnchorPoint(ccp(0,0));
    menu->setContentSize(menu_zone_size);
    _sheet_menu->addChild(menu);

    //CCSprite* next_level_image = CCSprite::create("level/next_level.png");
    CCSprite* next_level_image = CCSprite::create("level/next_level_background.png");

    CCSize image_size = next_level_image->getContentSize();
    float design_scale = 1;

    ADMenuItem *first_button = 0;
    if(current_level->getLevelState() == Level::Crown)
    {
        //CCSprite* levels = CCSprite::create("level/levels.png");
        CCSprite* levels = CCSprite::create("level/levels_background.png");
        first_button = ADMenuItem::create(levels);
        CONNECT(first_button->signalOnClick,
                this, &LevelScenePopUp::onLevels);
    }
    else
    {
        //CCSprite* find_more_image = CCSprite::create("level/find_more.png");
        CCSprite* find_more_image = CCSprite::create("level/find_more_background.png");
        first_button = ADMenuItem::create(find_more_image);
        CONNECT(first_button->signalOnClick,
                this, &LevelScenePopUp::onFindMoreSolutions);
    }
    //TODO: change if it is necessary x coordinate to 102
    first_button->setPosition(ccp(100*design_scale/scaled+image_size.width/2,
                                  53*design_scale/scaled+image_size.height/2));

    ADMenuItem *next_level = ADMenuItem::create(next_level_image);
    CONNECT(next_level->signalOnClick,
            this, &LevelScenePopUp::onNextLevel);

    next_level->setPosition(ccp(600*design_scale/scaled,
                                53*design_scale/scaled+image_size.height/2));
    menu->addChild(next_level);
    menu->addChild(first_button);

    //Add label
    //    CCSprite* title = 0;
    //    if(current_level->getLevelState() == Level::OneStamp)
    //        title = spl->loadSprite("good.png");
    //    else if(current_level->getLevelState() == Level::TwoStamps)
    //        title = spl->loadSprite("perfect.png");
    //    else
    //        title = spl->loadSprite("excellent.png");

    //    title->setPosition(ccp(409*design_scale/scaled, 445*design_scale/scaled));
    const Solutions& all_found_solutions = _parent->getLevel()->getFoundSolutions();
    Solutions last_solution(1, _solution);
    DisplaySolution* solution = DisplaySolution::create(CCSize(371/scaled, 90/scaled),
                                                        _parent->getLevel(),
                                                        last_solution,
                                                        last_solution);
    unsigned int stamp_ID = 0;
    for(unsigned int i=0; i<all_found_solutions.size(); ++i)
    {
        if(all_found_solutions[i] == _solution)
        {
            stamp_ID = i;
            break;
        }
    }

    this->addChild(solution);
    solution->setAnchorPoint(ccp(0.5f,0.5f));
    solution->setPosition(ccp(409*design_scale/scaled, 445*design_scale/scaled));


    std::vector<CCSprite*> stamps;


    const Stamps level_stamps = current_level->getLevelStamps();
    unsigned int stamps_number = current_level->getSolutions().size();
    CCNode* stamps_zone = 0;
    float max_stamps_zone_width = 605*design_scale/scaled;
    float max_stamps_zone_height = 160*design_scale/scaled;

    if(stamps_number)
    {
        stamps.reserve(stamps_number);
        stamps_zone = CCNode::create();
        SpritesLoader stamps_spl = GraphicsManager::getLoaderFor(stamps_zone,
                                                                 "level/stamps.plist",
                                                                 "level/stamps.png");

        stamps_zone->setContentSize(CCSize(max_stamps_zone_width,
                                           max_stamps_zone_height));
        stamps_zone->setPosition(ccp(414*design_scale/scaled, 289*design_scale/scaled));
        stamps_zone->setAnchorPoint(ccp(0.5f, 0.5f));
        _sheet_menu->addChild(stamps_zone);


        unsigned int level_max_solutions = stamps_number;
        CCSize stamp_size;
        //stamp_size.width *= 0.7f;
        float stamps_scale = 0;

        CCSize new_stamp_size;

        float new_width = new_stamp_size.width * level_max_solutions;
        float new_height = new_stamp_size.height;

        float h_disp = 0;
        float v_dist = 0;

        _crown = 0;

        for(unsigned int i=0; i<stamps_number; ++i)
        {
            CCSprite* sp = 0;
            if(i < level_stamps.size())
            {
                const Stamp& stamp = level_stamps[i];
                sp = stamps_spl->loadSprite(stamp.getFileName().c_str());
                stamps.push_back(sp);
                sp->setRotation(stamp.getRotation());

                if(i == 0)
                {
                    stamp_size = stamps[0]->getContentSize();
                    //stamp_size.width *= 0.7f;
                    stamps_scale = MIN(max_stamps_zone_height / stamp_size.height,
                                             max_stamps_zone_width / stamp_size.width / level_max_solutions);

                    new_stamp_size = CCSize(stamp_size.width * stamps_scale,
                                          stamp_size.height * stamps_scale);

                    new_width = new_stamp_size.width * level_max_solutions;
                    new_height = new_stamp_size.height;

                    h_disp = (max_stamps_zone_width - new_width + new_stamp_size.width) / 2;
                    v_dist = (max_stamps_zone_height - new_height + new_stamp_size.height) / 2;
                }



                sp->setPosition(ccp(h_disp + i * new_stamp_size.width,
                                    v_dist));

                if(stamp.newStamp())
                {
                    if(current_level->getLevelState() == Level::Crown)
                    {
                        //Add crown to last stamp
                        CCSprite* spc = stamps_spl->loadSprite("crown_st.png");
                        spc->setScale(stamps_scale);
                        spc->setPosition(sp->getPosition());

                        spc->setAnchorPoint(ccp(0.5, 0));
                        if(i == stamp_ID)
                        {
                            spc->runAction(getNewStampAction(stamps_scale));
                        }
                        _crown = spc;
                    }
                }
                if(i == stamp_ID)
                {
                    sp->runAction(getNewStampAction(stamps_scale));
                }

            }
            else
            {
                sp = stamps_spl->loadSprite("empty_stamp.png");
                sp->setPosition(ccp(h_disp + i * new_stamp_size.width,
                                    v_dist));

                stamps.push_back(sp);
            }

            sp->setScale(stamps_scale);

        }

    }
    //_parent->setVisible(false);
    _parent->sleep();

    //Tutorial::getInstance()->onSolutionFound(this);

    return true;
}
Esempio n. 3
0
// 初始化底部Bar
void ActivityView::initBottomBar(CCSize winSize) 
{
	/////////////////////////////////////////// 底部条 ////////////////////////////////////////
	
	this->footerBarNode = CCNode::create() ;
	this->footerBarNode->setAnchorPoint(ccp(0, 0)) ;
	this->footerBarNode->setPosition(ccp(0, -5)) ;	
	this->addChild(this->footerBarNode) ;

	/////////////////////////////////////// 定义背景 /////////////////////////////////////////
	// 背景
	CCSprite* bottomBarBg = CCSprite::create("bg_bottom_bar.png") ;
	bottomBarBg->setAnchorPoint(ccp(0.5, 0)) ;
	bottomBarBg->setPosition(ccp(winSize.width/2, 0)) ;
	this->footerBarNode->addChild(bottomBarBg, 1) ;

	// 定义底部条高度
	const float footerBarNode_height = bottomBarBg->getContentSize().height ;
	// 设置底部条的高和宽
	this->footerBarNode->setContentSize(CCSizeMake(winSize.width, footerBarNode_height)) ;

	// 背景遮罩层
	CCSprite* bottomBg = CCSprite::create("bg_bottom.png") ;
	bottomBg->setAnchorPoint(ccp(0, 1)) ;
	bottomBg->setPosition(ccp(0, footerBarNode_height)) ;
	this->footerBarNode->addChild(bottomBg, 0) ;


	CCSpriteBatchNode* bottomIcon = CCSpriteBatchNode::create("bg_bottom_icon.png") ;

	// 左边的icon
	CCSprite* leftIcon = CCSprite::createWithTexture(bottomIcon->getTexture()) ;
	leftIcon->setAnchorPoint(ccp(0, 0)) ;
	leftIcon->setPosition(ccp(0, 0)) ;
	this->footerBarNode->addChild(leftIcon, 1) ;

	// 右边的icon
	CCSprite* rightIcon = CCSprite::createWithTexture(bottomIcon->getTexture()) ;
	rightIcon->setAnchorPoint(ccp(1, 0)) ;
	rightIcon->setPosition(ccp(winSize.width, 0)) ;
	rightIcon->setFlipX(true) ; // 水平翻转
	this->footerBarNode->addChild(rightIcon, 1) ;

	const float menuItem_margin = 50.0f ;		// 距离中间位置的距离
	const float menuItem_padding = 100.0f ;		// menuItem之间的间隔

	// 底部菜单
	CCMenu* footerMenu = CCMenu::create() ;
	footerMenu->setContentSize(CCSizeMake(winSize.width, footerBarNode_height) ) ;
	footerMenu->setAnchorPoint(ccp(0, 0)) ;
	footerMenu->setPosition(ccp(0, 0)) ;
	this->footerBarNode->addChild(footerMenu, 2) ;

	// 活动菜单
	CCMenuItemImage* activityMenuItem = CCMenuItemImage::create("menu_activity_n.png", "menu_activity_s.png", 
																this, menu_selector(ActivityView::menuActivityClickCallback)) ;
	activityMenuItem->setAnchorPoint(ccp(1, 1)) ;
	activityMenuItem->setPosition(ccp(winSize.width/2-menuItem_margin, footerBarNode_height-3)) ;
	footerMenu->addChild(activityMenuItem) ;

	// 获取menuItem宽度
	const float menuItem_width = activityMenuItem->getContentSize().width ;


	// 信息菜单	
	CCMenuItemImage* infoMenuItem = CCMenuItemImage::create("menu_message_n.png", "menu_message_s.png", 
															this, menu_selector(ActivityView::menuInfoClickCallback)) ;
	infoMenuItem->setAnchorPoint(ccp(1, 1)) ;
	infoMenuItem->setPosition(ccp(winSize.width/2-menuItem_margin-menuItem_width-menuItem_padding, footerBarNode_height-3)) ;
	footerMenu->addChild(infoMenuItem) ;

	// 商城菜单
	CCMenuItemImage* shopMenuItem = CCMenuItemImage::create("menu_shop_n.png", "menu_shop_s.png", 
															this, menu_selector(ActivityView::menuShopClickCallback)) ;
	shopMenuItem->setAnchorPoint(ccp(0, 1)) ;
	shopMenuItem->setPosition(ccp(winSize.width/2+menuItem_margin, footerBarNode_height-3)) ;
	footerMenu->addChild(shopMenuItem) ;

	// 菜单菜单
	CCMenuItemImage* moreMenuItem = CCMenuItemImage::create("menu_more_n.png", "menu_more_s.png" , 
															this, menu_selector(ActivityView::menuMoreClickCallback)) ;
	moreMenuItem->setAnchorPoint(ccp(0, 1)) ;
	moreMenuItem->setPosition(ccp(winSize.width/2+menuItem_margin+menuItem_width+menuItem_padding, footerBarNode_height-3)) ;
	footerMenu->addChild(moreMenuItem) ;
	
	// 更多菜单背景
	CCSprite* moreMenuBg = CCSprite::create("bg_more_menu.png") ;
	moreMenuBg->setAnchorPoint(ccp(0,0)) ;
	moreMenuBg->setPosition(ccp(0, 0)) ;

	const float moreMenu_width = moreMenuBg->getContentSize().width ;
	const float moreMenu_height = moreMenuBg->getContentSize().height ;

	// 更多菜单节点
	moreMenuNode = CCNode::create() ;
	moreMenuNode->setContentSize(moreMenuBg->getContentSize()) ;		// 设置moreMenuNode的尺寸
	moreMenuNode->setAnchorPoint(ccp(1, 0)) ;
	moreMenuNode->setPosition(ccp(winSize.width-80, 80)) ;
	moreMenuNode->retain() ;
	// this->addChild(moreMenuNode, 5, MORE_MENU_NODE_TAG) ;

	moreMenuNode->addChild(moreMenuBg, 0) ;	// 将背景加入到更多菜单中		

	// 更多菜单
	CCMenu* moreMenu = CCMenu::create() ;
	moreMenu->setAnchorPoint(ccp(0, 0)) ;
	moreMenu->setPosition(ccp(0, 0)) ;
	moreMenuNode->addChild(moreMenu, 1, MORE_MENU_TAG) ;


	// 排行榜菜单项
	CCMenuItemImage* rankingMenuItem = CCMenuItemImage::create("menu_ranking_n.png", "menu_ranking_s.png" , 
															this, menu_selector(GameMenuView::menuRankingClickCallback)) ;
	rankingMenuItem->setAnchorPoint(ccp(0, 1)) ;
	rankingMenuItem->setPosition(ccp(10, moreMenu_height-10)) ;
	moreMenu->addChild(rankingMenuItem) ;

	// 任务菜单
	CCMenuItemImage* taskMenuItem = CCMenuItemImage::create("menu_task_n.png", "menu_task_s.png" , 
															this, menu_selector(GameMenuView::menuTaskClickCallback)) ;
	taskMenuItem->setAnchorPoint(ccp(1, 1)) ;
	taskMenuItem->setPosition(ccp(moreMenu_width-10, moreMenu_height-10)) ;
	moreMenu->addChild(taskMenuItem) ;

	// 好友菜单
	CCMenuItemImage* friendMenuItem = CCMenuItemImage::create("menu_friend_n.png", "menu_friend_s.png", 
															this, menu_selector(GameMenuView::menuFriendClickCallback)) ;	
	friendMenuItem->setAnchorPoint(ccp(0, 0)) ;
	friendMenuItem->setPosition(ccp(10, 5)) ;
	moreMenu->addChild(friendMenuItem) ;

	// 客服菜单
	CCMenuItemImage* customserviceMenuItem = CCMenuItemImage::create("menu_cs_n.png", "menu_cs_s.png", 
																this, menu_selector(GameMenuView::menuSettingClickCallback)) ;
	customserviceMenuItem->setAnchorPoint(ccp(1, 0)) ;
	customserviceMenuItem->setPosition(ccp(moreMenu_width-10, 5)) ;
	moreMenu->addChild(customserviceMenuItem) ;
	
}
Esempio n. 4
0
void BuyFullVersion::onCreate(CCNode *parent)
{
    float scaled = ADScreen::getScaleFactor();
    CCSize size = parent->getContentSize();
    float x_middle = size.width / 2;

    std::string title;
    std::string description_text;
    std::string buy_now_text;
    std::string buy_later_text;

    if(GameInfo::PURCHASE_TYPE == PurchaseType::AdsPurchaseFullVersion)
    {
        title = _("buy_full_version.title");
        description_text = _("buy_full_version.description");
        buy_now_text = _("pop_up.buy_full_version.button.buy_now");
        buy_later_text = _("pop_up.buy_full_version.button.later");
    }
    else
    {
        title = _("buy_no_ads.title");
        description_text = _("buy_no_ads.description");
        buy_now_text = _("pop_up.buy_no_ads.button.buy_now");
        buy_later_text = _("pop_up.buy_no_ads.button.later");
    }

    //create window title
    CCLabelTTF* window_title = CCLabelTTF::create(title.c_str(),
                                                  ADLanguage::getFontName(),
                                                  45);
    window_title->setColor(GameInfo::COLOR_LIGHT_BLUE);
    window_title->setPosition(ccp(x_middle, size.height * 0.85f));
    parent->addChild(window_title);

    /////////////////////////////////////////////////////////

    //add full version description
    CCLabelTTF* description = CCLabelTTF::create(description_text.c_str(),
                                                  ADLanguage::getFontName(),
                                                  32,
                                                 CCSize(parent->getContentSize().width* 0.6f, 0),
                                                 kCCTextAlignmentLeft);

    description->setColor(GameInfo::COLOR_LIGHT_GRAY);
    description->setPosition(ccp(x_middle+size.width*0.17, size.height * 0.55f));
    parent->addChild(description);

    ////////////////////////////////////////////////////

    //create menu for buttons
    CCMenu* menu = CCMenu::create();
    menu->setPosition(ccp(0,0));
    menu->setAnchorPoint(ccp(0,0));
    menu->setContentSize(size);
    parent->addChild(menu);

    //create zebra image
    CCSprite* zebra = CCSprite::create("select_collection/zebra.png");
    parent->addChild(zebra);
    zebra->setScale(0.9f);
    zebra->setPosition(ccp(200/scaled, 280/scaled));


    CCSprite* button1 = CCSprite::create("select_collection/background1.png");

    //////////////////////////////////////////////////

    //buy now
    CCSprite* button2 = CCSprite::create("select_collection/background1.png");
    CCLabelTTF* buy_now_title = CCLabelTTF::create(buy_now_text.c_str(),
                                                   ADLanguage::getFontName(),
                                                   45);
    buy_now_title->setColor(GameInfo::COLOR_DARK_GREEN);

    float BUTTON_WIDTH_USED = 0.85f;

    //fix font size
    if(buy_now_title->getContentSize().width >= button2->getContentSize().width*BUTTON_WIDTH_USED)
    {
        buy_now_title->setScale(button2->getContentSize().width*BUTTON_WIDTH_USED
                                / buy_now_title->getContentSize().width);
    }
    if(buy_now_title->getContentSize().height >= button2->getContentSize().height*BUTTON_WIDTH_USED)
    {
        float scale = button2->getContentSize().height*BUTTON_WIDTH_USED
                / buy_now_title->getContentSize().height;
        if(scale < buy_now_title->getScale())
        {
            buy_now_title->setScale(scale);
        }
    }

    button2->setColor(GameInfo::COLOR_DARK_GREEN);
    ADMenuItem *buy_now_item = ADMenuItem::create(button2);
    buy_now_item->addChild(buy_now_title);
    CONNECT(buy_now_item->signalOnClick,
            this, &BuyFullVersion::onBuyFullVersionClick);


    buy_now_title->setPosition(buy_now_item->getContentSize()*0.5);
    buy_now_item->setPosition(ccp(parent->getContentSize().width*0.3,
                              parent->getContentSize().height*0.2));


    ///////////////////////////////////////////////////////////////

    //buy later
    ADMenuItem *buy_later_item = ADMenuItem::create(button1);
    CCLabelTTF* buy_later_title = CCLabelTTF::create(buy_later_text.c_str(),
                                                   ADLanguage::getFontName(),
                                                   45);
    //fix font size
    if(buy_later_title->getContentSize().width >= button2->getContentSize().width*BUTTON_WIDTH_USED)
    {
        buy_later_title->setScale(button2->getContentSize().width*BUTTON_WIDTH_USED
                                        / buy_later_title->getContentSize().width);
    }


    buy_later_title->setColor(GameInfo::COLOR_LIGHT_GRAY);
    button1->setColor(GameInfo::COLOR_LIGHT_GRAY);
    CONNECT(buy_later_item->signalOnClick,
            this, &BuyFullVersion::onBuyLaterClick);

    buy_later_item->setPosition(ccp(parent->getContentSize().width*0.75,
                                    parent->getContentSize().height*0.2));
    buy_later_item->addChild(buy_later_title);
    buy_later_title->setPosition(buy_later_item->getContentSize()*0.5);

    ///////////////////////////////////////////////////////////////

    menu->addChild(buy_now_item);
    menu->addChild(buy_later_item);

}
Esempio n. 5
0
// 初始化顶部bar
void ActivityView::initTopBar(CCSize winSize) 
{
	////////////////////////////////////////////////////////////////////////////////////////////////////
	// topBarNode 背景
	CCSprite* topBarBg = CCSprite::create("bg_nav_top.png") ;
	topBarBg->setAnchorPoint(ccp(0.5, 0)) ;
	topBarBg->setPosition(ccp(winSize.width/2, 0)) ;

	const float topBar_height = topBarBg->getContentSize().height ; 

	

	// 顶部条信息 //////////////////////////////////////////////////////////////////////////////////////
	this->topBarNode = CCNode::create() ;
	this->topBarNode->setContentSize(CCSizeMake(winSize.width, topBar_height)) ;
	this->topBarNode->setAnchorPoint(ccp(0, 0)) ;
	this->topBarNode->setPosition(ccp(0, winSize.height - topBar_height)) ;
	this->addChild(this->topBarNode, 0, 1) ;

	// 将topBarNode背景加入到topBarNode
	this->topBarNode->addChild(topBarBg, 0 ) ;


	///////////////////////////// 左侧布局 //////////////////////////
	CCNode* leftNode = CCNode::create() ;
	leftNode->setContentSize(CCSizeMake(300, topBar_height)) ;
	leftNode->setAnchorPoint(ccp(0, 0.5)) ;
	leftNode->setPosition(ccp(30, topBar_height/2)) ;
	this->topBarNode->addChild(leftNode, 1) ;

	// 头像
	CCSprite* headPortraitSprite = CCSprite::create("user/head_default_f2.png") ;
	headPortraitSprite->setAnchorPoint(ccp(0, 0)) ;
	headPortraitSprite->setPosition(ccp(0, 10)) ;
	headPortraitSprite->setScale(0.8) ;
	leftNode->addChild(headPortraitSprite) ;

	// 昵称
	CCLabelTTF* nikeNameLabel = CCLabelTTF::create("昵称:我是主角", "font01.ttf", 22.0f) ;
	// nikeNameLabel->setColor(ccc3(191, 173, 111)) ;
	nikeNameLabel->setAnchorPoint(ccp(0, 0)) ;
	nikeNameLabel->setPosition(ccp(70, topBar_height/2+2)) ;
	nikeNameLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; 			// 水平对齐方式
	nikeNameLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; 	// 垂直对齐方式
	leftNode->addChild(nikeNameLabel) ;

	// 金币
	CCLabelTTF* goldCoinLabel = CCLabelTTF::create("金币:10000", "font01.ttf", 22.0f) ;
	goldCoinLabel->setAnchorPoint(ccp(0, 1)) ;
	goldCoinLabel->setPosition(ccp(70, topBar_height/2)) ;
	goldCoinLabel->setHorizontalAlignment(kCCTextAlignmentLeft) ; 			// 水平对齐方式
	goldCoinLabel->setVerticalAlignment(kCCVerticalTextAlignmentCenter) ; 	// 垂直对齐方式
	leftNode->addChild(goldCoinLabel) ;


	// 信息
	CCSprite* titleMsg = CCSprite::create("icon_title_activity.png") ;
	titleMsg->setAnchorPoint(ccp(0.5, 0.5)) ;
	titleMsg->setPosition(ccp(winSize.width/2, topBar_height/2)) ;
	this->topBarNode->addChild(titleMsg, 1) ;

	// 分割线
	CCSprite* spliteLineLeft = CCSprite::create("icon_top_nav_splite.png") ;
	spliteLineLeft->setAnchorPoint(ccp(0, 1)) ;
	spliteLineLeft->setPosition(ccp(winSize.width/3+10, topBar_height)) ;
	this->topBarNode->addChild(spliteLineLeft, 1) ;


	// 分割线
	CCSprite* spliteLineRight = CCSprite::create("icon_top_nav_splite.png") ;
	spliteLineRight->setAnchorPoint(ccp(0, 1)) ;
	spliteLineRight->setPosition(ccp(winSize.width*2/3-20, topBar_height)) ;
	this->topBarNode->addChild(spliteLineRight, 1) ;


	/////////////////////////////////////////////////////////////////////////////////////////////////
	/****************************** 菜单选项 ********************************************************/
	// 右侧menu
	const float right_width = 200 ;
	const float item_width = 55 ;

	
	// 礼物
	CCMenuItemImage* menuGifts = CCMenuItemImage::create("menu_gifts_n.png", "menu_gifts_s.png", this,
															menu_selector(ActivityView::menuGiftsClickCallback)) ;
	// menuBack->setContentSize(CCSizeMake(67, 68)) ;
	menuGifts->setAnchorPoint(ccp(0, 0.5)) ;
	menuGifts->setPosition(ccp(0, topBar_height/2)) ;
	//menuGifts->setPosition(ccp(right_width-2*item_width, topBar_height/2)) ;
	//rightMenu->addChild(menuGifts) ;

	// 返回大厅
	CCMenuItemImage* menuBack = CCMenuItemImage::create("menu_back_n.png", "menu_back_s.png", this,
															menu_selector(MessageView::menuBackClickCallback)) ;
	menuBack->setAnchorPoint(ccp(0, 0.5)) ;
	menuBack->setPosition(ccp(2*(item_width+10), topBar_height/2)) ;
	//menuBack->setPosition(ccp(right_width, topBar_height/2)) ;
	//rightMenu->addChild(menuBack) ;

	// 设置
	CCMenuItemImage* menuSetting = CCMenuItemImage::create("menu_setting_n.png", "menu_setting_s.png", this,
															menu_selector(MessageView::menuSettingClickCallback)) ;
	// menuBack->setContentSize(CCSizeMake(67, 68)) ;
	
	menuSetting->setAnchorPoint(ccp(0, 0.5)) ;
	menuSetting->setPosition(ccp(item_width+10, topBar_height/2)) ;
	//menuSetting->setPosition(ccp(right_width-item_width, topBar_height/2)) ;

	//rightMenu->addChild(menuSetting) ;
	CCMenu* rightMenu = CCMenu::create(menuGifts, menuBack, menuSetting, NULL) ;
	rightMenu->setContentSize(CCSizeMake(winSize.width/4, topBar_height)) ;
	rightMenu->setAnchorPoint(ccp(0, 0)) ;
	rightMenu->setPosition(ccp(winSize.width*3/4-10, 0)) ;	
	this->topBarNode->addChild(rightMenu, 1) ;
}