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


C++ CC_CALLBACK_0函数代码示例

本文整理汇总了C++中CC_CALLBACK_0函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_CALLBACK_0函数的具体用法?C++ CC_CALLBACK_0怎么用?C++ CC_CALLBACK_0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: while

// Worker thread
void HttpClient::networkThread()
{    
    HttpRequest *request = nullptr;
    
    auto scheduler = Director::getInstance()->getScheduler();
    
    while (true) 
    {
        if (s_need_quit)
        {
            break;
        }
        
        // step 1: send http request if the requestQueue isn't empty
        request = nullptr;
        
        s_requestQueueMutex.lock();
        
        //Get request task from queue
        
        if (!s_requestQueue->empty())
        {
            request = s_requestQueue->at(0);
            s_requestQueue->erase(0);
        }
        
        s_requestQueueMutex.unlock();
        
        if (nullptr == request)
        {
            // Wait for http request tasks from main thread
            std::unique_lock<std::mutex> lk(s_SleepMutex); 
            s_SleepCondition.wait(lk);
            continue;
        }
        
        // step 2: libcurl sync access
        
        // Create a HttpResponse object, the default setting is http access failed
        HttpResponse *response = new HttpResponse(request);
        
        processResponse(response, s_errorBuffer);
        

        // add response packet into queue
        s_responseQueueMutex.lock();
        s_responseQueue->pushBack(response);
        s_responseQueueMutex.unlock();
        
        if (nullptr != s_pHttpClient) {
            scheduler->performFunctionInCocosThread(CC_CALLBACK_0(HttpClient::dispatchResponseCallbacks, this));
        }
    }
    
    // cleanup: if worker thread received quit signal, clean up un-completed request queue
    s_requestQueueMutex.lock();
    s_requestQueue->clear();
    s_requestQueueMutex.unlock();
    
    
    if (s_requestQueue != nullptr) {
        delete s_requestQueue;
        s_requestQueue = nullptr;
        delete s_responseQueue;
        s_responseQueue = nullptr;
    }
    
}
开发者ID:0xiaohui00,项目名称:Cocos2dx-Wechat,代码行数:69,代码来源:HttpClient.cpp

示例2: CC_CALLBACK_0

void Label::draw()
{
    _customCommand.init(_globalZOrder);
    _customCommand.func = CC_CALLBACK_0(Label::onDraw, this);
    Director::getInstance()->getRenderer()->addCommand(&_customCommand);
}
开发者ID:12white,项目名称:CocoStudioSamples,代码行数:6,代码来源:CCLabel.cpp

示例3: transform

void ClippingNode::visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated)
{
    if(!_visible)
        return;
    
    bool dirty = parentTransformUpdated || _transformUpdated;
    if(dirty)
        _modelViewTransform = transform(parentTransform);
    _transformUpdated = false;

    // IMPORTANT:
    // To ease the migration to v3.0, we still support the Mat4 stack,
    // but it is deprecated and your code should not rely on it
    Director* director = Director::getInstance();
    CCASSERT(nullptr != director, "Director is null when seting matrix stack");
    director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
    director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform);

    //Add group command
        
    _groupCommand.init(_globalZOrder);
    renderer->addCommand(&_groupCommand);

    renderer->pushGroup(_groupCommand.getRenderQueueID());

    _beforeVisitCmd.init(_globalZOrder);
    _beforeVisitCmd.func = CC_CALLBACK_0(ClippingNode::onBeforeVisit, this);
    renderer->addCommand(&_beforeVisitCmd);
    if (_alphaThreshold < 1)
    {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WINDOWS || CC_TARGET_PLATFORM == CC_PLATFORM_LINUX)
#else
        // since glAlphaTest do not exists in OES, use a shader that writes
        // pixel only if greater than an alpha threshold
        GLProgram *program = GLProgramCache::getInstance()->getGLProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV);
        GLint alphaValueLocation = glGetUniformLocation(program->getProgram(), GLProgram::UNIFORM_NAME_ALPHA_TEST_VALUE);
        // set our alphaThreshold
        program->use();
        program->setUniformLocationWith1f(alphaValueLocation, _alphaThreshold);
        // we need to recursively apply this shader to all the nodes in the stencil node
        // XXX: we should have a way to apply shader to all nodes without having to do this
        setProgram(_stencil, program);
        
#endif

    }
    _stencil->visit(renderer, _modelViewTransform, dirty);

    _afterDrawStencilCmd.init(_globalZOrder);
    _afterDrawStencilCmd.func = CC_CALLBACK_0(ClippingNode::onAfterDrawStencil, this);
    renderer->addCommand(&_afterDrawStencilCmd);

    int i = 0;
    
    if(!_children.empty())
    {
        sortAllChildren();
        // draw children zOrder < 0
        for( ; i < _children.size(); i++ )
        {
            auto node = _children.at(i);
            
            if ( node && node->getLocalZOrder() < 0 )
                node->visit(renderer, _modelViewTransform, dirty);
            else
                break;
        }
        // self draw
        this->draw(renderer, _modelViewTransform, dirty);
        
        for(auto it=_children.cbegin()+i; it != _children.cend(); ++it)
            (*it)->visit(renderer, _modelViewTransform, dirty);
    }
    else
    {
        this->draw(renderer, _modelViewTransform, dirty);
    }

    _afterVisitCmd.init(_globalZOrder);
    _afterVisitCmd.func = CC_CALLBACK_0(ClippingNode::onAfterVisit, this);
    renderer->addCommand(&_afterVisitCmd);

    renderer->popGroup();
    
    director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
}
开发者ID:2276225819,项目名称:Game,代码行数:86,代码来源:CCClippingNode.cpp

示例4: CC_CALLBACK_0

void GamePromptCenter::popPromptText()
{
	if ( m_promptText.empty() )
	{
		return ;
	}

	RichTextEx* pText = m_promptText[0].first;
	if ( pText )
	{
		float deltaX = 0.0f;
		float deltaY = 100.0f;

		pText->runAction(FadeOut::create(0.5f));
		pText->runAction(Sequence::create(MoveBy::create(0.5f,Point(deltaX,deltaY)),CallFunc::create( CC_CALLBACK_0(GamePromptCenter::onPromptTextPoped,this,pText)),NULL));
	}

	m_promptText.erase(m_promptText.begin());

 	// 所有提示信息往上顶
 	for ( size_t i = 0; i<m_promptText.size(); ++i )
 	{
		RichTextEx* pTextReady = m_promptText[i].first;
		if ( pTextReady )
		{
			ActionInterval* pAction = MoveBy::create(0.2f,Point(0,pText->getSize().height+3));
			pTextReady->runAction(pAction);
		}
 	}
}
开发者ID:SmallRaindrop,项目名称:LocatorApp,代码行数:30,代码来源:GamePrompt.cpp

示例5: CC_CALLBACK_0

/**
 * Draw node.
 *
 * @param renderer Renderer object
 * @param transform Transform matrix
 * @param flags Flags to draw
 */
void ShaderNode::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
{
	_customCommand.init(_globalZOrder);
	_customCommand.func = CC_CALLBACK_0(ShaderNode::onDraw, this, transform, flags);
	renderer->addCommand(&_customCommand);
}
开发者ID:drjiro,项目名称:WSSample,代码行数:13,代码来源:ShaderNode.cpp

示例6: getContentSize

void SkillItem::onSkillStarted()
{
    this->setEnabled(false);
    
    ProgressTo *to1 = ProgressTo::create(getSkillCDTime(), 100);
    ProgressTimer *sprite = ProgressTimer::create(Sprite::create(this->getDisableIcon().c_str()));
    sprite->setType(ProgressTimer::Type::RADIAL);
    
    auto tint = Sequence::create(TintTo::create(getSkillCDTime(), 60, 255, 180),
                                 NULL);

    
    sprite->setPosition(Point(getContentSize().width / 2, getContentSize().height / 2));
    sprite->setBarChangeRate(Point(0, 1));
    addChild(sprite, 0, SKILL_ITEM_CHILD_TAG);
    sprite->runAction(Sequence::create(Spawn::create(to1, tint, NULL),CallFunc::create( CC_CALLBACK_0( SkillItem::onSkillCDFinished, this)) ,NULL) );


}
开发者ID:duongbadu,项目名称:FightGame,代码行数:19,代码来源:SkillItem.cpp

示例7: CCLOG

    void Gameboard::afterSwap(Node* _Node) {
        if (firstArrived_ == nullptr) {
            CCLOG("checkSwapValid: First arrived, proceed further.");
            firstArrived_ = _Node;
            return;
        }

        firstArrived_ = nullptr;

        CCLOG("checkSwapValid: Second arrived, finally can check.");

        std::set<IPiece*> removal;
        score_->newSequence(checkResults_.size());
        for (auto vec : checkResults_) {
            uint32_t size = vec.size();
            CCLOG("Found %d pieces in row", size);

            uint32_t scoreValue = score_->addGroup(vec.size());
            for (IPiece* piece : vec) {

                board_->remove(piece->getCoords());

                Vec2 pos = coord2world(piece->getCoords());

                Sprite* sprite = piece->sprite();
                addScoreLabel(scoreValue, sprite->getPosition());
                addSomeEffects(sprite->getPosition());

                dissapear(piece);
            }
            removal.insert(vec.begin(), vec.end());

            CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("remove.wav");
        }

        for (auto it = removal.begin(); it != removal.end(); ++it) {
            delete *it;
        }

        float longestAnimationTime = refill() * FalldownSpeed;
        float waitFalldownToComplete = longestAnimationTime + FastSpeed;

        if (!check()) {
            auto waitToUnlock = Sequence::create(
                    DelayTime::create(waitFalldownToComplete),
                    CallFunc::create(CC_CALLBACK_0(Gameboard::unlock, this)),
                    nullptr);
            runAction(waitToUnlock);
        } else {
            std::function<void(Node*)> cb;
            cb = CC_CALLBACK_1(Gameboard::afterSwap, this);

            // Hack - need to call it twice to make it do the job
            auto waitToRecheck = Sequence::create(
                    DelayTime::create(waitFalldownToComplete),
                    CallFuncN::create(cb),
                    CallFuncN::create(cb),
                    nullptr);

            runAction(waitToRecheck);
        }
    }
开发者ID:antidotcb,项目名称:match3,代码行数:62,代码来源:Gameboard.cpp

示例8: CC_CALLBACK_2

//================================================================================
// シーン初期化
//================================================================================
// on "init" you need to initialize your instance
bool ResultScene::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::getInstance()->getVisibleSize() / 2 + SCREEN_CENTER;
    Vec2 origin = Director::getInstance()->getVisibleSize() / 2 - SCREEN_CENTER;
        
    AchievementDataBaseList::setAchievementMin(ACHIEVEMENT_TYPE_GAME_TIME, GAME_TIME_MAX - m_nTimeBornus);
    
    // 更新処理の追加
    this->scheduleUpdate();
    // タッチ機能の有効化
    m_pTouchEventOneByOne =  EventListenerTouchOneByOne::create();
    m_pTouchEventOneByOne->setSwallowTouches(true);
    m_pTouchEventOneByOne->onTouchBegan = CC_CALLBACK_2(ResultScene::onTouchBegin,this);
    m_pTouchEventOneByOne->onTouchMoved = CC_CALLBACK_2(ResultScene::onTouchMoved,this);
    m_pTouchEventOneByOne->onTouchCancelled = CC_CALLBACK_2(ResultScene::onTouchCancelled, this);
    m_pTouchEventOneByOne->onTouchEnded = CC_CALLBACK_2(ResultScene::onTouchEnded, this);
    this->getEventDispatcher()->addEventListenerWithFixedPriority(m_pTouchEventOneByOne, 100);
  
    //フラグに応じてゲームオーバ処理分岐
    void (ResultScene::*pFuncInit)();
    if(!m_bGameOverFlag)
    {
        pFuncInit = &ResultScene::initGameClear;
        m_pFuncUpdate = &ResultScene::updateGameClear;
        
    }else{
        pFuncInit = &ResultScene::initGameOver;
        m_pFuncUpdate = &ResultScene::updateGameOver;
        
    }
    
    (this->*pFuncInit)();
    
    //スコアとランク表示
    m_pRankManager = RankManager::create(Vec2(origin.x + 100,origin.y + 600),m_nTimeBornus, this);
    
    //ボタン表示
    MenuItemSprite* pButtonRetry;
    MenuItemSprite* pButtonTitle;
    
    //タップ前のスプライト
    Sprite* pNormalSprite = Sprite::create(TEX_RESULT_RETRY_BUTTON);
    pNormalSprite->setColor(Color3B(255,255,255));
    
    //タップ時のスプライト
    Sprite* pSelectedSprite = Sprite::create(TEX_RESULT_RETRY_BUTTON);
    pSelectedSprite->setColor(Color3B(200,200,200));
    pButtonRetry = MenuItemSprite::create(pNormalSprite,pSelectedSprite,CC_CALLBACK_0(ResultScene::ButtonRetry,this));
    
    Menu* pButton = Menu::create(pButtonRetry,NULL);
    addChild(pButton);
    
    //タイトルボタン
    //タップ前のスプライト
    Sprite* pNormalSprite2 = Sprite::create(TEX_RESULT_TITLE_BUTTON);
    pButton->setPosition(Vec2(visibleSize.width - pNormalSprite2->getContentSize().width / 2,origin.y + 240));
    pNormalSprite2->setColor(Color3B(255,255,255));

    
    //タップ時のスプライト
    Sprite* pSelectedSprite2 = Sprite::create(TEX_RESULT_TITLE_BUTTON);
    pSelectedSprite2->setColor(Color3B(200,200,200));

    pButtonTitle = MenuItemSprite::create(pNormalSprite2,pSelectedSprite2,CC_CALLBACK_0(ResultScene::ButtonTitle,this));

    pButton = Menu::create(pButtonTitle,NULL);
    pButton->setPosition(Vec2(visibleSize.width - pSelectedSprite2->getContentSize().width / 2,origin.y + 150));
    addChild(pButton);
    
    AchievementDataBaseList::saveAchievement();
    
     //今、BGMが流れているかどうか
     if(SimpleAudioEngine::getInstance()->isBackgroundMusicPlaying()){
     
         //音楽を止める
         SimpleAudioEngine::getInstance()->stopBackgroundMusic(true);
     
     }

    //音量調整
    SimpleAudioEngine::getInstance()->setBackgroundMusicVolume(BGM_RESULT_VOLUME);
    //BGMをループ再生 第二引数がループするかどうか判定
    SimpleAudioEngine::getInstance()->playBackgroundMusic(BGM_RESULT_1, true);
    
    
    return true;
}
开发者ID:sutaa12,项目名称:BrushToothGame,代码行数:98,代码来源:ResultScene.cpp

示例9: CC_CALLBACK_0

void SpineBatchNode::draw (Renderer* renderer, const Mat4& transform, uint32_t transformFlags) {
    _drawCommand.init(_globalZOrder);
    _drawCommand.func = CC_CALLBACK_0(SpineBatchNode::onDrawSkeletonBatch, this, transform, transformFlags);
    renderer->addCommand(&_drawCommand);
}
开发者ID:halx99,项目名称:SpineBatchNode,代码行数:5,代码来源:SpineBatchNode.cpp

示例10: goNextPoint

void EnemyBase::runRoute()
{
	goNextPoint();
	if (!m_isArriveEnd)
	{
		this->runAction(Sequence::create(MoveTo::create(getStepTime(), m_nextPoint), CallFuncN::create(CC_CALLBACK_0(EnemyBase::runRoute, this)), NULL));
	}
	else
	{
		EnemyManager::getInstance()->removeEnemy(this);
		this->removeFromParent();
	}
}
开发者ID:slienthuang,项目名称:Design,代码行数:13,代码来源:EnemyBase.cpp

示例11: kmGLPushMatrix

void NodeGrid::visit(Renderer *renderer, const kmMat4 &parentTransform, bool parentTransformUpdated)
{
    // quick return if not visible. children won't be drawn.
    if (!_visible)
    {
        return;
    }
    
    _groupCommand.init(_globalZOrder);
    renderer->addCommand(&_groupCommand);
    renderer->pushGroup(_groupCommand.getRenderQueueID());

    bool dirty = parentTransformUpdated || _transformUpdated;
    if(dirty)
        _modelViewTransform = this->transform(parentTransform);
    _transformUpdated = false;

    // IMPORTANT:
    // To ease the migration to v3.0, we still support the kmGL stack,
    // but it is deprecated and your code should not rely on it
    kmGLPushMatrix();
    kmGLLoadMatrix(&_modelViewTransform);

    Director::Projection beforeProjectionType;
    if(_nodeGrid && _nodeGrid->isActive())
    {
        beforeProjectionType = Director::getInstance()->getProjection();
        _nodeGrid->set2DProjection();
    }

    _gridBeginCommand.init(_globalZOrder);
    _gridBeginCommand.func = CC_CALLBACK_0(NodeGrid::onGridBeginDraw, this);
    renderer->addCommand(&_gridBeginCommand);


    if(_gridTarget)
    {
        _gridTarget->visit(renderer, _modelViewTransform, dirty);
    }
    
    int i = 0;

    if(!_children.empty())
    {
        sortAllChildren();
        // draw children zOrder < 0
        for( ; i < _children.size(); i++ )
        {
            auto node = _children.at(i);

            if ( node && node->getLocalZOrder() < 0 )
                node->visit(renderer, _modelViewTransform, dirty);
            else
                break;
        }
        // self draw,currently we have nothing to draw on NodeGrid, so there is no need to add render command
        this->draw(renderer, _modelViewTransform, dirty);

        for(auto it=_children.cbegin()+i; it != _children.cend(); ++it) {
            (*it)->visit(renderer, _modelViewTransform, dirty);
        }
    }
    else
    {
        this->draw(renderer, _modelViewTransform, dirty);
    }
    
    // reset for next frame
    _orderOfArrival = 0;
    
    if(_nodeGrid && _nodeGrid->isActive())
    {
        // restore projection
        Director *director = Director::getInstance();
        director->setProjection(beforeProjectionType);
    }

    _gridEndCommand.init(_globalZOrder);
    _gridEndCommand.func = CC_CALLBACK_0(NodeGrid::onGridEndDraw, this);
    renderer->addCommand(&_gridEndCommand);

    renderer->popGroup();
 
    kmGLPopMatrix();
}
开发者ID:1007650105,项目名称:RockChipmunk2D,代码行数:85,代码来源:CCNodeGrid.cpp

示例12: CC_CALLBACK_0

void CScrollView::beforeDraw()
{
	_beforeDrawCommand.init(_globalZOrder);
	_beforeDrawCommand.func = CC_CALLBACK_0(CScrollView::onBeforeDraw, this);
	Director::getInstance()->getRenderer()->addCommand(&_beforeDrawCommand);
}
开发者ID:Eason-Xi,项目名称:Tui-x,代码行数:6,代码来源:ScrollView.cpp

示例13: CC_CALLBACK_0

void Hills::draw(Renderer* renderer, const Mat4 &transform, uint32_t flags) {
    Node::draw(renderer, transform, flags);
    rendererCommands[0].init(0.0f);
    rendererCommands[0].func = CC_CALLBACK_0(Hills::onDraw, this, transform);
    renderer->addCommand(&rendererCommands[0]);
}
开发者ID:jfb6486,项目名称:MaoMaoPaoPaoDemo,代码行数:6,代码来源:Hills.cpp

示例14: onEnter

void GateResult::onEnter()
{
    BaseUI::onEnter();
    bool isWin=this->pResultResp.star()!=0;
    if (isWin) {
        Widget* img_bg=(Widget*)layout->getChildByName("img_bg");
        Button* btn_return=(Button*)layout->getChildByName("btn_return");
        btn_return->addTouchEventListener(CC_CALLBACK_2(GateResult::touchButtonEvent, this));
        img_bg->setVisible(false);
        btn_return->setVisible(false);
        Widget* panel_win=(Widget*)layout->getChildByName("panel_win");
        panel_win->setAnchorPoint(Vec2(0.5, 0.5));
        panel_win->setScale(0.2);
        panel_win->setVisible(true);
        Widget* img_round=(Widget*)panel_win->getChildByName("img_round");
        img_round->runAction(RepeatForever::create(RotateBy::create(1.0f, 360)));
        Clip* clip=Clip::create("winEffect.plist", "winEffect");
        clip->setPosition(panel_win->getContentSize().width/2,panel_win->getContentSize().height/2);
        clip->setScale(2, 2);
        panel_win->addChild(clip);
        clip->play(true);
        panel_win->runAction(Sequence::create(ScaleTo::create(0.3, 1),DelayTime::create(1),CCCallFunc::create(CC_CALLBACK_0(GateResult::resetUI, this)),CallFunc::create(CC_CALLBACK_0(Sprite::removeFromParent, panel_win)), NULL));
    }else{
        this->resetUI();
    }
    
    
}
开发者ID:robert1111,项目名称:fancyHeart,代码行数:28,代码来源:GateResult.cpp

示例15: CC_CALLBACK_0

void RoleLayer::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags){
    //CCLOG("RoleLayer::draw");
    _customCommand.init(1);
    _customCommand.func = CC_CALLBACK_0(RoleLayer::onDraw, this,transform,flags);
    renderer->addCommand(&_customCommand);
}
开发者ID:zhyswan,项目名称:jump,代码行数:6,代码来源:RoleLayer.cpp


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