• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setCallback函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getUniformValue

void GLProgramState::setUniformCallback(GLint uniformLocation, const std::function<void(GLProgram*, Uniform*)> &callback)
{
    auto v = getUniformValue(uniformLocation);
    if (v)
        v->setCallback(callback);
    else
        CCLOG("cocos2d: warning: Uniform at location not found: %i", uniformLocation);
}
开发者ID:Alprog,项目名称:LHR2,代码行数:8,代码来源:CCGLProgramState.cpp


示例2: setServer

PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client)
{
	this->_state = MQTT_DISCONNECTED;
	setServer(ip, port);
	setCallback(callback);
	setClient(client);
	this->stream = NULL;
}
开发者ID:malimu,项目名称:MySensors,代码行数:8,代码来源:PubSubClient.cpp


示例3: setServer

PubSubClient::PubSubClient(uint8_t *ip, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client, Stream& stream) {
    this->_state = MQTT_DISCONNECTED;
    setServer(ip,port);
    setCallback(callback);
    setClient(client);
    setStream(stream);
    setProtocol(MQTT_VERSION);
}
开发者ID:mirkoflchtt,项目名称:pubsubclient,代码行数:8,代码来源:PubSubClient.cpp


示例4: setServer

PubSubClient::PubSubClient(IPAddress addr, uint16_t port, MQTT_CALLBACK_SIGNATURE, Client& client) {
    this->_state = MQTT_DISCONNECTED;
    setServer(addr, port);
    setCallback(callback);
    setClient(client);
    this->stream = NULL;
    setListener(NULL);  // TOAST
}
开发者ID:toastedcode,项目名称:pubsubclient,代码行数:8,代码来源:PubSubClient.cpp


示例5: TEST_P

TEST_P(TestDetailedBalanceWithKernels, FissionThatShouldBeRejected) {
    auto &ctx = kernel->context();
    abcFusionFissionContext(ctx, 1e-15, 1e15); // very high off rate
    ctx.particle_types().add("D", 0.);
    ctx.potentials().addHarmonicRepulsion("A", "D", 10., 2.);
    ctx.potentials().addHarmonicRepulsion("B", "D", 10., 2.);

    const auto idfus = ctx.reactions().idOf("fusion");
    const auto idfis = ctx.reactions().idOf("fission");

    auto countsObs = kernel->observe().reactionCounts(1);
    countsObs->setCallback([&idfus, &idfis](const readdy::model::observables::ReactionCounts::result_type &result) {
        if (result.empty()) {
            readdy::log::trace("reaction counts is empty, no reaction handler ran so far, skip test");
            return;
        }
        EXPECT_EQ(result.at(idfis), 0) << "fission shall not occur";
        EXPECT_EQ(result.at(idfus), 0) << "fusion shall not occur";
    });
    auto countsConnection = kernel->connectObservable(countsObs.get());

    std::vector<std::string> typesToCount = {"A", "B", "C", "D"};
    auto numbersObs = kernel->observe().nParticles(1, typesToCount);
    numbersObs->setCallback([](const readdy::model::observables::NParticles::result_type &result) {
        EXPECT_EQ(result[0] + result[2], 1) << "conservation of A + C";
        EXPECT_EQ(result[1] + result[2], 1) << "conservation of B + C";
        EXPECT_EQ(result[3], 500) << "conservation of D";
        if (result[0] + result[2] != 1) {
            readdy::log::trace("A {} B {} C {}", result[0], result[1], result[2]);
        }
    });
    auto numbersConnection = kernel->connectObservable(numbersObs.get());

    const auto idc = ctx.particle_types().idOf("C");
    const auto idd = ctx.particle_types().idOf("D");
    kernel->stateModel().addParticle({{-0.1, -0.1, -0.1}, idc});

    // induce rejection by many repulsing particles in the vicinity
    for (std::size_t i = 0; i < 500; ++i) {
        auto pos = m::rnd::normal3(0., 1.);
        kernel->stateModel().addParticle({pos, idd});
    }

    readdy::scalar timeStep = 0.1;
    perform(kernel.get(), 1, timeStep);
}
开发者ID:chrisfroe,项目名称:readdy,代码行数:46,代码来源:TestDetailedBalance.cpp


示例6: Vec2

Scene* Chapter7_1::createScene()
{
    cocos2d::Rect visibleRect = Director::getInstance()->getOpenGLView()->getVisibleRect();
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    // create a scene
    auto scene = Scene::create();
    
    // add title
    auto label = LabelTTF::create("TileMap", "Marker Felt.ttf", 32);
    label->setPosition(Vec2(visibleRect.origin.x+visibleRect.size.width/2, visibleRect.origin.y+visibleRect.size.height/2).x,
                       Vec2(visibleRect.origin.x+visibleRect.size.width/2, visibleRect.origin.y+visibleRect.size.height).y - 30);
    
    scene->addChild(label, -1);
    
    //add the menu item for back to main menu
    label = LabelTTF::create("MainMenu", "Marker Felt.ttf", 32);
    auto menuItem = MenuItemLabel::create(label);
    menuItem->setCallback([&](cocos2d::Ref *sender) {
        Director::getInstance()->replaceScene(Chapter7::createScene());
    });
    
    auto menu = Menu::create(menuItem, nullptr);
    menu->setPosition(Vec2::ZERO);
    menuItem->setPosition(Vec2(visibleRect.origin.x+visibleRect.size.width - 80, visibleRect.origin.y + 25));
    scene->addChild(menu, 1);
    
    // TileMap
    auto map = TMXTiledMap::create("isometric_grass_and_water.tmx");
    map->setPosition(Vec2(visibleSize.width/2 - map->getContentSize().width/2, 0));
    
    auto listener1 = EventListenerTouchOneByOne::create();
    
    listener1->onTouchBegan = [](Touch* touch, Event* event){
        return true; // if you are consuming it
    };
    
    listener1->onTouchEnded = [=](Touch* touch, Event* event){
        auto layer = map->getLayer("layer0");
        Size viewSize = Director::getInstance()->getWinSize();
        
        Vec2 mapCordinate = map->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
        int tileX = mapCordinate.x / map->getTileSize().width;
        int tileY = (viewSize.height - mapCordinate.y) / map->getTileSize().height;
        
        int id = layer->getTileGIDAt(Vec2(tileX, tileY));
        Sprite* tileSprite = layer->getTileAt(Vec2(tileX, tileY));
        
        std::cout << "Tile GID: " << id << std::endl;
    };
    
    Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener1, map);
    
    scene->addChild(map, 0, 99); // with a tag of '99'
    
    return scene;
}
开发者ID:IPubby,项目名称:programmers-guide-samples,代码行数:58,代码来源:Chapter7_1.cpp


示例7: setCallback

void Curl::reset() {
	buffer = "";
	http_response_code = 0;
	response_headers.clear();
	http_response_message.clear();
	setCallback();
	setUserPass();
	setDefaultOptions();
}
开发者ID:HellicarAndLewis,项目名称:Hub,代码行数:9,代码来源:Curl.cpp


示例8: mapFileType

libfalltergeist::MapFileType* ResourceManager::mapFileType(std::string filename)
{
    auto item = dynamic_cast<libfalltergeist::MapFileType*>(datFileItem(filename));
    if (item)
    {
        item->setCallback(&ResourceManager::proFileType);
    }
    return item;
}
开发者ID:poxu,项目名称:falltergeist,代码行数:9,代码来源:ResourceManager.cpp


示例9: init

bool MainMenuLayer::init()
{
    if(!Layer::init())
    {
        return false;
    }
    
	MenuItemFont::setFontName("fonts/arial.ttf");
	MenuItemFont::setFontSize(40);

	auto menuItemSelectMap = MenuItemFont::create(std::string(LocalizedCStringByKey("start_game")));
	menuItemSelectMap->setCallback(
		[=](Ref*)
	{

		static_cast<LayerMultiplex*>(_parent)->switchTo(1);
	}
		);


	auto menuItemMapMaker = MenuItemFont::create(std::string(LocalizedCStringByKey("map_maker")));
	menuItemMapMaker->setCallback(
		[](Ref*)
	{
		auto scene = Scene::create();
		scene->addChild(MapMakerScene::create());
		Director::getInstance()->replaceScene(TransitionFlipX::create(0.5, scene));

	}
	);


	auto menu = Menu::create(menuItemSelectMap, menuItemMapMaker, nullptr);
	menu->alignItemsVerticallyWithPadding(20);

	auto s = Director::getInstance()->getWinSize();
	addChild(menu);
	menu->setPosition(Vec2(s.width / 2, s.height / 2));
	


    return true;
}
开发者ID:xu1hua,项目名称:SquareClear,代码行数:43,代码来源:MainMenuLayer.cpp


示例10: initTitle

void InstanceLayer::initTitle()
{
	Size size = Director::getInstance()->getVisibleSize();

	//顶部的文字
	title_custom_instance = Sprite::createWithSpriteFrameName("titlename_instance_custom.png");
	title_custom_instance->setPosition(size.width/2, 690);
	this->addChild(title_custom_instance, 4);

	//精英按钮
	auto button_left_normal = Sprite::createWithSpriteFrameName("button_left_0.png");
	auto button_left_pressed = Sprite::createWithSpriteFrameName("button_left_1.png");
	auto button_left_disable = Sprite::createWithSpriteFrameName("button_left_2.png");
	auto menuItem = MenuItemSprite::create(button_left_normal, button_left_pressed, button_left_disable);
	menuItem->setCallback([](Ref* pSender){
	
	});

	auto text_elite_install = Sprite::createWithSpriteFrameName("text_elite.png");
	text_elite_install->setPosition(button_left_normal->getContentSize().width/2 - 15, button_left_normal->getContentSize().height/2);
	menuItem->addChild(text_elite_install);

	menu_left = Menu::create(menuItem, NULL);
	menu_left->setPosition(menuItem->getContentSize().width/2 - 10, 687);
	this->addChild(menu_left, 4);

	//活动按钮
	auto button_right_normal = Sprite::createWithSpriteFrameName("button_left_0.png");
	auto button_right_pressed = Sprite::createWithSpriteFrameName("button_left_1.png");
	auto button_right_disable = Sprite::createWithSpriteFrameName("button_left_2.png");
	auto menu_rightItem = MenuItemSprite::create(button_right_normal, button_right_pressed, button_right_disable);
	menu_rightItem->setCallback([](Ref* pSender){
	
	});

	auto text_activity = Sprite::createWithSpriteFrameName("text_activity.png");
	text_activity->setPosition(button_right_normal->getContentSize().width/2 - 15, button_right_normal->getContentSize().height/2);
	menu_rightItem->addChild(text_activity);

	menu_right = Menu::create(menu_rightItem, NULL);
	menu_right->setPosition(size.width - button_right_normal->getContentSize().width/2 + 30, 687);
	this->addChild(menu_right);
}
开发者ID:Youjk,项目名称:CardGame,代码行数:43,代码来源:InstanceLayer.cpp


示例11: createMenuItemImage

MenuItemImage* CustomTool::createMenuItemImage(const char* normal, const char* selected, ccMenuCallback callback)
{
	auto item = MenuItemImage::create();
	auto nsf = SpriteFrameCache::getInstance()->getSpriteFrameByName(normal);
	auto ssf = SpriteFrameCache::getInstance()->getSpriteFrameByName(selected);
	item->setNormalSpriteFrame(nsf);
	item->setSelectedSpriteFrame(ssf);
	item->setCallback(callback);
	return item;
}
开发者ID:forthxu,项目名称:brave,代码行数:10,代码来源:CustomTool.cpp


示例12: _drawAABB

OBBTest::OBBTest():
_drawAABB(nullptr),
_pick(false),
_camera(nullptr)
{
    auto listener = EventListenerTouchAllAtOnce::create();
    listener->onTouchesBegan = CC_CALLBACK_2(OBBTest::onTouchesBegan, this);
    listener->onTouchesEnded = CC_CALLBACK_2(OBBTest::onTouchesEnded, this);
    listener->onTouchesMoved = CC_CALLBACK_2(OBBTest::onTouchesMoved, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    
    auto s = Director::getInstance()->getWinSize();
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    auto winSize = Director::getInstance()->getWinSize();
    
    // add title
    auto label = LabelTTF::create("OBB", "Arial", 24);
    label->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x,
                       Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - 30);
    
    this->addChild(label, -1);
    
    //add the menu item for back to main menu
    label = LabelTTF::create("MainMenu", "Arial", 24);
    auto menuItem = MenuItemLabel::create(label);
    menuItem->setCallback([&](cocos2d::Ref *sender) {
        Director::getInstance()->replaceScene(Chapter9::createScene());
    });
    auto menu = Menu::create(menuItem, nullptr);
    menu->setPosition( Vec2::ZERO );
    menuItem->setPosition( Vec2(origin.x+visibleSize.width - 80, origin.y + 25) );
    this->addChild(menu, 1);
    
    auto layer3D=Layer::create();
    addChild(layer3D);
    
    // add camera
    _camera=Camera::createPerspective(60, (GLfloat)winSize.width/winSize.height, 1, 1000);
    _camera->setCameraFlag(CameraFlag::USER1);// set camera flag
    _camera->setPosition3D(Vec3(0, 50, 230));
    _camera->lookAt(Vec3(0,0,0), Vec3(0,1,0));
    layer3D->addChild(_camera);
    
    _drawAABB = DrawNode3D::create();
    
    Vec3 extents = Vec3(60, 30, 100);
    AABB aabb = AABB(-extents, extents);
    _obb = OBB(aabb);
    layer3D->addChild(_drawAABB);
    
    layer3D->setCameraMask(2);
    
    scheduleUpdate();
}
开发者ID:IPubby,项目名称:programmers-guide-samples,代码行数:55,代码来源:Chapter9_7.cpp


示例13: Vec2

Scene* Chapter9_2::createScene()
{
    Size visibleSize = Director::getInstance()->getVisibleSize();
    Vec2 origin = Director::getInstance()->getVisibleOrigin();
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // create a scene
    // 'scene' is an autorelease object
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    auto scene = Scene::create();
    
    // add title
    auto label = LabelTTF::create("3D skeleton animation", "Arial", 24);
    label->setPosition(Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x,
                       Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height).y - 30);
    
    scene->addChild(label, -1);
    
    //add the menu item for back to main menu
    label = LabelTTF::create("MainMenu", "Arial", 24);
    auto menuItem = MenuItemLabel::create(label);
    menuItem->setCallback([&](cocos2d::Ref *sender) {
        Director::getInstance()->replaceScene(Chapter9::createScene());
    });
    auto menu = Menu::create(menuItem, nullptr);
    menu->setPosition( Vec2::ZERO );
    menuItem->setPosition( Vec2(origin.x+visibleSize.width - 80, origin.y + 25) );
    scene->addChild(menu, 1);
    
    std::string fileName = "orc.c3b";
    
    auto sprite = Sprite3D::create(fileName);
    sprite->setScale(8.f);
    sprite->setRotation3D(Vec3(0,180,0));
    sprite->setPosition( Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).x,
                        Vec2(origin.x+visibleSize.width/2, origin.y+visibleSize.height/2).y );
    
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // play skeleton animation
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    auto animation = Animation3D::create(fileName);
    if (animation)
    {
        auto animate = Animate3D::create(animation);
        animate->setSpeed(1);
        sprite->runAction(RepeatForever::create(animate));
    }
    
    //add to scene
    scene->addChild(sprite);
    
    // return the scene
    return scene;
}
开发者ID:ArkightCrossfaith,项目名称:learning-cocos2dx,代码行数:54,代码来源:Chapter9_2.cpp


示例14: removeControl

void cContextMenu::clear() {
	// Iterate over all known controls and see how high this thing is
	Iterator it;
	for (it = entries.begin(); it != entries.end(); ++it) {
		removeControl((*it));
		delete *it;
	}
	entries.clear();

	setCallback(0, 0); // Reset callback
}
开发者ID:BackupTheBerlios,项目名称:wolfpack-svn,代码行数:11,代码来源:contextmenu.cpp


示例15:

MenuSourceItem * MenuSourceButton::copy() {
	auto ret = construct<MenuSourceButton>();
	ret->setName(_name);
	ret->setNameIcon(_nameIcon);
	ret->setValue(_name);
	ret->setValueIcon(_nameIcon);
	ret->setSelected(_selected);
	ret->setNextMenu(_nextMenu);
	ret->setCallback(_callback);
	ret->setCustomData(_customData);
	return ret;
}
开发者ID:SBKarr,项目名称:stappler,代码行数:12,代码来源:MaterialMenuSource.cpp


示例16: main

int main() {
	udp = initUDP();

	start();

	int status = 0;
	while (status == 0) {
		status = setCallback(&packet_handler);
	}

	return 0;
}
开发者ID:jywang,项目名称:tunnel61850,代码行数:12,代码来源:main.c


示例17: AllianceTerritoryDetailCommand

void TerritoryResourceDetailView::requestDetail() {
    m_isInUpdate = true;
    unsigned index = m_cityInfo.cityIndex;
    if (m_cityInfo.parentCityIndex != -1) {
        index = m_cityInfo.parentCityIndex;
    }
    if (WorldController::isInSelfServer(m_cityInfo.tileServerId)) {
        auto cmd = new AllianceTerritoryDetailCommand(index);
        cmd->setCallback(CCCallFuncO::create(this, callfuncO_selector(TerritoryResourceDetailView::onDetailCallback), nullptr));
        cmd->sendAndRelease();
    }
}
开发者ID:ourgames,项目名称:dc208,代码行数:12,代码来源:TerritoryResourceDetailView.cpp


示例18: start

    void start (AudioIODeviceCallback* newCallback)
    {
        stop();

        if (deviceOpen && callback != newCallback)
        {
            if (newCallback != nullptr)
                newCallback->audioDeviceAboutToStart (this);

            setCallback (newCallback);
        }
    }
开发者ID:oeberhard,项目名称:BAVSN,代码行数:12,代码来源:juce_android_OpenSL.cpp


示例19: setCallback

PubSubClient::PubSubClient() {
    this->_state = MQTT_DISCONNECTED;
    this->_client = NULL;
    this->stream = NULL;
    setCallback(NULL);
#ifdef MQTT_PCN006_SUPPORT_WAIT_FOR_ACK
    waitAck = ackState = 0x00;
#endif
#ifdef MQTT_PCN007_SUPPORT_PUB_QOS
    pub_qos = MQTTQOS0;
#endif
}
开发者ID:Ameba8195,项目名称:Arduino,代码行数:12,代码来源:PubSubClient.cpp


示例20: resetCallback

void __fastcall TfrmCompetitorCategoryResultEdit::bbtnEnterResultClick(
      TObject *Sender)
{

    //Сохранить результаты текущего участника
    if(resultModified){

        resetCallback();


        //Выбрать нового участника
        int currentCompetitorId = TResult::getCurrentCompetitorId();

        //Установить полученный результаты в выпадющем списке
        AnsiString fwok = cmboxFightWOKnifeRank->Text;
        AnsiString fwk = cmboxFightWKnifeRank->Text;
        AnsiString sht = cmboxShootRank->Text;
        AnsiString cmmn = cmboxCommonRank->Text;

        if(fwok.IsEmpty()){fwok = "0";}
        if(fwk.IsEmpty()){fwk = "0";}
        if(sht.IsEmpty()){sht = "0";}
        if(cmmn.IsEmpty()){cmmn = "0";}

        currentCompetitor.result.setFightWOKnifeRank(
                            StrToInt(fwok));
        currentCompetitor.result.setFightWKnifeRank(
                            StrToInt(fwk));
        currentCompetitor.result.setShootRank(
                            StrToInt(sht));
        currentCompetitor.result.setCommonRank(
                            StrToInt(cmmn));

        //Сохраним результат участника
        currentCompetitor.storeResult(currentCategory->getId());
        //Отобразить список участников снова
        ShowCompetitorList(currentCategory);

        //Установить выбранную запись как текущуую
        TResult::setCurrentCompetitorById(currentCompetitorId);

        cmboxFightWOKnifeRank->Text = !fwok.AnsiCompare("0") ? AnsiString("") : fwok;
        cmboxFightWKnifeRank->Text = !fwk.AnsiCompare("0") ? AnsiString("") : fwk;
        cmboxShootRank->Text = !sht.AnsiCompare("0") ? AnsiString("") : sht;
        cmboxCommonRank->Text = !cmmn.AnsiCompare("0") ? AnsiString("") : cmmn;

        showResultScores();

        HideResultChange();

        setCallback();
        }
}
开发者ID:agoffer,项目名称:secretary,代码行数:53,代码来源:competitorCategoryResultEditU.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setCamera函数代码示例发布时间:2022-05-30
下一篇:
C++ setCacheMode函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap