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


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

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


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

示例1: initView

void SpRuleInfoBox::initView()
{
    CCPoint center = SGLayout::getPoint(kMiddleCenter);
    
	fontbg->setPreferredSize(CCSizeMake(380, 380));
	fontbg->setPosition(ccpAdd(fontbg->getPosition(), ccp(0, 25)));
	SGCCLabelTTF *tips = SGCCLabelTTF::create(str_SpecialBattleIntro, FONT_PANGWA, 32 ,ccRED);
	this->addChild(tips, 2);
	tips->setPosition(ccpAdd(biao->getPosition(), ccp(0, 0)));
	
    //可滚动规则视图
    
	CCScrollView *m_scrollview = CCScrollView::create(CCSizeMake(350, 150));
	m_scrollview->setViewSize(CCSizeMake(350, 360));
    CCLayerColor *container = CCLayerColor::create(ccc4(0, 0, 0, 0));
    container->setContentSize(CCSizeMake(350, 355));
    m_scrollview->setContainer(container);
	m_scrollview->setPosition(ccpAdd(center, ccp(-fontbg->getContentSize().width / 2, -fontbg->getContentSize().height / 2 + 30)));//设置scrollview位置
	
	m_scrollview->setDirection(kCCScrollViewDirectionVertical);
    this->addChild(m_scrollview);
	m_scrollview->setTag(103);
	
	//测试数据
	int finalLen = 0;
	int rankSize = 10;
    SGStaticDataManager *mgr = SGStaticDataManager::shareStatic();
    
	for (int i = 0; i < mgr->getSpHelpInfoKeysNum(); i++)
	{
        
        std::string info = SGStaticDataManager::shareStatic()->getSingleSpBattleRule(i);
        if (info != "")
        {
            SGRuleItem *item = SGRuleItem::create(i, info.c_str());
            container->addChild(item);
            item->setPosition(ccpAdd(container->getPosition(), ccp(item->getContentSize().width / 2.8,
															   (item->getContentSize().height + 10) * (rankSize - i) - item->getContentSize().height - 30)));
            finalLen += (item->getContentSize().height + 10);
        }
	}
	m_scrollview->setContentOffset(ccp(0, -finalLen + m_scrollview->getContentSize().height - 10));
	m_scrollview->setContentSize(CCSizeMake(350, finalLen));
	m_scrollview->getContainer()->setContentSize(CCSizeMake(350, finalLen + 20));
    
    
	
	SGButton *okButton = SGButton::createFromLocal("box_btnbg.png", str_Ok, this, menu_selector(SpRuleInfoBox::pressOkButton),
												   ccp(0, 0), FONT_PANGWA, ccWHITE, 24);
	this->addBtn(okButton);
	okButton->setPosition(ccpAdd(center, ccp(0, -324/2+5 -70)));
}
开发者ID:caoguoping,项目名称:warCraft,代码行数:52,代码来源:SGSpecialBattleLayer.cpp

示例2: initView


//.........这里部分代码省略.........
            quality = afterEquipModel->getOfficerCurrStarLevel();
            
//            if(quality < 3 || quality > 6)
//                titleColor = ccGREEN;
//            else
//                titleColor = color[quality - 3];
            
            break;
        }
            
        default:
            break;
    }
    
    //构造sprite
    beforeAdvancedItemPic = CCSprite::createWithSpriteFrameName(beforeItemPicStr);
    afterAdvancedItemPic = CCSprite::createWithSpriteFrameName(afterItemPicStr);
    itemName = SGCCLabelTTF::create(itemNameStr, FONT_PANGWA, 35, SGTools::getColorByQuality(quality));
    if (adNum)
    {
        adNumLabel = SGCCLabelTTF::create(itemAdNum, FONT_PANGWA, 34, ccGREEN);
    }
    
    
    
    //黑背景
    CCLayerColor *blackBg = CCLayerColor::create(ccc4(0, 0, 0, 255), CCDirector::sharedDirector()->getWinSize().width,
                                                 CCDirector::sharedDirector()->getWinSize().height);
    this->addChild(blackBg, 0);
    blackBg->setPosition(ccp(0, 0));
    blackBg->addChild(beforeAdvancedItemPic, 1);
    blackBg->addChild(itemName, 1);
    
    beforeAdvancedItemPic->setPosition(ccpAdd(blackBg->getPosition(), ccp(blackBg->getContentSize().width / 2,
                                                                          blackBg->getContentSize().height / 2)));
    itemName->setPosition(ccpAdd(beforeAdvancedItemPic->getPosition(), ccp(0, beforeAdvancedItemPic->getContentSize().height / 2
                                                                           + itemName->getContentSize().height + 20)));
    if (adNumLabel)
    {
        blackBg->addChild(adNumLabel, 1);
        adNumLabel->setPosition(ccpAdd(itemName->getPosition(), ccp(itemName->getContentSize().width / 2 + 10 + adNumLabel->getContentSize().width, 0)));
    }
    
    
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    
    //添加动画 法阵旋转
    CCSpriterX *visitArray = CCSpriterX::create("animationFile/Array.scml",true,true);
    visitArray->setisloop(true);
    visitArray->play();
    visitArray->setanimaID(0);
    blackBg->addChild(visitArray,1);
    visitArray->setPosition(ccp(winSize.width/2, winSize.height*(0.8-0.28) - 50));
    //法阵上升粒子
    CCSpriterX *lightSpot = CCSpriterX::create("animationFile/Lightspot.scml",true,true);
    lightSpot->setisloop(true);
    lightSpot->play();
    lightSpot->setanimaID(0);
    blackBg->addChild(lightSpot,50);
    lightSpot->setPosition(ccp(winSize.width/2, winSize.height*(0.8-0.2)));
    
        //构造动画
    CCCallFuncN *setPicVisiable = CCCallFuncN::create(this,
                                                      callfuncN_selector(SGAdvancedEffectLayer::setPictureVisiable));
    CCCallFuncN *setTipsVisiable = CCCallFuncN::create(this,
                                                       callfuncN_selector(SGAdvancedEffectLayer::setSuccessTipsVisiable));
开发者ID:caoguoping,项目名称:warCraft,代码行数:67,代码来源:SGAdvancedEffectLayer.cpp

示例3: init

// on "init" you need to initialize your instance
bool MainMenuScene::init()
{
    // Parent
    CCLayerColor *layer = CCLayerColor::create();
    layer->initWithColor(ccc4(255, 255, 255, 255), VisibleRect::right().x , VisibleRect::top().y);
    layer->setPosition(VisibleRect::center());
    layer->setAnchorPoint(ccp(0.5f, 0.5f));
    layer->ignoreAnchorPointForPosition(false);
    addChild(layer, 0);
    
    CCSprite *fondo = CCSprite::create("fondo.png");
    fondo->setPosition(VisibleRect::center());
    layer->addChild(fondo);
    
    // 1st Son
    CCLayerColor *upperLayer = CCLayerColor::create();
    upperLayer->setContentSize(ccp(VisibleRect::right().x , VisibleRect::top().y/2));
    //upperLayer->initWithColor(ccc4(120, 120, 120, 120), VisibleRect::right().x , VisibleRect::top().y/2);
    upperLayer->setPosition(ccp(VisibleRect::left().x, VisibleRect::center().y));
    upperLayer->setAnchorPoint(ccp(0,0));
    upperLayer->ignoreAnchorPointForPosition(false);
    layer->addChild(upperLayer, 0);
    
    CCSprite *spriteLogo = CCSprite::create("logo_opciones.png");
    spriteLogo->setPosition(ccp(layer->getPosition().x, layer->getPosition().y/2));
    upperLayer->addChild(spriteLogo);
    
    // 2nd Son
    CCLayerColor *lowerLayer = CCLayerColor::create();
    lowerLayer->setContentSize(ccp(VisibleRect::right().x , VisibleRect::top().y/2));
    //lowerLayer->initWithColor(ccc4(200, 200, 200, 200), VisibleRect::right().x , VisibleRect::top().y/2);
    lowerLayer->setPosition(ccp(VisibleRect::left().x, VisibleRect::bottom().y));
    lowerLayer->setAnchorPoint(ccp(0,0));
    lowerLayer->ignoreAnchorPointForPosition(false);
    layer->addChild(lowerLayer, 0);
    
    int mySize = lowerLayer->getContentSize().height / 3;
    
    // Button SAILKAPENA
    CCTexture2D *texture1 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
    SpriteButton *pButton1 = SpriteButton::create(texture1 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
    pButton1->setTag(2);
    pButton1->setPosition(ccp(
                              lowerLayer->getContentSize().width / 2,
                              lowerLayer->getContentSize().height / 2));
    pButton1->setAnchorPoint(ccp(0.5f, 0.5f));
    CCLabelTTF *pLabel1 = CCLabelTTF::create("Sailkapena", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
    pLabel1->setPosition(ccp(
                             lowerLayer->getContentSize().width / 2,
                             lowerLayer->getContentSize().height / 2));
    lowerLayer->addChild(pButton1);
    lowerLayer->addChild(pLabel1);
    
    // Button JOKATU
    CCTexture2D *texture2 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
    SpriteButton *pButton2 = SpriteButton::create(texture2 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
    pButton2->setTag(1);
    pButton2->setPosition(ccp(
                              lowerLayer->getContentSize().width / 2,
                              (mySize * 3) - texture2->getContentSize().height));
    pButton2->setAnchorPoint(ccp(0.5f, 0.5f));
    CCLabelTTF *pLabel2 = CCLabelTTF::create("Jokatu", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
    pLabel2->setPosition(ccp(
                             lowerLayer->getContentSize().width / 2,
                             (mySize * 3) - texture2->getContentSize().height));
    lowerLayer->addChild(pButton2);
    lowerLayer->addChild(pLabel2);
    
    // Button HONI BURUZ
    CCTexture2D *texture3 = CCTextureCache::sharedTextureCache()->addImage("botoia_normal.png");
    SpriteButton *pButton3 = SpriteButton::create(texture3 ,this, callfuncO_selector(MainMenuScene::menuSelector), 1.0f);
    pButton3->setTag(3);
    pButton3->setPosition(ccp(
                              lowerLayer->getContentSize().width / 2,
                              mySize - (texture2->getContentSize().height / 2)));
    pButton3->setAnchorPoint(ccp(0.5f, 0.5f));
    CCLabelTTF *pLabel3 = CCLabelTTF::create("Honi buruz", "fonts/PT_Sans-Web-Bold.ttf", 30.0);
    pLabel3->setPosition(ccp(
                             lowerLayer->getContentSize().width / 2,
                             mySize - (texture2->getContentSize().height / 2)));
    lowerLayer->addChild(pButton3);
    lowerLayer->addChild(pLabel3);
    
	return true;
}
开发者ID:axierjhtjz,项目名称:Jakina-mobile,代码行数:86,代码来源:MainMenuScene.cpp


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