コード例 #1
0
void ProgressBar::progressBy(float delta)
{
    float maxPercentage = 100.0f;

    bool isFinished = false;
    float nextPercentage = delta + this->getPercentage();
    if(nextPercentage >= maxPercentage){
        nextPercentage = maxPercentage;
        isFinished = true;
    }
    this->stopActionByTag(k_Progress_Action);
    CCArray *actions = CCArray::createWithCapacity(2);
    float duration = delta/this->getSpeed();
    CCProgressTo* to = CCProgressTo::create(duration, nextPercentage);
    actions->addObject(to);
    if(isFinished){
        CCCallFunc* callfunc = CCCallFunc::create(this, callfunc_selector(ProgressBar::loadingFinished));
        actions->addObject(callfunc);
    }
    CCFiniteTimeAction* seq = CCSequence::create(actions);
    
    CCCallFunc* updatePercentage = CCCallFunc::create(this, callfunc_selector(ProgressBar::updatePercentage));
    updatePercentage->setDuration(duration);

    CCSpawn* spawn = CCSpawn::createWithTwoActions(seq, updatePercentage);
    spawn->setTag(k_Progress_Action);
    
    this->runAction(spawn);
}
コード例 #2
0
ファイル: GameScene.cpp プロジェクト: studio501/fiypig
void GameScene::raisePig()
{
    if (!m_Crashed)
    {
        const float tapRaiseHeight = 80;
        float raiseHeight = MIN(tapRaiseHeight, m_VisibleOrigin.y + m_VisibleSize.height - m_pPig->getPositionY() - m_pPig->getContentSize().height / 2);

        CCActionInterval* raiseEaseOut = CCEaseSineOut::create(CCMoveBy::create(0.4f * raiseHeight / tapRaiseHeight, ccp(0, raiseHeight)));
        CCSpawn *action = CCSpawn::createWithTwoActions(raiseEaseOut, CCRotateTo::create(0.1f, -25));
        action->setTag(kTagRaise);

        m_pPig->stopActionByTag(kTagRaise);
        m_pPig->runAction(action);

        m_fFallVelocity = 0;
    }
}