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


C++ CCAction::isDone方法代码示例

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


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

示例1: ccTouchesEnded

void TestController::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
    CCAction* delaytime = CCActionManager::sharedManager()->getActionByTag(99,this);
    if(delaytime != NULL)
        if(delaytime->isDone() == false)
        {
            CCSetIterator it = pTouches->begin();
            CCTouch* touch = (CCTouch*)(*it);
            CCPoint p1 =	m_tBeginPos;
            CCPoint p2 =	touch->locationInView(touch->view());
            float x = m_pItmeMenu->getPosition().x + (p2.x - p1.x) * 5;
            if(x>= 0)
                x = 0;
            else if(x <= -m_pItmeMenu->getContentSize().width)
                x = -m_pItmeMenu->getContentSize().width;
            CCMoveTo* move = CCMoveTo::actionWithDuration(1,CCPointMake(x,0));
            CCActionInterval* ease = CCEaseOut::actionWithAction(move,3.0);
            m_pItmeMenu->runAction(ease);
        }
}
开发者ID:Openxlive,项目名称:cocos2d-x-win8-tests-metro-style,代码行数:20,代码来源:controller.cpp

示例2: update

void GameScene::update(float delta)
{
    bool oldCrashed = m_Crashed;
    if (m_Started && !m_Paused)
    {
        if (!m_Crashed)
        {
            float deltaX = m_fForwordVelocity * delta;

            // move background
            m_pBackground1->setPositionX(m_pBackground1->getPositionX() + deltaX);
            m_pBackground2->setPositionX(m_pBackground1->getPositionX() + m_pBackground1->getContentSize().width);

            if (m_pBackground1->getPositionX() + m_pBackground1->getContentSize().width / 2 <= m_VisibleOrigin.x)
            {
                CCSprite *pTemp = m_pBackground1;
                m_pBackground1 = m_pBackground2;
                m_pBackground2 = pTemp;

                m_pBackground2->setPositionX(m_pBackground1->getPositionX() + m_pBackground1->getContentSize().width);
            }

            // move pillars
            for (int i = 0; i < 4; i++)
            {
                if (m_Pillars[i] != NULL)
                {
                    m_Pillars[i]->setPositionX(m_Pillars[i]->getPositionX() + deltaX);
                    float w = m_pPig->getContentSize().width * m_pPig->getScaleX(), h = m_pPig->getContentSize().height * m_pPig->getScaleY();
                    CCRect pigRect = CCRectMake(m_pPig->getPositionX() - w / 2, m_pPig->getPositionY() - h / 2, w, h);
                    if (m_Pillars[i]->boundingBox().intersectsRect(pigRect))
                    {
                        m_Crashed = true;
                        //m_Pillars[i]->setPositionX(m_pPig->getPositionX() + m_pPig->getContentSize().width * m_pPig->getScale() / 2 + 44);
                    }
                }
            }
        }

        // fall & rotate pig
        CCAction *pAction = m_pPig->getActionByTag(kTagRaise);
        if (!pAction || pAction->isDone())
        {
            m_fFallVelocity += -1400 * delta;
            m_fFallVelocity = MAX(m_fFallVelocity, m_fMaxVelocity);
            float posY = m_pPig->getPositionY() +m_fFallVelocity * delta;
            if (posY <= m_VisibleOrigin.y + m_GroundPosY + m_pPig->getContentSize().height / 2)
            {
                posY = m_VisibleOrigin.y + m_GroundPosY + m_pPig->getContentSize().height / 2;
                m_Crashed = true;
            }

            m_pPig->setPositionY(posY);
            float orgRotation = m_pPig->getRotation();
            float rotation = 0;
            if (orgRotation < -24)
            {
                rotation = orgRotation + delta * 10;
            }
            else if (orgRotation < -22)
            {
                rotation = orgRotation + delta * 30;
            }
            else if (orgRotation < -16)
            {
                rotation = orgRotation + delta * 60;
            }
            else
            {
                rotation = orgRotation + delta * 500;
            }

            rotation = MIN(rotation, 80);
            m_pPig->setRotation(rotation);
        }

        if (m_Crashed)
        {
            if (!oldCrashed)
            {
                m_pPig->stopAllActions();

                GameManager *gameManager = GameManager::getInstance();
                gameManager->addGoalToday();
                if (gameManager->getGoalsToday() >= 2 && m_CurrentScore >= 5 && gameManager->getRated() == false && gameManager->getLaterTS() != Util::getCurrentDays())
                {
                    showRateView();
                }
                else
                {
                    showOverView();
                }

                if (m_Sound)
                {
                    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect(SFX_HIT);
                    scheduleOnce(schedule_selector(GameScene::playDieEffect), 0.5f);
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:studio501,项目名称:fiypig,代码行数:101,代码来源:GameScene.cpp


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