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


C++ Fish::GetLevel方法代码示例

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


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

示例1: XMTMoveAI


//.........这里部分代码省略.........
        {
            // create block
            _disDivisor4Block = disDivisor4Block;
            
            // create fish
            float rd2 = CCRANDOM_0_1();
            
            float x = 25 + 700 * rd2;
            
            log("create block");
            
            BFBlock* block = BFBlock::createBlock(Vec2(x, 1334));
            block->setTag(OBJ_BLOCK);
            playLayer->apiAddBlock(block);
        }
    }
    
    Fish* player = playLayer->xGetPlayer();
    // collision detection
    {
        Vec2 pPos = player->getPosition();
        gData->_playerPosY = pPos.y;
        
        Rect pRect = player->getBoundingBox();
        Vector<Node*>& children = playLayer->getChildren();
        for(auto a : children)
        {
            if((a->getTag() & OBJ_FISH) == OBJ_FISH)
            {
                Fish* fish = (Fish*)a;
                Rect fRect = fish->getBoundingBox();
                if(fRect.intersectsRect(pRect))
                {
                    if(fish->GetLevel() > player->GetLevel())
                    {
                        // game over
                        gData->_healthPoint = 0;
                        JizGame::getInstance()->playAudioEffect("audioeffect/hurt2.mp3");
                    }
                    else
                    {
                        JizGame::getInstance()->playAudioEffect("audioeffect/eat1.mp3");
                        gData->_experience += (10 + fish->GetLevel());
                        gData->_eatedCount++;
                        gData->_staminaPoint += gData->_staminaRecoverPoint* fish->GetLevel();
                        
                        // eat fish
                        gData->_staminaPoint += 10;
                        
                        fish->Die();
                        fish->setTag(OBJ_ORNAMENTAL);
                        
                        auto layerEffect = (XEffectLayer*)playLayer->getChildByTag(LAYER_EFFECT);
                        layerEffect->XAddFishEatedEffect(fish->getPosition(), fish->GetLevel());
                    }
                }
            }
            else if(a->getTag() == OBJ_BLOCK)
            {
                Rect fRect = a->getBoundingBox();
                if(fRect.intersectsRect(pRect))
                {
                    // game over
                    gData->_healthPoint -= 10;
                    a->setTag(OBJ_ORNAMENTAL);
                    JizGame::getInstance()->playAudioEffect("audioeffect/hurt1.mp3");
开发者ID:Stringbao,项目名称:bigfish,代码行数:67,代码来源:M001Logic.cpp


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