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


C++ CCPointArray::addControlPoint方法代码示例

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


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

示例1: init

bool AllianceAreaPopupView::init(){
    if(!PopupBaseView::init()){
        return false;
    }
    setIsHDPanel(true);
    isMoving = false;
    this->setModelLayerOpacity(0);
    this->setContentSize(CCDirector::sharedDirector()->getWinSize());
    m_picNode = CCNode::create();
    m_picNode->setContentSize(CCSize(_tile_width * 2, _tile_height * 2));
    m_picNode->setAnchorPoint(ccp(0, 0));
    CCPoint testPoint =PopupViewController::getInstance()->getTouchPoint() + ccp(-_tile_width, -_tile_height);
//    m_picNode->setPosition(PopupViewController::getInstance()->getTouchPoint() + ccp(-_tile_width, -_tile_height));
    
    CCPoint tilePoint = WorldController::getInstance()->getPointByIndex(m_tileIndex);
    CCPoint viewPoint = getInLayerPoint(tilePoint);
    viewPoint = viewPoint + ccp(-_tile_width * 1.5, -_tile_height);
    m_picNode->setPosition(viewPoint);
    
    m_cityNode = CCNode::create();
    
 
    /*int mapIndex = 3;
    while (mapIndex >= 0) {
        auto arr = WorldController::getInstance()->getCityPicArr(mapIndex, 0, false ,44996);
        int posX = _tile_width / 2;
        int posY = _tile_height / 2;
        if(mapIndex == 0 || mapIndex == 2){
            posX = _tile_width;
        }
        if(mapIndex == 3){
            posX = _tile_width + posX;
        }
        if(mapIndex == 1 || mapIndex == 3){
            posY = _tile_height;
        }
        if(mapIndex == 2){
            posY = _tile_height + posY;
        }
        auto itMap = arr.begin();
        while (itMap!=arr.end()) {
            std::string picName = (*itMap).pic;
            int addX = (*itMap).x;
            int addY = (*itMap).y;
            auto sprite = CCLoadSprite::createSprite(picName.c_str());
            sprite->setAnchorPoint(ccp(0, 0));
            if (CCCommonUtils::isIosAndroidPad()) {
                m_cityNode->addChild(sprite);
                sprite->setPosition(ccp(posX, posY) - ccp(_tile_width / 2, _tile_height / 2) + ccp(addX, addY));
                
            }
            else {
                m_picNode->addChild(sprite);
                sprite->setPosition(ccp(posX, posY) - ccp(_tile_width / 2, _tile_height / 2) + ccp(addX, addY));
            }
            ++itMap;
        }
        mapIndex--;
    }*/
    auto tower = CCLoadSprite::createSprite("territory_fort.png");
    tower->setPosition(ccp(_tile_width -25, _tile_height + 62));
    m_picNode->addChild(tower);
    
    if (CCCommonUtils::isIosAndroidPad()) {
        m_picNode->addChild(m_cityNode);
        m_cityNode->setScale(WORLD_DEFAULT_HD_SCALE);
        m_cityNode->setPosition(ccp(-_tile_width * (WORLD_DEFAULT_HD_SCALE - 1),-_tile_height * (WORLD_DEFAULT_HD_SCALE - 1)));
    }
    
        CCPointArray* pointArr = CCPointArray::create(3);
        pointArr->addControlPoint(ccp(-70,59));
        pointArr->addControlPoint(ccp(-2,23));
        pointArr->addControlPoint(ccp(66,57));
    CCLoadSprite::doResourceByCommonIndex(507, true);
        for (int i = 0; i < 3; i++) {
            auto bannerSprite = CCFlagWaveSprite::create(CCLoadSprite::loadResource("1212_double.png"));
            if (CCCommonUtils::isIosAndroidPad()) {
                bannerSprite->setScale(0.25);
            }
            else
                bannerSprite->setScale(0.18);
            bannerSprite->setPosition(ccp(_tile_width, _tile_height)+pointArr->getControlPointAtIndex(i) + ccp(12, 20));
            m_picNode->addChild(bannerSprite);
        }
    CCLoadSprite::doResourceByCommonIndex(507, false);
    
    if (CCCommonUtils::isIosAndroidPad()) {
        m_cancelBtn = CCControlButton::create(CCLoadSprite::createScale9Sprite("but_blue.png"));
        m_cancelBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(AllianceAreaPopupView::onCancelBtnClick), CCControlEventTouchUpInside);
        m_cancelBtn->setPreferredSize(CCSize(160, 70));
        m_cancelBtn->setScaleX(2.1);
        m_cancelBtn->setScaleY(1.7);
        
        m_confirmBtn = CCControlButton::create(CCLoadSprite::createScale9Sprite("btn_green3.png"));
        m_confirmBtn->setBackgroundSpriteForState(CCLoadSprite::createScale9Sprite("btn_green3.png"),CCControlStateHighlighted);
        m_confirmBtn->setBackgroundSpriteForState(CCLoadSprite::createScale9Sprite("Btn_grey.png"),CCControlStateDisabled);
        m_confirmBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(AllianceAreaPopupView::onConfirmBtnClick), CCControlEventTouchUpInside);
        m_confirmBtn->setPreferredSize(CCSize(160, 70));
        m_confirmBtn->setScaleX(2.1);
        m_confirmBtn->setScaleY(1.7);
//.........这里部分代码省略.........
开发者ID:ourgames,项目名称:dc208,代码行数:101,代码来源:AllianceAreaPopupView.cpp

示例2: setTileEffect

// Breakable(破壊可能)のタイルを赤にする
void Game::setTileEffect(CCPoint position)
{
    // stage and area
    _hud->setStageLabel(1, 1);
    _hud->setLifeLabel(1);
    
    CCPoint tileCoord = this->tileCoordForPosition(position);
    // キャラクターの上下左右の座標
    CCPointArray *pointArray = CCPointArray::create(4);
    pointArray->addControlPoint(ccp(0,1));
    pointArray->addControlPoint(ccp(-1,0));
    pointArray->addControlPoint(ccp(1,0));
    pointArray->addControlPoint(ccp(0,-1));
    
    for(int i = 0; i < pointArray->count(); i++){
        CCPoint point = pointArray->getControlPointAtIndex(i);
        //CCLog("(%f,%f)", point.x, point.y);
            
        CCPoint tmpTileCoord = ccp(tileCoord.x + point.x, tileCoord.y + point.y);
        if(tmpTileCoord.x < 0 || tmpTileCoord.x > _tileMap->getMapSize().width -1 ||
           tmpTileCoord.y < 0 || tmpTileCoord.y > _tileMap->getMapSize().height - 1)
        {
            continue;
        }

        //CCLog("(%f,%f)", tmpTileCoord.x, tmpTileCoord.y);
        //CCLog("TileX %f, TileY %f", _tileMap->getMapSize().width, _tileMap->getMapSize().height);
        
        int tileGid = _meta->tileGIDAt(tmpTileCoord);
        
        if (tileGid) {
            CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
            if (properties) {
                // obstacle
                CCString *collision = new CCString();
                // Breakableを赤
                *collision = *properties->valueForKey("Breakable");
            
                if (collision && (collision->compare("True") == 0)) {
                    CCSprite *sprite = _background->tileAt(tmpTileCoord);
                    //sprite->setTag(TAPPABLE);
                    // red
                    sprite->setColor(ccRED);
                }
            }
        }
    }
    
    // 白に戻す
    // まず詰める
    /*
      ◯は赤なので変化させない
      |6,0|6,1|6,2|6,3|6,4|6,5|6,6|
      |5,0|5,1|5,2|5,3|5,4|5,5|5,6|
      |4,0|4,1|4,2|◯4,3|4,4|4,5|4,6|
      |3,0|3,1|◯3,2|3,3|◯3,4|3,5|3,6|
      |2,0|2,1|2,2|◯2,3|2,4|2,5|2,6|
      |1,0|1,1|1,2|1,3|1,4|1,5|1,6|
      |0,0|0,1|0,2|0,3|0,4|0,5|0,6|
    */
    CCPointArray *revertPointArray = CCPointArray::create(255);
    for (int i = 0; i < 7; i++) {
        for (int j = 0; j < 7; j++) {
            if((i == 3 && j == 2) || (i == 3 && j == 4) ||
               (i == 2 && j == 3) || (i == 4 && j == 3)
            )
            {
                continue;
            }
            revertPointArray->addControlPoint(ccp(-3 + j, -3 + i));
        }
    }

    // 詰めたものから適用
    for(int i = 0; i < revertPointArray->count(); i++) {
        CCPoint point = revertPointArray->getControlPointAtIndex(i);
        //CCLog("(%f,%f)", point.x, point.y);
        
        CCPoint tmpTileCoord = ccp(tileCoord.x + point.x, tileCoord.y + point.y);
        
        // 画面端はエラーになるので適用させない
        if(tmpTileCoord.x < 0 || tmpTileCoord.x > _tileMap->getMapSize().width - 1||
           tmpTileCoord.y < 0 || tmpTileCoord.y > _tileMap->getMapSize().height - 1)
        {
            continue;
        }
        
        //CCLog("(%f,%f)", tmpTileCoord.x, tmpTileCoord.y);
        
        int tileGid = _meta->tileGIDAt(tmpTileCoord);
        
        if (tileGid) {
            CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
            if (properties) {
                // obstacle
                CCString *collision = new CCString();
                // Breakableのみ戻す
                *collision = *properties->valueForKey("Breakable");
                
//.........这里部分代码省略.........
开发者ID:shinriyo,项目名称:expeller,代码行数:101,代码来源:GameScene.cpp


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