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


C++ CCControlButton::addTargetWithActionForControlEvents方法代码示例

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


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

示例1: init

bool GeneralDialogTest::init()
{
    if (CCLayer::init())
    {
        //正常状态按钮
        CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
        //按下效果
        CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
        //按钮的大小根据标题变化
        CCLabelTTF *titleButton = CCLabelTTF::create("Touch Me!", "Marker Felt", 30);
        //按钮颜色
        titleButton->setColor(ccc3(159, 168, 176));
        
        CCControlButton* controlButton = CCControlButton::create(titleButton, backgroundButton);
        controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
        controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
        
//        controlButton->setAnchorPoint(ccp(0.5f, 1));
        controlButton->setPosition(ccp(640/2, 960/5));
        addChild(controlButton);
        /* 当鼠标处于按下并曾经点中按钮的状态下,鼠标松开且在按钮范围内,则触发一次 */
        controlButton->addTargetWithActionForControlEvents(this, cccontrol_selector(GeneralDialogTest::touchUpInside), CCControlEventTouchUpInside);
        return true;
    }
    return false;
}
开发者ID:aquariusgx,项目名称:Winterfell_Test,代码行数:26,代码来源:GeneralDialogTest.cpp

示例2: tableCellAtIndex

CCTableViewCell* RPGMapItemsMenuLayer::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
    CCTableViewCell *cell = tableView->dequeueCell();
    if (!cell)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
        cell->removeAllChildrenWithCleanup(true);
    
    float x = 100;
    for (int i = 0; i < 4; i++)
    {
        int index = idx * 4 + i;
        
        if(index >= this->m_itemsList->count())
            break;
        
        RPGExistingItems *itemsData = (RPGExistingItems*)this->m_itemsList->objectAtIndex(index);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(x, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGMapItemsMenuLayer::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
        x += 200;
    }
    
    return cell;
}
开发者ID:ChinaiOS,项目名称:OzgGameRPG,代码行数:32,代码来源:RPGMapItemsMenuLayer.cpp

示例3: init

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->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
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
    pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

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

    // add a label shows "Hello World"
    // create and initialize a label
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

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

    CCRect rect1(133, 333, 42, 46);
    CCScale9Sprite* btnNormal = CCScale9Sprite::create("char_bluelight.png",rect1);  
    CCScale9Sprite* btnDown = CCScale9Sprite::create("char_bluelight.png",rect1);  
    CCControlButton* controlBtn = CCControlButton::create(btnNormal);  
    controlBtn->setBackgroundSpriteForState(btnDown, CCControlStateSelected);  
    controlBtn->setPosition(ccp(visibleSize.width/2, visibleSize.height/2));  
    controlBtn->setPreferredSize(CCSize(60, 50));  
    controlBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown);
    this->addChild(controlBtn);  
    
    return true;
}
开发者ID:,项目名称:,代码行数:59,代码来源:

示例4: init

bool ParticleTest::init(){
    CCControlButton *btn = CCControlButton::create("particle ", "Arial", 24);
    btn->setPosition(ccp(320, 1000));
    this->addChild(btn);
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(ParticleTest::btnClick), CCControlEventTouchDown);
    
    
    return true;
}
开发者ID:1179432578,项目名称:cocos2dx-2.2.2-test,代码行数:9,代码来源:ParticleTest.cpp

示例5: createRootButton

    CCControlButton* PluginLayerContent::createRootButton( const char* btnTitle, int btnTag )
    {
        CCControlButton* ctrlBtn = nl::ControlUtils::createButton(btnTitle);
        ctrlBtn->setTag(btnTag);
        ctrlBtn->addTargetWithActionForControlEvents(
            this, 
            cccontrol_selector(PluginLayerContent::onUIAction), 
            CCControlEventTouchUpInside);
        return ctrlBtn;
    }
开发者ID:Mobiletainment,项目名称:Multiplayer-Network-Conecpts,代码行数:10,代码来源:nlPluginLayerContent.cpp

示例6: init

bool HelloScene::init()
{
    if (!CCLayer::init())
    {
        return false;
    }

    CCSprite *bg = CCSprite::create("background.png");
    bg->setPosition(VisibleRect::center());
    //CCSize &winSize = CCDirector::sharedDirector()->getWinSize();
    //float scalex = winSize.width / 480;
    //float scaley = winSize.height / 800;
    //bg->setScaleX(scalex);
    //bg->setScaleY(scaley);
    addChild(bg);

    const CCPoint &center = VisibleRect::center();

    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
        "CloseNormal.png",
        "CloseSelected.png",
        this,
        menu_selector(HelloScene::menuCloseCallback));
    pCloseItem->setPosition(ccp(VisibleRect::rightBottom().x - pCloseItem->getContentSize().width/2 ,
        pCloseItem->getContentSize().height/2));
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    CCLabelTTF *title = CCLabelTTF::create("Lovexin Plane Chess", "Arial", 40);
    title->setPosition(ccp(center.x, center.y + 250));
    CCLabelTTF *author = CCLabelTTF::create("made by Waltz Duyf", "Arial", 20);
    author->setPosition(ccp(center.x + 100, center.y + 200));
    addChild(title);
    addChild(author);

    addSetupSwitch(ccp(center.x - 120, center.y + 50 ), "RED", ccc3(255, 0, 0), FORCE_COLOR_RED);//, cccontrol_selector(HelloScene::valueChangedJoinInR), cccontrol_selector(HelloScene::valueChangedAIR));
    addSetupSwitch(ccp(center.x - 120, center.y - 10 ), "YEL", ccc3(234, 165, 0), FORCE_COLOR_YELLOW);//, cccontrol_selector(HelloScene::valueChangedJoinInY), cccontrol_selector(HelloScene::valueChangedAIY));
    addSetupSwitch(ccp(center.x - 120, center.y - 70 ), "GRE", ccc3(0, 255, 0), FORCE_COLOR_GREEN);//, cccontrol_selector(HelloScene::valueChangedJoinInG), cccontrol_selector(HelloScene::valueChangedAIG));
    addSetupSwitch(ccp(center.x - 120, center.y - 130), "BLU", ccc3(0, 144, 255), FORCE_COLOR_BLUE);//, cccontrol_selector(HelloScene::valueChangedJoinInB), cccontrol_selector(HelloScene::valueChangedAIB));

    CCScale9Sprite *backgroundButton = CCScale9Sprite::create("button.png");
    CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("buttonHighlighted.png");
    CCLabelTTF *titleButton = CCLabelTTF::create("Play Now", "Arial", 30);
    titleButton->setColor(ccc3(159, 168, 176));
    CCControlButton *button = CCControlButton::create(titleButton, backgroundButton);
    button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted);
    button->setTitleColorForState(ccWHITE, CCControlStateHighlighted);
    button->setMargins(70, 20);
    button->setPosition(ccp(center.x, center.y - 250));
    addChild(button);
    button->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloScene::playBtnCallback), CCControlEventTouchUpInside);

    return true;
}
开发者ID:waltzduyf,项目名称:cocos2d_game,代码行数:55,代码来源:HelloScene.cpp

示例7: jumpBtn

void guankaScene::jumpBtn() {
    CCSize screenSize = CCDirector::sharedDirector()->getVisibleSize();
    
    CCLabelTTF* jumptext = CCLabelTTF::create("Jump!!", "Arial", 40);
    CCScale9Sprite* noDownbtn = CCScale9Sprite::create("button.png");
    CCScale9Sprite* downbtn = CCScale9Sprite::create("buttonDown.png");
    CCControlButton* Btnjump = CCControlButton::create(jumptext, noDownbtn);
    Btnjump->setPosition(ccp(screenSize.width-80, 50));
    Btnjump->setBackgroundSpriteForState(downbtn, extension::CCControlStateHighlighted);
    Btnjump->addTargetWithActionForControlEvents(this, cccontrol_selector(guankaScene::jumpEvent),CCControlEventTouchDown);
    this->addChild(Btnjump,1);
}
开发者ID:bailitusu,项目名称:paoku,代码行数:12,代码来源:guankaScene.cpp

示例8: init

bool HelloWorld::init()
{
    if ( !CCLayer::init() )
    {
        return false;
    }

//获取可视区域尺寸大小
    CCSize mysize = CCDirector::sharedDirector()->getVisibleSize();
//获取可视区域的原点位置
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
//屏幕正中心位置
    CCPoint midPos = ccp(mysize.width/2, mysize.height/2);


//显示按钮状态的标签displayLabel
    displayLabel = CCLabelTTF::create("No Event", "Marker Felt", 32);
    displayLabel->setPosition( midPos + ccp(0, 100) );
    this->addChild(displayLabel);


//按钮中的背景精灵CCScale9Sprite
    CCScale9Sprite* bgNormal = CCScale9Sprite::create("btnNormal.png"); //正常背景
    CCScale9Sprite* bgHighlighted = CCScale9Sprite::create("btnHighlighted.png"); //高亮背景

//按钮中的标签CCLabelTTF
    CCLabelTTF* titleNormal = CCLabelTTF::create("Button is Normal !", "Marker Felt", 30);
    CCLabelTTF* titleHighlighted = CCLabelTTF::create("Button is Highlighted !", "Marker Felt", 30);


//创建按钮CCControlButton
    CCControlButton* btn = CCControlButton::create(titleNormal, bgNormal);
    btn->setPosition( midPos );
    this->addChild(btn);

//设置按钮高亮时的状态
    btn->setTitleLabelForState(titleHighlighted, CCControlStateHighlighted); //高亮标签
    btn->setTitleColorForState(ccRED, CCControlStateHighlighted); //红色
    btn->setBackgroundSpriteForState(bgHighlighted, CCControlStateHighlighted); //高亮背景

    //写了这句话,反而大小被固定了。没有按照label的大小进行自动伸展了
    //btn->setPreferredSize( CCSizeMake(120,40) );

//绑定事件,用于显示按钮状态
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDownAction), CCControlEventTouchDown); //刚刚开始触摸按钮时
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragInsideAction), CCControlEventTouchDragInside);  //在内部拖动时(保持触摸状态下)
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragOutsideAction), CCControlEventTouchDragOutside); //在外部拖动时(保持触摸状态下)
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragEnterAction), CCControlEventTouchDragEnter);  //拖动刚进入内部时(保持触摸状态下)
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchDragExitAction), CCControlEventTouchDragExit); //拖动刚离开内部时(保持触摸状态下)
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpInsideAction), CCControlEventTouchUpInside); //在内部抬起手指(保持触摸状态下)
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchUpOutsideAction), CCControlEventTouchUpOutside); //在外部抬起手指(保持触摸状态下)
    btn->addTargetWithActionForControlEvents(this, cccontrol_selector(HelloWorld::touchCancelAction), CCControlEventTouchCancel); //取消触点

    return true;
}
开发者ID:wangzhenGitHup,项目名称:cocos2d-xGame,代码行数:55,代码来源:HelloWorldScene.cpp

示例9: tableCellAtIndex

CCTableViewCell* RPGBattleMenu::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
    CCTableViewCell *cell = tableView->dequeueCell();
    if (!cell)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
        cell->removeAllChildrenWithCleanup(true);
    
    if(dynamic_cast<RPGSkillBtnData*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
    {
        //点击了技能项
        RPGSkillBtnData *itemsData = (RPGSkillBtnData*)this->m_tableItems->objectAtIndex(idx);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_MP)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
    }
    else if(dynamic_cast<RPGExistingItems*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
    {
        //点击了道具项
        
        RPGExistingItems *itemsData = (RPGExistingItems*)this->m_tableItems->objectAtIndex(idx);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
    }
    
    return cell;
}
开发者ID:ChinaiOS,项目名称:OzgGameRPG,代码行数:39,代码来源:RPGBattleMenu.cpp

示例10: tableCellTouched

void CCLobbyView::tableCellTouched(cocos2d::extension::CCTableView* table, cocos2d::extension::CCTableViewCell* cell)
{
    if (this->getIsJoinRoomConfirming()) {
        return;
    }
    using namespace ExitGames::LoadBalancing;
    CCLog("CCLobbyView::tableCellTouched() -- cell touched at index: %i", cell->getIdx());
    
    CCRoomTableCell* roomCell = (CCRoomTableCell*) cell;
    ExitGames::LoadBalancing::Room* room = roomCell->getRoom();
    
    if( roomCell->getHasRoom() && room && room->getMaxPlayers() > room->getPlayerCount() )
    {
        CCLog("CCLobbyView::tableCellTouched() HasRoom");
        CCLog("room name %s", room->getName().UTF8Representation().cstr());
        this->setSelectedRoom(room);
//        CocosNetworkLogic* network = CocosNetworkLogic::getInstance();
//        network->opJoinRoom( room->getName() );

        std::string stdStr = room->toString().UTF8Representation().cstr();
        stdStr = "Join this room?";
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
        CCSprite* background = CCSprite::create( "frame.png" );

        CCScale9Sprite* controlCancelBackground = CCScale9Sprite::create("extensions/yellow_edit.png");
        CCScale9Sprite* controlOkayBackground = CCScale9Sprite::create("extensions/yellow_edit.png");
        CCLabelTTF* label = CCLabelTTF::create( stdStr.c_str(), "Arial", FONT_SIZE(24) );
        label->setColor(ccc3(0, 0, 0));
        CCLabelTTF* cancelLabel = CCLabelTTF::create(". Cancel .", "Arial", FONT_SIZE(24));
        CCLabelTTF* okayLabel     = CCLabelTTF::create(".  Okay  .", "Arial", FONT_SIZE(24));
        cancelLabel->setColor(ccc3(0, 0, 0));
        okayLabel->setColor(ccc3(0, 0, 0));
        CCControlButton* cancel = CCControlButton::create( cancelLabel, controlCancelBackground );
        CCControlButton* okay = CCControlButton::create( okayLabel, controlOkayBackground );
        okay->addTargetWithActionForControlEvents(this, cccontrol_selector(CCLobbyView::joinRoom), CCControlEventTouchUpInside);
        
        CCFadeIn* in = CCFadeIn::create(1.0f);
        CCFadeOut* out = CCFadeOut::create(1.0f);
        
        CCConfirmMessage* message = CCConfirmMessage::create( background, label, cancel, okay, in, out );
        CCSize messageSize = message->getContentSize();
        message->setPosition( ccp(winSize.width/2 - messageSize.width/2, winSize.height/2 - messageSize.height/2) );

        pBottomMenu->setVisible(false);
        this->setIsJoinRoomConfirming(true);
        this->addChild(message, 10, Child::CCConfirmDialog);
    }
}
开发者ID:kaznog,项目名称:t09,代码行数:48,代码来源:CCLobbyView.cpp

示例11: createClientUI

    void ClientChatNetPackageSender::createClientUI( PeerNode* peerNode, CCControlBase* parentLayer )	{
        CCSize preferredSize(CCSizeMake(0,0));

        _ctrlName = ControlUtils::createEditBox("Name:", preferredSize);
        _ctrlPassword = ControlUtils::createEditBox("Password:", preferredSize);
        _ctrlMessage = nl::ControlUtils::createEditBox("Message:", preferredSize);

        ControlUtils::addCtrlNode(_ctrlName, parentLayer);
        ControlUtils::addCtrlNode(_ctrlPassword, parentLayer);
        ControlUtils::addCtrlNode(_ctrlMessage, parentLayer);

        CCControlButton* ctrlBtn;
        ctrlBtn = sl::ControlUtils::createButton("Register");
        ctrlBtn->setTag(SL_CTRLID_REGISTER);
        ctrlBtn->addTargetWithActionForControlEvents(
            this, 
            cccontrol_selector(ClientChatNetPackageSender::onUIAction), 
            CCControlEventTouchUpInside);

        ControlUtils::addCtrlNode(ctrlBtn, parentLayer);
    }
开发者ID:Mobiletainment,项目名称:Multiplayer-Network-Conecpts,代码行数:21,代码来源:nlChatSample.cpp

示例12: init

bool TutorialLayer::init(){
    if (CCLayer::init()) {
        callback = NULL;
        target = NULL;
        
        CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
        CCLayerColor *background = CCLayerColor::create(ccc4(0, 0, 0, 200), screenSize.width, screenSize.height);
        this->addChild(background);

        CCScale9Sprite *closeButtonSprite = Common::getCCScale9SpriteWithoutScale("CloseButton.png");
        CCControlButton *closeButton = CCControlButton::create(closeButtonSprite);
        closeButton->setPreferredSize(closeButtonSprite->getOriginalSize());
        closeButton->setContentSize(closeButtonSprite->getOriginalSize());
        closeButton->setPosition(ccp(screenSize.width*0.9, screenSize.height*0.9));
        closeButton->addTargetWithActionForControlEvents(this, cccontrol_selector(TutorialLayer::close), CCControlEventTouchUpInside);
        this->addChild(closeButton, CLOSE_BUTTON_Z);
        
        return true;
    }
    return false;
}
开发者ID:killing333,项目名称:Colors,代码行数:21,代码来源:TutorialLayer.cpp

示例13: init

bool CPullMachHelpLayer::init()
{
    if (!CCLayer::init())
        return false;

    CCSize barDownSize;	//µ×Ãæ±ß¿ò³ß´ç
    CCSize barUpSize;	//ÉÏÃæ±ß¿ò³ß´ç
    CCSize infoBgSize;	//ÐÅÏ¢±³¾°³ß´ç
    CCSize infoViewSize;	//ÐÅÏ¢¿ÉÊӳߴç

    CCSprite * pSprite = NULL;
    if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Bar_Down, pSprite))
    {
        barDownSize = pSprite->getContentSize();
        pSprite->setAnchorPoint(CCPointZero);
        pSprite->setPosition(CCPointZero);
        this->addChild(pSprite);
    }

    {
        float fHeight = this->getContentSize().height - 200;
        infoBgSize.setSize(barDownSize.width, (fHeight > 600) ? 600 : fHeight);
        CCLayerColor * bgLayer = CCLayerColor::create(ccc4(0, 24, 85, 255), infoBgSize.width, infoBgSize.height);
        bgLayer->setPosition(ccp(0, barDownSize.height));
        this->addChild(bgLayer);
    }

    if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Bar_Up, pSprite))
    {
        barUpSize = pSprite->getContentSize();
        pSprite->setAnchorPoint(CCPointZero);
        pSprite->setPosition(ccp(0, barDownSize.height + infoBgSize.height));
        this->addChild(pSprite);
    }

    //Ìí¼Ó¹ö¶¯ÄÚÈÝ
    infoViewSize.setSize(infoBgSize.width - 20, infoBgSize.height);
    if (m_pResManager->GenerateNodeByCfgID(eSpriteType_Base, PullMach_Bg_Help_Info, pSprite))
    {
        pSprite->setAnchorPoint(ccp(0.5f, 0.0f));
        pSprite->setPosition(ccp(infoViewSize.width / 2, 0));
    }

    CCLayerColor * layerColor = CCLayerColor::create(ccc4(0, 13, 32, 255), infoViewSize.width, pSprite->getContentSize().height);
    layerColor->setPosition(CCPointZero);
    layerColor->addChild(pSprite);

    m_pScroll = CCScrollView::create();
    m_pScroll->setViewSize(infoViewSize);
    m_pScroll->setPosition(ccp(10, barDownSize.height));
    m_pScroll->setDirection(kCCScrollViewDirectionVertical);
    m_pScroll->addChild(layerColor);
    m_pScroll->setContentSize(layerColor->getContentSize());
    m_pScroll->setContentOffset(m_pScroll->minContainerOffset());
    m_pScroll->setTouchPriority(kCCMenuHandlerPriority - 1);
    this->addChild(m_pScroll);

    this->setContentSize(CCSize(infoBgSize.width, barDownSize.height + barUpSize.height + infoBgSize.height));

    //Ìí¼Ó¹Ø±Õ°´Å¥
    CCControlButton* pCloseButton = m_pResManager->CreateControlButton(PullMach_Bt_Help_Close_N, PullMach_Bt_Help_Close_C);
    pCloseButton->setAnchorPoint(ccp(1, 1));
    pCloseButton->setPosition(getContentSize().width - 10, getContentSize().height - 4);
    pCloseButton->addTargetWithActionForControlEvents(this, cccontrol_selector(CPullMachHelpLayer::OnTouchClose), CCControlEventTouchUpInside);
    pCloseButton->setScaleX(1.5f);
    this->addChild(pCloseButton);

    return true;
}
开发者ID:hantingmeixue,项目名称:Aoyi,代码行数:69,代码来源:PullMachHelpLayer.cpp

示例14: initWithGift

bool MailWritePopUpView::initWithGift(int giftID,int propID) {
    if(!PopupBaseView::init()) {
        return false;
    }
    setIsHDPanel(true);
    mPropID = propID;
    mType = 1;
//    auto cf = CCLoadSprite::getSF("Mail_diban.png");
    auto cf = CCLoadSprite::getSF("Mail_BG1.png");
    if (cf==NULL) {
        CCLoadSprite::doResourceByCommonIndex(11, true);
        CCLoadSprite::doResourceByCommonIndex(6, true);
        setCleanFunction([]() {
            CCLoadSprite::doResourceByCommonIndex(11, false);
            CCLoadSprite::doResourceByCommonIndex(6, false);
        });
    }
    else {
        CCLoadSprite::doResourceByCommonIndex(11, true);
        setCleanFunction([]() {
            CCLoadSprite::doResourceByCommonIndex(11, false);
        });
    }

    auto bg = CCBLoadFile("NEWMailWriteView", this, this);
    if (CCCommonUtils::isIosAndroidPad()) {
        this->setContentSize(CCDirector::sharedDirector()->getWinSize());
    }
    else
        this->setContentSize(bg->getContentSize());
//    setTitleName(_lang("105513"));
    m_titleText->setString(_lang("105513"));
    if (CCCommonUtils::isIosAndroidPad()) {
        int extH = getExtendHeight();
        this->m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + extH));
        m_downNode->setPositionY(m_downNode->getPositionY() - extH);
        m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
//        m_nodeContent->setPositionY(m_nodeContent->getPositionY() - extH);
        auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
        auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
        auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
        picBg1->setAnchorPoint(ccp(0, 0));
        picBg1->setPosition(ccp(0, 0));
        picBg1->setScaleX(2.4);
        tBatchNode->addChild(picBg1);
        int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
        int curHeight = picBg1->getContentSize().height;
        while(curHeight < maxHeight)
        {
            auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
            picBg2->setAnchorPoint(ccp(0, 0));
            picBg2->setPosition(ccp(0, curHeight));
            picBg2->setScaleX(2.4);
            tBatchNode->addChild(picBg2);
            curHeight += picBg2->getContentSize().height;
        }
        m_bgNode->addChild(tBatchNode);
    }
    else {
        int extH = getExtendHeight();
        this->m_listNode->setContentSize(CCSize(m_listNode->getContentSize().width, m_listNode->getContentSize().height + extH));
        m_downNode->setPositionY(m_downNode->getPositionY() - extH);
        m_bgNode->setPositionY(m_bgNode->getPositionY() - extH);
//        m_nodeContent->setPositionY(m_nodeContent->getPositionY() - extH);
        auto tbg = CCLoadSprite::loadResource("Mail_diban.png");
        auto tBatchNode = CCSpriteBatchNode::createWithTexture(tbg->getTexture());
        auto picBg1 = CCLoadSprite::createSprite("Mail_diban.png");
        picBg1->setAnchorPoint(ccp(0, 0));
        picBg1->setPosition(ccp(0, 0));
        tBatchNode->addChild(picBg1);
        int maxHeight = CCDirector::sharedDirector()->getWinSize().height;
        int curHeight = picBg1->getContentSize().height;
        while(curHeight < maxHeight)
        {
            auto picBg2 = CCLoadSprite::createSprite("Mail_diban.png");
            picBg2->setAnchorPoint(ccp(0, 0));
            picBg2->setPosition(ccp(0, curHeight));
            tBatchNode->addChild(picBg2);
            curHeight += picBg2->getContentSize().height;
        }
        m_bgNode->addChild(tBatchNode);
    }
//    CCSize wNodeSize = this->m_waitingNode->getContentSize();
//    m_waitingNode->setContentSize(CCSize(wNodeSize.width,wNodeSize.height + dh));
//    m_waitingNode->setPositionY(m_waitingNode->getPositionY() - dh*0.5);

//    this->m_nameText->setString(_lang("105505").c_str());
    //    this->m_titleText->setString(_lang("105503").c_str());
//    this->m_contentText->setString(_lang("105504").c_str());

    CCNode *searchnode = CCNode::create();
    auto spr1 = CCLoadSprite::createScale9Sprite("button_dark.png");
    CCControlButton *shareBtn = CCControlButton::create(spr1);
    searchnode->addChild(shareBtn);
    shareBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(MailWritePopUpView::onChooseName), CCControlEventTouchUpInside);
    CCSprite* sprIcon = CCLoadSprite::createSprite("search_icon.png");
    CCSize sprSize = sprIcon->getContentSize();
    searchnode->addChild(sprIcon);
    CCCommonUtils::setSpriteMaxSize(sprIcon, 40);
    shareBtn->setPreferredSize(CCSize(60, 60));
//.........这里部分代码省略.........
开发者ID:ourgames,项目名称:dc208,代码行数:101,代码来源:MailWritePopUpView.cpp

示例15: init

bool HelloWorld::init()
{
    if ( !CCLayer::init())
    {
        return false;
    }
    //CCSize s = CCDirector::sharedDirector()->getWinSize();
    
    CCNode* container = CCNode::create();
    this->addChild(container);
    container->setPosition(ccp(0, 80));
    
    QimiParamInfo* paramInfo = QimiParamInfo::create(21, 15, "7a92bba4670d479c5514720c1cf46aab", "pay");
    QimiPlatform::shareQimiPlatform()->setParamInfo(paramInfo);
    
    CCControlButton* backBtn0 = CCControlButton::create(CCLabelTTF::create("全屏WEBVIEW", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn0->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn0);
    backBtn0->setPosition(ccp(240, 590));
    backBtn0->addTargetWithActionForControlEvents(this,
                                                 cccontrol_selector(HelloWorld::openWebURLFull),
                                                 CCControlEventTouchUpInside);
    
    
    CCControlButton* backBtn = CCControlButton::create(CCLabelTTF::create("QIMI登录窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn);
    backBtn->setPosition(ccp(240, 520));
    backBtn->addTargetWithActionForControlEvents(this,
                                                 cccontrol_selector(HelloWorld::menuCloseCallback),
                                                 CCControlEventTouchUpInside);
    

    CCControlButton* backBtn3 = CCControlButton::create(CCLabelTTF::create("QIMI注册窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn3->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn3);
    backBtn3->setPosition(ccp(240, 450));
    backBtn3->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::reg),
                                                  CCControlEventTouchUpInside);
    
    CCControlButton* backBtn2 = CCControlButton::create(CCLabelTTF::create("QIMI直接登录窗口", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn2->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn2);
    backBtn2->setPosition(ccp(240, 380));
    backBtn2->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::login),
                                                  CCControlEventTouchUpInside);
    
    
    CCControlButton* backBtn7 = CCControlButton::create(CCLabelTTF::create("QIMI充值中心", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn7->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn7);
    backBtn7->setPosition(ccp(240, 310));
    backBtn7->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::menuCloseCallback),
                                                  CCControlEventTouchUpInside);

    
    
    
    CCControlButton* backBtn4 = CCControlButton::create(CCLabelTTF::create("QIMI论坛", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn4->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn4);
    backBtn4->setPosition(ccp(240, 240));
    backBtn4->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::openWebURL),
                                                  CCControlEventTouchUpInside);
    
    CCControlButton* backBtn5 = CCControlButton::create(CCLabelTTF::create("忘记密码", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn5->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn5);
    backBtn5->setPosition(ccp(240, 160));
    backBtn5->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::forget),
                                                  CCControlEventTouchUpInside);
    
    
    CCControlButton* backBtn6 = CCControlButton::create(CCLabelTTF::create("退出QIMI", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn6->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn6);
    backBtn6->setPosition(ccp(240, 90));
    backBtn6->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::quit),
                                                  CCControlEventTouchUpInside);
    
    CCControlButton* backBtn9 = CCControlButton::create(CCLabelTTF::create("获取设备ID", "Helvetica", 20), CCScale9Sprite::create("buttonblue.png"));
    backBtn9->setPreferredSize(CCSizeMake(200, 50));
    container->addChild(backBtn9);
    backBtn9->setPosition(ccp(240, 20));
    backBtn9->addTargetWithActionForControlEvents(this,
                                                  cccontrol_selector(HelloWorld::getDivceId),
                                                  CCControlEventTouchUpInside);
    
    return true;
}
开发者ID:BenVim,项目名称:IsmoleSDK,代码行数:96,代码来源:HelloWorldScene.cpp


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