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


C++ CCLayerColor::setTouchEnabled方法代码示例

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


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

示例1: constructView

void SGCGMovieLayer::constructView()
{
    SGNotificationCenter::sharedNotificationCenter()->addObserver(MSG_CGBATTLE_START, this, callfuncO_selector(SGCGMovieLayer::cgBattleListener));
       s = CCDirector::sharedDirector()->getWinSize();
    
    ResourceManager::sharedInstance()->bindTexture("bg/cgBg.plist", RES_TYPE_LAYER_UI, sg_cgMovieLayer);

    CCSprite *cgBg = CCSprite::createWithSpriteFrameName("cgBg.png");
    cgBg->setAnchorPoint(ccp(0.5, 1));
    cgBg->ignoreAnchorPointForPosition(false);
    cgBg->cocos2d::CCNode::setScaleX(s.width/cgBg->getContentSize().width);
    cgBg->setPosition(ccp(s.width/2, s.height));
    addChild(cgBg);
    
//    SGButton *skipBt = SGButton::createFromLocal("box_btnbg.png", "跳 过", this, menu_selector(SGCGMovieLayer::cgSkipToBattle), CCPointZero, FONT_PANGWA,ccWHITE,32,false,true);
//    skipBt->setPosition(ccp(s.width/2, skipBt->getContentSize().height*2));
//    addBtn(skipBt);
    
    CCLayerColor * blackBg = CCLayerColor::create(ccc4(0, 0, 0, 255), s.width, s.height);
    blackBg->setTouchEnabled(false);
    blackBg->ignoreAnchorPointForPosition(false);
    blackBg->setAnchorPoint(ccp(0, 0));
    blackBg->setPosition(ccp(0, 0));
    this->addChild(blackBg, -100);
    
    scrollRect = CCRectMake(0, s.height*0.2, s.width, s.height/4);
    cgScrollView = SNSScrollView::create(scrollRect);
    cgScrollView->setFrame(scrollRect);
    cgScrollView->setPosition(scrollRect.origin);
    cgScrollView->setHorizontal(false);
    cgScrollView->setVertical(true);
    cgScrollView->setTouchEnabled(false);
    this->addChild(cgScrollView);
    
//    CCSprite *scrollBg = CCSprite::createWithSpriteFrameName("barrack_kuang.png");
//    scrollBg->cocos2d::CCNode::setScale(s.width/scrollBg->getContentSize().width, s.height/4/scrollBg->getContentSize().height);
//    scrollBg->setPosition(ccpAdd(scrollRect.origin, ccp(s.width/2, s.height/8)));
//    addChild(scrollBg);
    
    char *spritData = new char[(int)s.width * (int)s.height *4];
    memset(spritData,0,(int)s.width * (int)s.height *4);
    int spriteDataSize = (int)s.width * (int)s.height*4;
    for (int j=0; j<spriteDataSize; j+=4) {
        spritData[j] = 0;
        spritData[j+1] = 0;
        spritData[j+2] = 0;
        spritData[j+3] = 255;
    }
    
    CCTexture2D *pTexture = new CCTexture2D();
    pTexture->initWithData(spritData, kCCTexture2DPixelFormat_Default, (int)s.width, (int)s.height, s);
    
    finaleSprite = CCSprite::createWithTexture(pTexture);
    finaleSprite->setPosition(CCPointZero);
    finaleSprite->setAnchorPoint(CCPointZero);
    this->addChild(finaleSprite,10,10);
    finaleSprite->setVisible(false);
    finaleSprite->setOpacity(0);
    
    delete [] spritData;
    pTexture->autorelease();
    
    
    this->setTouchEnabled(true);
    
    const char *str[7] = { str_CGMovieLayer_str1,
                         str_CGMovieLayer_str2,
                        str_CGMovieLayer_str3,
                         str_CGMovieLayer_str4,
                        str_CGMovieLayer_str5,
                          str_CGMovieLayer_str6,
                         str_CGMovieLayer_str7};
    
    SGCCLabelTTF *cgMsg = NULL;
    posY =  -20;
    for (int i=0; i<7; i++) {
        cgMsg =  SGCCLabelTTF::create(str[i], FONT_BOXINFO, 34);
        cgMsg->cocos2d::CCNode::setPosition(s.width/2, posY);
        cgScrollView->m_body->addChild(cgMsg);
        posY -= 50;
    }
    moveCgMsgDis = CGMSGMOVEDIS;
    unschedule(schedule_selector(SGCGMovieLayer::moveCgMsgUp));
    if (SGPlayerInfo::sharePlayerInfo()->getCDKeyNeed()==1) {
        
        SGNotificationCenter::sharedNotificationCenter()->addObserver(MSG_CDK, this, callfuncO_selector(SGCGMovieLayer::cdkListener));
        
        ResourceManager::sharedInstance()->bindTexture("sgloginingbox/sgloginingbox.plist", RES_TYPE_LAYER_UI, sg_cgMovieLayer);
//         ResourceManager::sharedInstance()->bindTexture("sgserverlistlayer/sgserverlistlayer.plist",RES_TYPE_LAYER_UI ,sg_registerLayer);
        
        
        box = CCSprite::createWithSpriteFrameName("register_diban.png");
        box->setPosition(SGLayout::getPoint(kMiddleCenter));
        this->addChild(box);

        m_cdk = CCEditBox::create(CCSizeMake(500, 60), CCScale9Sprite::createWithSpriteFrameName("public_kuang_input.png"));
        m_cdk->setPlaceHolder(str_CGMovieLayer_str8);
        m_cdk->setPlaceholderFontColor(ccc3(0x82,0x3e,0x02));
        m_cdk->setMaxLength(10);
        m_cdk->setReturnType(kKeyboardReturnTypeDone);
//.........这里部分代码省略.........
开发者ID:caoguoping,项目名称:warCraft,代码行数:101,代码来源:SGCGMovieLayer.cpp


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